summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorThinkofdeath <thinkofdeath@spigotmc.org>2014-12-07 11:36:31 +0000
committerThinkofdeath <thinkofdeath@spigotmc.org>2014-12-07 11:36:31 +0000
commit6268eb5a3edc61c2cca57a68a44e51a65da01baf (patch)
treefa8296787385c5fa6918592f74f8e5548b4323ce /src/main
parent7bb3034c786a068a4c59e56a1b7e1af4ad2b2122 (diff)
downloadcraftbukkit-6268eb5a3edc61c2cca57a68a44e51a65da01baf.tar
craftbukkit-6268eb5a3edc61c2cca57a68a44e51a65da01baf.tar.gz
craftbukkit-6268eb5a3edc61c2cca57a68a44e51a65da01baf.tar.lz
craftbukkit-6268eb5a3edc61c2cca57a68a44e51a65da01baf.tar.xz
craftbukkit-6268eb5a3edc61c2cca57a68a44e51a65da01baf.zip
Fix BlockEntityTag being stripped from items
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java19
1 files changed, 18 insertions, 1 deletions
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<String> lore;
private Map<Enchantment, Integer> 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<Enchantment, Integer> buildEnchantments(NBTTagCompound tag, ItemMetaKey key) {
@@ -332,6 +343,7 @@ class CraftMetaItem implements ItemMeta, Repairable {
}
attributes = null;
+ blockEntityTag = null;
}
static Map<Enchantment, Integer> buildEnchantments(Map<String, Object> 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<String> 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);
}
/**