diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java b/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java index 83ac79f798..15f24e9d31 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java @@ -163,6 +163,10 @@ public class CraftLegacy { } public static Material fromLegacy(MaterialData materialData) { + return fromLegacy(materialData, false); + } + + public static Material fromLegacy(MaterialData materialData, boolean itemPriority) { Material material = materialData.getItemType(); if (material == null || !material.isLegacy()) { return material; @@ -170,7 +174,15 @@ public class CraftLegacy { Material mappedData = null; - if (material.isBlock()) { + // Try item first + if (itemPriority) { + Item item = materialToItem.get(materialData); + if (item != null) { + mappedData = CraftMagicNumbers.getMaterial(item); + } + } + + if (mappedData == null && material.isBlock()) { // Try exact match first IBlockData iblock = materialToData.get(materialData); if (iblock != null) { @@ -187,7 +199,7 @@ public class CraftLegacy { } // Fallback to matching item - if (mappedData == null) { + if (!itemPriority && mappedData == null) { Item item = materialToItem.get(materialData); if (item != null) { mappedData = CraftMagicNumbers.getMaterial(item); diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 3474536f75..21d0062d9c 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -134,6 +134,11 @@ public final class CraftMagicNumbers implements UnsafeValues { return CraftLegacy.fromLegacy(material); } + @Override + public Material fromLegacy(MaterialData material, boolean itemPriority) { + return CraftLegacy.fromLegacy(material, itemPriority); + } + @Override public BlockData fromLegacy(Material material, byte data) { return CraftBlockData.fromData(getBlock(material, data));