Skip to content

Commit

Permalink
Fix ItemMeta#removeEnchantments (#10886)
Browse files Browse the repository at this point in the history
  • Loading branch information
GhastCraftHD authored and kennytv committed Jun 15, 2024
1 parent fb511c6 commit b420038
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion patches/server/0971-General-ItemMeta-fixes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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 <julius.gruenberg@leghast.de>

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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion patches/server/0978-Fix-equipment-slot-and-group-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b420038

Please sign in to comment.