use of net.glowstone.util.GlowUnsafeValues in project Glowstone by GlowstoneMC.
the class GlowBufUtils method readSlot.
/**
* Read an item stack from the buffer.
*
* @param buf The buffer.
* @param network Mark network source.
* @return The stack read, or null.
*/
public static ItemStack readSlot(ByteBuf buf, boolean network) throws IOException {
boolean present = buf.readBoolean();
if (!present) {
return InventoryUtil.createEmptyStack();
}
int type = ByteBufUtils.readVarInt(buf);
int amount = buf.readUnsignedByte();
GlowUnsafeValues unsafeValues = (GlowUnsafeValues) Bukkit.getServer().getUnsafe();
Material material = unsafeValues.fromId(type);
if (material == null) {
return InventoryUtil.createEmptyStack();
}
CompoundTag tag = readCompound(buf, network);
ItemStack stack = new ItemStack(material, amount);
stack.setItemMeta(GlowItemFactory.instance().readNbt(material, tag));
return stack;
}
Aggregations