From 7c0a97e8762235a960e0798a22ee1336c30f18dd Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Thu, 30 Aug 2018 09:06:10 +1000 Subject: [PATCH] SPIGOT-4330: Improve isSimilar for legacy stacks By: md_5 --- paper-api/src/main/java/org/bukkit/inventory/ItemStack.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/paper-api/src/main/java/org/bukkit/inventory/ItemStack.java b/paper-api/src/main/java/org/bukkit/inventory/ItemStack.java index 2e44d4e2a9..c744799f64 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ItemStack.java @@ -120,6 +120,8 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { } if (type.isLegacy()) { createData((byte) 0); + } else { + this.data = null; } } @@ -263,7 +265,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { if (stack == this) { return true; } - Material comparisonType = Bukkit.getUnsafe().fromLegacy(this.getType()); // This may be called from legacy item stacks, try to get the right material + Material comparisonType = (this.type.isLegacy()) ? Bukkit.getUnsafe().fromLegacy(this.getData(), true) : this.type; // This may be called from legacy item stacks, try to get the right material return comparisonType == stack.getType() && getDurability() == stack.getDurability() && hasItemMeta() == stack.hasItemMeta() && (hasItemMeta() ? Bukkit.getItemFactory().equals(getItemMeta(), stack.getItemMeta()) : true); }