From b4200387992e94d23766a061b999083946dec7b0 Mon Sep 17 00:00:00 2001 From: Ghast <70332776+ghastcrafthd@users.noreply.github.com> Date: Sat, 15 Jun 2024 17:26:55 +0200 Subject: [PATCH] Fix ItemMeta#removeEnchantments (#10886) --- patches/server/0971-General-ItemMeta-fixes.patch | 13 ++++++++++++- .../0978-Fix-equipment-slot-and-group-API.patch | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/patches/server/0971-General-ItemMeta-fixes.patch b/patches/server/0971-General-ItemMeta-fixes.patch index 563ec07fd9..776e90997b 100644 --- a/patches/server/0971-General-ItemMeta-fixes.patch +++ b/patches/server/0971-General-ItemMeta-fixes.patch @@ -9,6 +9,8 @@ public net/minecraft/world/food/FoodProperties DEFAULT_EAT_SECONDS public org/bukkit/craftbukkit/block/CraftBlockStates getBlockState(Lorg/bukkit/World;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/entity/BlockEntity;)Lorg/bukkit/craftbukkit/block/CraftBlockState; public net/minecraft/world/level/block/entity/BlockEntity saveId(Lnet/minecraft/nbt/CompoundTag;)V +Co-authored-by: GhastCraftHD + diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java index 486c3769a0e6a1ecb5530a35e2591f78776619b9..b800b03ae034b276740c3b41555a52b778ad9aad 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java @@ -828,7 +830,7 @@ index 97b7085250d749c5e46352b372068b51de89bc7f..7277e7ee566aabf6e01937072d949ed6 } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -index 8cfce9c557c4411914adffd10872bf3129435423..d2a7414f3ae9fb23a2f9f2ed7fd0a50a4aa3d7d9 100644 +index 8cfce9c557c4411914adffd10872bf3129435423..d9d4b983672b4340df926d98a7fa6708acad8a05 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -182,9 +182,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -895,6 +897,15 @@ index 8cfce9c557c4411914adffd10872bf3129435423..d2a7414f3ae9fb23a2f9f2ed7fd0a50a this.lore = lore != null ? io.papermc.paper.adventure.PaperAdventure.asVanilla(lore) : null; } // Paper end +@@ -1164,7 +1169,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { + @Override + public void removeEnchantments() { + if (this.hasEnchants()) { +- this.enchantments.clear(); ++ this.enchantments = null; // Paper - Correctly clear enchantments + } + } + @@ -1230,6 +1235,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { // Paper end @Override diff --git a/patches/server/0978-Fix-equipment-slot-and-group-API.patch b/patches/server/0978-Fix-equipment-slot-and-group-API.patch index 637547f1ea..0369dbaa73 100644 --- a/patches/server/0978-Fix-equipment-slot-and-group-API.patch +++ b/patches/server/0978-Fix-equipment-slot-and-group-API.patch @@ -32,7 +32,7 @@ index 9d74577af071954e1e37201a96368c1360076209..eafa54c870c3e2aef30c3f9f96f51660 throw new IllegalArgumentException("Not implemented. This is a bug"); } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -index d2a7414f3ae9fb23a2f9f2ed7fd0a50a4aa3d7d9..89c545d4390c7f717f496806fed1d5bc094db0f1 100644 +index d9d4b983672b4340df926d98a7fa6708acad8a05..7c6d4c08cf07da18b414773dfed5704926938bea 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -1452,7 +1452,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {