Beispiel #1
0
  @Override
  public void readPacketData(PacketBuffer in) throws IOException {
    receive = true;
    try {
      field_148863_a = in.readInt();
      field_148861_b = in.readShort();
      field_148862_c = in.readInt();

      NBTTagCompound received = in.readNBTTagCompoundFromBuffer();
      if (!received.getBoolean(ERROR_TAG)) {
        // try {
        this.populateFromStream(received);
        // }
        // catch (Exception e) {
        //	e.printStackTrace();
        //	data.clear(); //discard packet
        // }
      }
    } catch (Exception e) {
      DragonAPICore.logError("Error reading Sync Tag!");
      e.printStackTrace();
      data.clear();
    }
    receive = false;
  }
Beispiel #2
0
  public void setData(TileEntity te, boolean force, NBTTagCompound NBT) {
    if (dispatch) {
      if (DragonOptions.LOGSYNCCME.getState()) {
        DragonAPICore.log("The sync packet for " + te + " would have just CME'd, as the");
        DragonAPICore.log(
            "Server-Thread data-writing code has overlapped with the Network-Thread byte[] dispatch.");
        DragonAPICore.log("Seeing this message frequently could indicate a serious issue.\n");
      }
      return;
    }

    field_148863_a = te.xCoord;
    field_148861_b = te.yCoord;
    field_148862_c = te.zCoord;

    changes.clear();
    Collection c = NBT.func_150296_c();
    Iterator<String> it = c.iterator();
    while (it.hasNext()) {
      String name = it.next();
      if (name == null) {
        DragonAPICore.logError(
            "An NBT tag with a null key is being sent to the sync packet from " + te);
      } else {
        NBTBase tag = NBT.getTag(name);
        this.addData(name, tag, force);
      }
    }
  }
 /**
  * Triggers one of TC's native FX. It is your responsibility to ensure the correct parameters are
  * chosen for the relevant Effect Type.
  */
 @SideOnly(Side.CLIENT)
 public static void triggerEffect(EffectType type, Object... data) {
   try {
     type.call.invoke(proxy, data);
   } catch (Exception e) {
     DragonAPICore.logError("Error Triggering ThaumCraft Effect: " + e.getMessage());
     e.printStackTrace();
   }
 }
 private static AspectList getAspectList(Object... aspects) {
   AspectList ot = new AspectList();
   try {
     for (int i = 0; i < aspects.length; i += 2) {
       ot.add((Aspect) aspects[i], (Integer) aspects[i + 1]);
     }
   } catch (ClassCastException e) {
     DragonAPICore.logError(
         "Invalid parameters! Could not generate aspect list from "
             + Arrays.toString(aspects)
             + "!");
     e.printStackTrace();
   }
   return ot;
 }
  /** Contains a helper function to avoid overwriting existing aspects. */
  public static void addAspects(ItemStack is, Object... aspects) {
    if (aspects.length % 2 != 0) {
      DragonAPICore.logError(
          "Could not add aspects to " + is + ": You must specify a level for every aspect!");
      ReikaJavaLibrary.dumpStack();
      return;
    }
    AspectList has = ThaumcraftApi.objectTags.get(Arrays.asList(is.getItem(), is.getItemDamage()));
    AspectList ot = getAspectList(aspects);

    if (has != null) {
      for (Aspect as : has.aspects.keySet()) {
        ot.merge(as, has.getAmount(as));
      }
    }
    clearNullAspects(ot);
    ThaumcraftApi.registerObjectTag(is, ot);
    DragonAPICore.log("Registering " + is + " aspects " + aspectsToString(ot));
  }
