From 19e69bb8fc7a1ddf7b4691668ca4e3edee73b601 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sat, 6 Jan 2024 16:07:58 +1100 Subject: [PATCH] #1324: Improve ItemFactory#enchantItem consistency By: Miles Holder --- .../bukkit/craftbukkit/inventory/CraftItemFactory.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java index c1d9f917cc..3c79efcf98 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -489,13 +489,8 @@ public final class CraftItemFactory implements ItemFactory { private static ItemStack enchantItem(RandomSource source, ItemStack itemStack, int level, boolean allowTreasures) { Preconditions.checkArgument(itemStack != null, "ItemStack must not be null"); Preconditions.checkArgument(!itemStack.getType().isAir(), "ItemStack must not be air"); - - if (!(itemStack instanceof CraftItemStack)) { - itemStack = CraftItemStack.asCraftCopy(itemStack); - } - + itemStack = CraftItemStack.asCraftCopy(itemStack); CraftItemStack craft = (CraftItemStack) itemStack; - EnchantmentManager.enchantItem(source, craft.handle, level, allowTreasures); - return craft; + return CraftItemStack.asCraftMirror(EnchantmentManager.enchantItem(source, craft.handle, level, allowTreasures)); } }