Exemplo n.º 1
0
 public void load(T state, CompoundTag compound) {
   String checkId = ((StringTag) compound.getValue().get("id")).getValue();
   if (!id.equalsIgnoreCase(checkId)) {
     throw new IllegalArgumentException(
         "Invalid ID loading tile entity, expected " + id + " got " + checkId);
   }
   int checkX = ((IntTag) compound.getValue().get("x")).getValue(), x = state.getX();
   int checkY = ((IntTag) compound.getValue().get("y")).getValue(), y = state.getY();
   int checkZ = ((IntTag) compound.getValue().get("z")).getValue(), z = state.getZ();
   if (x != checkX || y != checkY || z != checkZ) {
     throw new IllegalArgumentException(
         "Invalid coords loading tile entity, expected ("
             + x
             + ","
             + y
             + ","
             + z
             + ") got ("
             + checkX
             + ","
             + checkY
             + ","
             + checkZ
             + ")");
   }
 }
Exemplo n.º 2
0
 public ItemStack readItemStack(CompoundTag compound) {
   ItemStack stack = null;
   Tag idTag = compound.getValue().get("id");
   Tag damageTag = compound.getValue().get("Damage");
   Tag countTag = compound.getValue().get("Count");
   short id = (idTag == null) ? 0 : ((ShortTag) idTag).getValue();
   short damage = (damageTag == null) ? 0 : ((ShortTag) damageTag).getValue();
   byte count = (countTag == null) ? 0 : ((ByteTag) countTag).getValue();
   if (id != 0 && count != 0) {
     stack = new ItemStack(id, count, damage);
   }
   return stack;
 }
Exemplo n.º 3
0
 @Override
 public void load(GlowItem entity, CompoundTag compound) {
   if (compound.getValue().containsKey("Item")) {
     ItemStack stack = readItemStack((CompoundTag) compound.getValue().get("Item"));
     entity.setItemStack(stack);
   }
   if (compound.getValue().containsKey("Health")) {
     // item.setHealth(((IntTag)compound.getValue().get("Health")).getValue());
   }
   if (compound.getValue().containsKey("Age")) {
     // item.setAge(((IntTag)compound.getValue().get("Age")).getValue());
   }
 }
Exemplo n.º 4
0
 @Override
 public GlowItem load(GlowServer server, GlowWorld world, CompoundTag compound) {
   ItemStack stack = null;
   if (compound.getValue().containsKey("Item")) {
     stack = readItemStack((CompoundTag) compound.getValue().get("Item"));
   }
   GlowItem item = new GlowItem(server, world, stack);
   if (compound.getValue().containsKey("Health")) {
     // item.setHealth(((IntTag)compound.getValue().get("Health")).getValue());
   }
   if (compound.getValue().containsKey("Age")) {
     // item.setAge(((IntTag)compound.getValue().get("Age")).getValue());
   }
   return item;
 }
Exemplo n.º 5
0
 /**
  * Writes a <code>TAG_Compound</code> tag.
  *
  * @param tag The tag.
  * @throws IOException if an I/O error occurs.
  */
 private void writeCompoundTagPayload(CompoundTag tag) throws IOException {
   for (Tag childTag : tag.getValue().values()) {
     writeTag(childTag);
   }
   os.writeByte((byte) 0); // end tag - better way?
 }