2016-12-03 03:04:24 +00:00
From ba3e15745ed9c595c8b787eff25b4092ab524e97 Mon Sep 17 00:00:00 2001
2016-09-22 03:42:13 +00:00
From: Aikar <aikar@aikar.co>
Date: Wed, 4 May 2016 22:31:18 -0400
Subject: [PATCH] Process NMS Data Conversion post ItemMeta on Copy
ItemMeta apply is a destructive process that expects to be the authority on
what the items NBT data is.
When CraftItemStack.asNMSCopy was called, the conversion ran, potentially setting
the converted data into the ItemStacks tag.
Then if that item had ItemMeta, it would completely undo that conversion by
erasing the NBT Tag.
On copy, run conversion post ItemMeta apply.
2016-12-03 03:04:24 +00:00
diff --git a/src/main/java/net/minecraft/server/DataInspectorBlockEntity.java b/src/main/java/net/minecraft/server/DataInspectorBlockEntity.java
index 4a8820e68..27fb802bf 100644
--- a/src/main/java/net/minecraft/server/DataInspectorBlockEntity.java
+++ b/src/main/java/net/minecraft/server/DataInspectorBlockEntity.java
@@ -32,7 +32,7 @@ public class DataInspectorBlockEntity implements DataInspector {
boolean flag;
if (s1 == null) {
- DataInspectorBlockEntity.a.warn("Unable to resolve BlockEntity for ItemInstance: {}", new Object[] { s});
+ //DataInspectorBlockEntity.a.warn("Unable to resolve BlockEntity for ItemInstance: {}", new Object[] { s}); // Paper - no need to nag about an ok condition
flag = false;
} else {
flag = !nbttagcompound2.hasKey("id");
2016-09-22 03:42:13 +00:00
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
2016-12-03 03:04:24 +00:00
index 66973051a..1218c005e 100644
2016-09-22 03:42:13 +00:00
--- a/src/main/java/net/minecraft/server/ItemStack.java
+++ b/src/main/java/net/minecraft/server/ItemStack.java
2016-11-17 02:23:38 +00:00
@@ -55,13 +55,24 @@ public final class ItemStack {
2016-09-22 03:42:13 +00:00
this(item, i, 0);
}
+ // Paper start
public ItemStack(Item item, int i, int j) {
+ this(item, i, j, true);
+ }
+ public ItemStack(Item item, int i, int j, boolean convert) {
+ // Paper end
this.item = item;
2016-11-17 02:23:38 +00:00
this.damage = j;
2016-09-22 03:42:13 +00:00
this.count = i;
2016-11-17 02:23:38 +00:00
// CraftBukkit start - Pass to setData to do filtering
2016-09-22 03:42:13 +00:00
+ // Paper start
2016-11-17 02:23:38 +00:00
+ if (convert) convertData(j);
2016-09-22 03:42:13 +00:00
+ }
2016-11-17 02:23:38 +00:00
+
+ public final void convertData(int data) {
2016-09-22 03:42:13 +00:00
+ // Paper end
if (MinecraftServer.getServer() != null) {
2016-11-17 02:23:38 +00:00
- this.setData(j);
+ this.setData(data);
2016-09-22 03:42:13 +00:00
NBTTagCompound savedStack = new NBTTagCompound();
this.save(savedStack);
2016-11-17 02:23:38 +00:00
MinecraftServer.getServer().getDataConverterManager().a(DataConverterTypes.ITEM_INSTANCE, savedStack); // PAIL: convert
2016-09-22 03:42:13 +00:00
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
2016-12-03 03:04:24 +00:00
index 4afd3a99a..a862e946c 100644
2016-09-22 03:42:13 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
2016-11-17 02:23:38 +00:00
@@ -41,10 +41,11 @@ public final class CraftItemStack extends ItemStack {
return net.minecraft.server.ItemStack.a;
2016-09-22 03:42:13 +00:00
}
- net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(item, original.getAmount(), original.getDurability());
+ net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(item, original.getAmount(), original.getDurability(), false); // Paper
if (original.hasItemMeta()) {
setItemMeta(stack, original.getItemMeta());
}
2016-11-17 02:23:38 +00:00
+ stack.convertData(original.getDurability()); // Paper
2016-09-22 03:42:13 +00:00
return stack;
}
--
2016-12-03 03:04:24 +00:00
2.11.0
2016-09-22 03:42:13 +00:00