diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java index 39ac9ac827..b7243eba80 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemMetas.java @@ -2,8 +2,14 @@ package org.bukkit.craftbukkit.inventory; import java.util.function.BiFunction; import java.util.function.Function; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemBanner; +import net.minecraft.world.item.ItemBlock; +import net.minecraft.world.item.ItemMonsterEgg; +import net.minecraft.world.item.ItemSign; import net.minecraft.world.item.ItemStack; -import org.bukkit.Tag; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.BlockShulkerBox; import org.bukkit.inventory.ItemType; import org.bukkit.inventory.meta.ArmorMeta; import org.bukkit.inventory.meta.AxolotlBucketMeta; @@ -150,7 +156,10 @@ public final class CraftItemMetas { // We use if instead of a set, since the result gets cached in CraftItemType, // which would result in dead memory once all ItemTypes have cached the data. - public static ItemMetaData getItemMetaData(ItemType itemType) { + public static ItemMetaData getItemMetaData(CraftItemType itemType) { + Item itemHandle = itemType.getHandle(); + Block blockHandle = (itemHandle instanceof ItemBlock itemBlock) ? itemBlock.getBlock() : null; + if (itemType == ItemType.AIR) { return asType(EMPTY_META_DATA); } @@ -203,50 +212,10 @@ public final class CraftItemMetas { if (itemType == ItemType.ENCHANTED_BOOK) { return asType(ENCHANTED_BOOK_META_DATA); } - if (itemType.hasBlockType() && Tag.BANNERS.isTagged(itemType.getBlockType().asMaterial())) { + if (itemHandle instanceof ItemBanner) { return asType(BANNER_META_DATA); } - if (itemType == ItemType.ARMADILLO_SPAWN_EGG || itemType == ItemType.ALLAY_SPAWN_EGG - || itemType == ItemType.ARMADILLO_SPAWN_EGG || itemType == ItemType.ALLAY_SPAWN_EGG - || itemType == ItemType.AXOLOTL_SPAWN_EGG || itemType == ItemType.BAT_SPAWN_EGG - || itemType == ItemType.BEE_SPAWN_EGG || itemType == ItemType.BLAZE_SPAWN_EGG - || itemType == ItemType.BOGGED_SPAWN_EGG || itemType == ItemType.BREEZE_SPAWN_EGG - || itemType == ItemType.CAT_SPAWN_EGG || itemType == ItemType.CAMEL_SPAWN_EGG - || itemType == ItemType.CAVE_SPIDER_SPAWN_EGG || itemType == ItemType.CHICKEN_SPAWN_EGG - || itemType == ItemType.COD_SPAWN_EGG || itemType == ItemType.COW_SPAWN_EGG - || itemType == ItemType.CREEPER_SPAWN_EGG || itemType == ItemType.DOLPHIN_SPAWN_EGG - || itemType == ItemType.DONKEY_SPAWN_EGG || itemType == ItemType.DROWNED_SPAWN_EGG - || itemType == ItemType.ELDER_GUARDIAN_SPAWN_EGG || itemType == ItemType.ENDER_DRAGON_SPAWN_EGG - || itemType == ItemType.ENDERMAN_SPAWN_EGG || itemType == ItemType.ENDERMITE_SPAWN_EGG - || itemType == ItemType.EVOKER_SPAWN_EGG || itemType == ItemType.FOX_SPAWN_EGG - || itemType == ItemType.FROG_SPAWN_EGG || itemType == ItemType.GHAST_SPAWN_EGG - || itemType == ItemType.GLOW_SQUID_SPAWN_EGG || itemType == ItemType.GOAT_SPAWN_EGG - || itemType == ItemType.GUARDIAN_SPAWN_EGG || itemType == ItemType.HOGLIN_SPAWN_EGG - || itemType == ItemType.HORSE_SPAWN_EGG || itemType == ItemType.HUSK_SPAWN_EGG - || itemType == ItemType.IRON_GOLEM_SPAWN_EGG || itemType == ItemType.LLAMA_SPAWN_EGG - || itemType == ItemType.MAGMA_CUBE_SPAWN_EGG || itemType == ItemType.MOOSHROOM_SPAWN_EGG - || itemType == ItemType.MULE_SPAWN_EGG || itemType == ItemType.OCELOT_SPAWN_EGG - || itemType == ItemType.PANDA_SPAWN_EGG || itemType == ItemType.PARROT_SPAWN_EGG - || itemType == ItemType.PHANTOM_SPAWN_EGG || itemType == ItemType.PIGLIN_BRUTE_SPAWN_EGG - || itemType == ItemType.PIGLIN_SPAWN_EGG || itemType == ItemType.PIG_SPAWN_EGG - || itemType == ItemType.PILLAGER_SPAWN_EGG || itemType == ItemType.POLAR_BEAR_SPAWN_EGG - || itemType == ItemType.PUFFERFISH_SPAWN_EGG || itemType == ItemType.RABBIT_SPAWN_EGG - || itemType == ItemType.RAVAGER_SPAWN_EGG || itemType == ItemType.SALMON_SPAWN_EGG - || itemType == ItemType.SHEEP_SPAWN_EGG || itemType == ItemType.SHULKER_SPAWN_EGG - || itemType == ItemType.SILVERFISH_SPAWN_EGG || itemType == ItemType.SKELETON_HORSE_SPAWN_EGG - || itemType == ItemType.SKELETON_SPAWN_EGG || itemType == ItemType.SLIME_SPAWN_EGG - || itemType == ItemType.SNIFFER_SPAWN_EGG || itemType == ItemType.SNOW_GOLEM_SPAWN_EGG - || itemType == ItemType.SPIDER_SPAWN_EGG || itemType == ItemType.SQUID_SPAWN_EGG - || itemType == ItemType.STRAY_SPAWN_EGG || itemType == ItemType.STRIDER_SPAWN_EGG - || itemType == ItemType.TADPOLE_SPAWN_EGG || itemType == ItemType.TRADER_LLAMA_SPAWN_EGG - || itemType == ItemType.TROPICAL_FISH_SPAWN_EGG || itemType == ItemType.TURTLE_SPAWN_EGG - || itemType == ItemType.VEX_SPAWN_EGG || itemType == ItemType.VILLAGER_SPAWN_EGG - || itemType == ItemType.VINDICATOR_SPAWN_EGG || itemType == ItemType.WANDERING_TRADER_SPAWN_EGG - || itemType == ItemType.WARDEN_SPAWN_EGG || itemType == ItemType.WITCH_SPAWN_EGG - || itemType == ItemType.WITHER_SKELETON_SPAWN_EGG || itemType == ItemType.WITHER_SPAWN_EGG - || itemType == ItemType.WOLF_SPAWN_EGG || itemType == ItemType.ZOGLIN_SPAWN_EGG - || itemType == ItemType.ZOMBIE_HORSE_SPAWN_EGG || itemType == ItemType.ZOMBIE_SPAWN_EGG - || itemType == ItemType.ZOMBIE_VILLAGER_SPAWN_EGG || itemType == ItemType.ZOMBIFIED_PIGLIN_SPAWN_EGG) { + if (itemHandle instanceof ItemMonsterEgg) { return asType(SPAWN_EGG_META_DATA); } if (itemType == ItemType.ARMOR_STAND) { @@ -258,13 +227,13 @@ public final class CraftItemMetas { if (itemType == ItemType.FURNACE || itemType == ItemType.CHEST || itemType == ItemType.TRAPPED_CHEST || itemType == ItemType.JUKEBOX || itemType == ItemType.DISPENSER || itemType == ItemType.DROPPER - || (itemType.hasBlockType() && Tag.ALL_SIGNS.isTagged(itemType.getBlockType().asMaterial())) || itemType == ItemType.SPAWNER + || itemHandle instanceof ItemSign || itemType == ItemType.SPAWNER || itemType == ItemType.BREWING_STAND || itemType == ItemType.ENCHANTING_TABLE || itemType == ItemType.COMMAND_BLOCK || itemType == ItemType.REPEATING_COMMAND_BLOCK || itemType == ItemType.CHAIN_COMMAND_BLOCK || itemType == ItemType.BEACON || itemType == ItemType.DAYLIGHT_DETECTOR || itemType == ItemType.HOPPER || itemType == ItemType.COMPARATOR || itemType == ItemType.STRUCTURE_BLOCK - || (itemType.hasBlockType() && Tag.SHULKER_BOXES.isTagged(itemType.getBlockType().asMaterial())) + || blockHandle instanceof BlockShulkerBox || itemType == ItemType.ENDER_CHEST || itemType == ItemType.BARREL || itemType == ItemType.BELL || itemType == ItemType.BLAST_FURNACE || itemType == ItemType.CAMPFIRE || itemType == ItemType.SOUL_CAMPFIRE