diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index d7fb0acb74..f4672b9a48 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -22,6 +22,7 @@ import org.bukkit.material.MaterialData; import com.google.common.collect.ImmutableMap; import org.bukkit.craftbukkit.enchantments.CraftEnchantment; +import org.bukkit.craftbukkit.util.CraftLegacy; import org.bukkit.craftbukkit.util.CraftNamespacedKey; @DelegateDeserialization(ItemStack.class) @@ -545,7 +546,8 @@ public final class CraftItemStack extends ItemStack { if (handle == null || that.handle == null) { return false; } - if (!(that.getType() == getType() && getDurability() == that.getDurability())) { + Material comparisonType = CraftLegacy.fromLegacy(that.getType()); // This may be called from legacy item stacks, try to get the right material + if (!(comparisonType == getType() && getDurability() == that.getDurability())) { return false; } return hasItemMeta() ? that.hasItemMeta() && handle.getTag().equals(that.handle.getTag()) : !that.hasItemMeta(); diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java b/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java index ea2fa6f419..ea6b88853c 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java @@ -147,6 +147,10 @@ public class CraftLegacy { } public static Material fromLegacy(Material material) { + if (material == null || !material.isLegacy()) { + return material; + } + return fromLegacy(new MaterialData(material)); }