Example #1
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);
      }
    }
  }
Example #2
0
  @SideOnly(Side.CLIENT)
  public void readForSync(TileEntity te, NBTTagCompound NBT) {
    if (dispatch) {
      if (DragonOptions.LOGSYNCCME.getState()) {
        DragonAPICore.log("The sync packet for " + te + " would have just CME'd, as the");
        DragonAPICore.log(
            "Client-Thread data-reading code has overlapped with the Network-Thread byte[] reading.");
        DragonAPICore.log("Seeing this message frequently could indicate a serious issue.\n");
      }
      return;
    }

    for (String key : data.keySet()) {
      NBT.setTag(key, data.get(key));
    }
  }
  public static void addAspects(ItemStack is, AspectList aspects) {
    AspectList has = ThaumcraftApi.objectTags.get(Arrays.asList(is.getItem(), is.getItemDamage()));

    if (has != null) {
      for (Aspect as : has.aspects.keySet()) {
        aspects.merge(as, has.getAmount(as));
      }
    }
    clearNullAspects(aspects);
    ThaumcraftApi.registerObjectTag(is, new int[] {is.getItemDamage()}, aspects);
    DragonAPICore.log("Registering " + is + " aspects " + aspectsToString(aspects));
  }
  /** 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));
  }