Beispiel #6
0
  @Override
  public void writePacketData(PacketBuffer out) throws IOException {
    dispatch = true;
    out.writeInt(field_148863_a);
    out.writeShort(field_148861_b);
    out.writeInt(field_148862_c);

    NBTTagCompound toSend = new NBTTagCompound();
    try {
      this.saveChanges(toSend);
    } catch (Exception e) {
      toSend.setBoolean(ERROR_TAG, true);
      e.printStackTrace();
      // out.clear();
    }
    try {
      out.writeNBTTagCompoundToBuffer(toSend);
    } catch (Exception e) {
      DragonAPICore.logError("Error writing Sync Tag!");
      out.clear();
      e.printStackTrace();
    }
    dispatch = false;
  }
  static {
    if (ModList.THAUMCRAFT.isLoaded()) {

      nativeCategories.add("BASICS");
      nativeCategories.add("THAUMATURGY");
      nativeCategories.add("ALCHEMY");
      nativeCategories.add("ARTIFICE");
      nativeCategories.add("GOLEMANCY");
      nativeCategories.add("ELDRITCH");

      try {
        Class c = Class.forName("thaumcraft.common.Thaumcraft");
        Field f = c.getField("proxy");
        proxy = f.get(null);

        Class cp = Class.forName("thaumcraft.common.CommonProxy");
        Field kn = cp.getField("playerKnowledge");
        Object knowledge = kn.get(proxy);
        Class ck = Class.forName("thaumcraft.common.lib.research.PlayerKnowledge");
        Field res = ck.getField("researchCompleted");
        Field objs = ck.getField("objectsScanned");
        Field ents = ck.getField("entitiesScanned");
        Field phen = ck.getField("phenomenaScanned");
        Field asp = ck.getField("aspectsDiscovered");
        Field warp = ck.getField("warp");
        Field warpsticky = ck.getField("warpSticky");
        Field warptemp = ck.getField("warpTemp");

        aspects = (Map) asp.get(knowledge);
        research = (Map) res.get(knowledge);
        scannedObjects = (Map) objs.get(knowledge);
        scannedEntities = (Map) ents.get(knowledge);
        scannedPhenomena = (Map) phen.get(knowledge);
        playerWarp = (Map) warp.get(knowledge);
        playerStickyWarp = (Map) warpsticky.get(knowledge);
        playerTempWarp = (Map) warptemp.get(knowledge);
      } catch (Exception e) {
        DragonAPICore.logError("Could not load ThaumCraft PlayerKnowledge Handler!");
        e.printStackTrace();
        ReflectiveFailureTracker.instance.logModReflectiveFailure(ModList.THAUMCRAFT, e);
      }

      try {
        Class wand = Class.forName("thaumcraft.common.items.wands.ItemWandCasting");
        addWandVis =
            wand.getMethod("addVis", ItemStack.class, Aspect.class, int.class, boolean.class);
        getWandVis = wand.getMethod("getAllVis", ItemStack.class);
        maxWandVis = wand.getMethod("getMaxVis", ItemStack.class);
        setWandInUse =
            wand.getMethod("setObjectInUse", ItemStack.class, int.class, int.class, int.class);
        clearWandInUse = wand.getMethod("clearObjectInUse", ItemStack.class);
      } catch (Exception e) {
        DragonAPICore.logError("Could not load ThaumCraft Wand Handler!");
        e.printStackTrace();
        ReflectiveFailureTracker.instance.logModReflectiveFailure(ModList.THAUMCRAFT, e);
      }

      try {
        Class mgr = Class.forName("thaumcraft.common.lib.research.ResearchManager");
        researchComplete = mgr.getMethod("isResearchComplete", String.class, String.class);
      } catch (Exception e) {
        DragonAPICore.logError("Could not load ThaumCraft Research Handler!");
        e.printStackTrace();
        ReflectiveFailureTracker.instance.logModReflectiveFailure(ModList.THAUMCRAFT, e);
      }

      try {
        Class wisp = Class.forName("thaumcraft.common.entities.monster.EntityWisp");
        wispTarget = wisp.getDeclaredField("targetedEntity");
        wispTarget.setAccessible(true);
      } catch (Exception e) {
        DragonAPICore.logError("Could not load ThaumCraft Mob Handler!");
        e.printStackTrace();
        ReflectiveFailureTracker.instance.logModReflectiveFailure(ModList.THAUMCRAFT, e);
      }

      try {
        Field[] fds = Aspect.class.getDeclaredFields();
        for (int i = 0; i < fds.length; i++) {
          Field fd = fds[i];
          if (fd.getType() == Aspect.class) {
            Aspect a = (Aspect) fd.get(null);
            if (a != null) {
              allAspects.add(a);
            }
          }
        }
      } catch (Exception e) {
        DragonAPICore.logError("Could not load ThaumCraft Aspect Handler!");
        e.printStackTrace();
        ReflectiveFailureTracker.instance.logModReflectiveFailure(ModList.THAUMCRAFT, e);
      }

      if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
        try {
          Class clip = Class.forName("thaumcraft.client.ClientProxy");

          for (int i = 0; i < EffectType.list.length; i++) {
            EffectType type = EffectType.list[i];
            type.call = clip.getMethod(type.name, type.arguments);
          }
        } catch (Exception e) {
          DragonAPICore.logError("Could not load ThaumCraft Effect Handler!");
          e.printStackTrace();
          ReflectiveFailureTracker.instance.logModReflectiveFailure(ModList.THAUMCRAFT, e);
        }
      }
    }
  }