From f4277d7105c1b4b03b494084b2ad9519056003d4 Mon Sep 17 00:00:00 2001 From: feildmaster Date: Thu, 10 Oct 2013 17:54:29 -0500 Subject: Force item data to use a tag name. Fixes BUKKIT-4809 The recent Minecraft update rendered the e20e50f85083dc53cb5456254bcf5781ef750daa fix incorrect by adding a compound name to the base tag in some code. This fix changes all uses of tag changes to explicitly use a name. --- src/main/java/net/minecraft/server/ItemStack.java | 9 +++++++-- .../java/org/bukkit/craftbukkit/inventory/CraftItemStack.java | 9 +++++---- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java index 69f81ca1..808860ed 100644 --- a/src/main/java/net/minecraft/server/ItemStack.java +++ b/src/main/java/net/minecraft/server/ItemStack.java @@ -117,8 +117,8 @@ public final class ItemStack { } if (nbttagcompound.hasKey("tag")) { - // CraftBukkit - clear name from compound and make defensive copy as this data may be coming from the save thread - this.tag = (NBTTagCompound) nbttagcompound.getCompound("tag").clone().setName(""); + // CraftBukkit - make defensive copy as this data may be coming from the save thread + this.tag = (NBTTagCompound) nbttagcompound.getCompound("tag").clone(); } } @@ -334,6 +334,11 @@ public final class ItemStack { } public void setTag(NBTTagCompound nbttagcompound) { + // CraftBukkit start - Set compound name to "tag," remove discrepancy + if (nbttagcompound != null) { + nbttagcompound.setName("tag"); + } + // CraftBukkit end this.tag = nbttagcompound; } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index c70d41bd..51d5beb7 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -191,10 +191,11 @@ public final class CraftItemStack extends ItemStack { if (item == null) { return false; } - if (item.tag != null) { - return true; + + if (item.tag == null) { + item.setTag(new NBTTagCompound("tag")); } - item.tag = new NBTTagCompound(); + return true; } @@ -350,7 +351,7 @@ public final class CraftItemStack extends ItemStack { return false; } - NBTTagCompound tag = new NBTTagCompound(); + NBTTagCompound tag = new NBTTagCompound("tag"); item.setTag(tag); ((CraftMetaItem) itemMeta).applyToItem(tag); -- cgit v1.2.3