diff --git a/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java b/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java index 4c56408858..1dfeda4871 100644 --- a/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java +++ b/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java @@ -90,7 +90,7 @@ public final class CraftLegacy { return (mappedData == null) ? new MaterialData(Material.LEGACY_AIR) : mappedData; } - public static IBlockData fromLegacyData(Material material, Block block, byte data) { + public static IBlockData fromLegacyData(Material material, byte data) { Preconditions.checkArgument(material.isLegacy(), "fromLegacyData on modern Material"); MaterialData materialData = new MaterialData(material, data); @@ -107,11 +107,11 @@ public final class CraftLegacy { return convertedBlock.getBlockData(); } - // Return existing block - return block.getBlockData(); + // Return air + return Blocks.AIR.getBlockData(); } - public static Item fromLegacyData(Material material, Item item, short data) { + public static Item fromLegacyData(Material material, short data) { Preconditions.checkArgument(material.isLegacy(), "fromLegacyData on modern Material. Did you forget to define api-version: 1.13 in your plugin.yml?"); MaterialData materialData = new MaterialData(material, (byte) data); @@ -137,8 +137,8 @@ public final class CraftLegacy { } } - // Return existing item - return item; + // Return air + return Items.AIR; } public static byte toLegacyData(IBlockData blockData) { diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index afe4004ff2..68728b4d86 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -56,7 +56,7 @@ public final class CraftMagicNumbers implements UnsafeValues { } public static IBlockData getBlock(Material material, byte data) { - return CraftLegacy.fromLegacyData(CraftLegacy.toLegacy(material), getBlock(material), data); + return CraftLegacy.fromLegacyData(CraftLegacy.toLegacy(material), data); } public static MaterialData getMaterial(IBlockData data) { @@ -65,7 +65,7 @@ public final class CraftMagicNumbers implements UnsafeValues { public static Item getItem(Material material, short data) { if (material.isLegacy()) { - return CraftLegacy.fromLegacyData(CraftLegacy.toLegacy(material), getItem(material), data); + return CraftLegacy.fromLegacyData(CraftLegacy.toLegacy(material), data); } return getItem(material); @@ -114,10 +114,18 @@ public final class CraftMagicNumbers implements UnsafeValues { } public static Item getItem(Material material) { + if (material != null && material.isLegacy()) { + material = CraftLegacy.fromLegacy(material); + } + return MATERIAL_ITEM.get(material); } public static Block getBlock(Material material) { + if (material != null && material.isLegacy()) { + material = CraftLegacy.fromLegacy(material); + } + return MATERIAL_BLOCK.get(material); }