Package org.spout.nbt

Examples of org.spout.nbt.CompoundMap


      if (material == null) {
        throw new IOException("Unknown material with id of " + id);
      }
      int count = buffer.readUnsignedByte();
      int damage = buffer.readUnsignedShort();
      CompoundMap nbtData = readCompound(buffer);
      return new ItemStack(material, damage, count).setNBTData(nbtData);
    }
  }
View Full Code Here


      } else {
        return false;
      }
    }

    CompoundMap nbtData = item.getNBTData();
    if (nbtData == null) {
      nbtData = new CompoundMap();
    }
    List<CompoundTag> enchantments = new ArrayList<CompoundTag>();
    if (nbtData.get("ench") instanceof ListTag<?>) {
      enchantments = new ArrayList<CompoundTag>(((ListTag<CompoundTag>) nbtData.get("ench")).getValue());
    }
    CompoundMap map = new CompoundMap();
    map.put(new ShortTag("id", (short) enchantment.getId()));
    map.put(new ShortTag("lvl", (short) powerLevel));
    enchantments.add(new CompoundTag(null, map));
    nbtData.put(new ListTag<CompoundTag>("ench", CompoundTag.class, enchantments));
    item.setNBTData(nbtData);
    return true;
  }
View Full Code Here

   *
   * @param item Item to check
   * @return true if the item contains any enchantment
   */
  public static boolean isEnchanted(ItemStack item) {
    CompoundMap nbtData = item.getNBTData();
    return nbtData != null && nbtData.containsKey("ench") && nbtData.get("ench") instanceof ListTag<?>;
  }
View Full Code Here

  public EntityTileDataMessage decode(ByteBuf buffer) throws IOException {
    int x = buffer.readInt();
    int y = buffer.readShort();
    int z = buffer.readInt();
    byte action = buffer.readByte();
    CompoundMap data = ByteBufUtils.readCompound(buffer);
    return new EntityTileDataMessage(x, y, z, action, data, NullRepositionManager.getInstance());
  }
View Full Code Here

TOP

Related Classes of org.spout.nbt.CompoundMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.