From 6268eb5a3edc61c2cca57a68a44e51a65da01baf Mon Sep 17 00:00:00 2001 From: Thinkofdeath Date: Sun, 7 Dec 2014 11:36:31 +0000 Subject: Fix BlockEntityTag being stripped from items --- .../bukkit/craftbukkit/inventory/CraftMetaItem.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/main/java/org') diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index e658e4a3..9fb42563 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -196,16 +196,20 @@ class CraftMetaItem implements ItemMeta, Repairable { static final ItemMetaKey ATTRIBUTES_UUID_HIGH = new ItemMetaKey("UUIDMost"); @Specific(Specific.To.NBT) static final ItemMetaKey ATTRIBUTES_UUID_LOW = new ItemMetaKey("UUIDLeast"); + @Specific(Specific.To.NBT) + static final ItemMetaKey BLOCK_ENTITY_TAG = new ItemMetaKey("BlockEntityTag"); private String displayName; private List lore; private Map enchantments; private int repairCost; private final NBTTagList attributes; + private final NBTTagCompound blockEntityTag; CraftMetaItem(CraftMetaItem meta) { if (meta == null) { attributes = null; + blockEntityTag = null; return; } @@ -221,6 +225,7 @@ class CraftMetaItem implements ItemMeta, Repairable { this.repairCost = meta.repairCost; this.attributes = meta.attributes; + blockEntityTag = meta.blockEntityTag; } CraftMetaItem(NBTTagCompound tag) { @@ -296,6 +301,12 @@ class CraftMetaItem implements ItemMeta, Repairable { } else { attributes = null; } + + if (tag.hasKeyOfType(BLOCK_ENTITY_TAG.NBT, 10)) { + blockEntityTag = tag.getCompound(BLOCK_ENTITY_TAG.NBT); + } else { + blockEntityTag = null; + } } static Map buildEnchantments(NBTTagCompound tag, ItemMetaKey key) { @@ -332,6 +343,7 @@ class CraftMetaItem implements ItemMeta, Repairable { } attributes = null; + blockEntityTag = null; } static Map buildEnchantments(Map map, ItemMetaKey key) { @@ -371,6 +383,10 @@ class CraftMetaItem implements ItemMeta, Repairable { if (attributes != null) { itemTag.set(ATTRIBUTES.NBT, attributes); } + + if (blockEntityTag != null) { + itemTag.set(BLOCK_ENTITY_TAG.NBT, blockEntityTag); + } } static NBTTagList createStringList(List list) { @@ -539,7 +555,8 @@ class CraftMetaItem implements ItemMeta, Repairable { && (this.hasEnchants() ? that.hasEnchants() && this.enchantments.equals(that.enchantments) : !that.hasEnchants()) && (this.hasLore() ? that.hasLore() && this.lore.equals(that.lore) : !that.hasLore()) && (this.hasAttributes() ? that.hasAttributes() && this.attributes.equals(that.attributes) : !that.hasAttributes()) - && (this.hasRepairCost() ? that.hasRepairCost() && this.repairCost == that.repairCost : !that.hasRepairCost()); + && (this.hasRepairCost() ? that.hasRepairCost() && this.repairCost == that.repairCost : !that.hasRepairCost()) + && (this.blockEntityTag != null ? that.blockEntityTag != null && this.blockEntityTag.equals(this.blockEntityTag) : that.blockEntityTag == null); } /** -- cgit v1.2.3