Correctly check enchants for ItemStack#damage (#11240)

This commit is contained in:
Jake Potrebic 2024-08-11 13:27:24 -07:00
parent e0bec73f14
commit e574dc326d

View file

@ -28,11 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (player == null || !player.hasInfiniteMaterials() || force) { // Paper
if (amount > 0) {
int originalDamage = amount; // Paper - Expand PlayerItemDamageEvent
- amount = EnchantmentHelper.processDurabilityChange(world, this, amount);
+ if (!force) amount = EnchantmentHelper.processDurabilityChange(world, this, amount); // Paper - itemstack damage API - do not consider enchantments when damaging from API
// CraftBukkit start
if (player instanceof ServerPlayer serverPlayer) { // Paper - Add EntityDamageItemEvent
PlayerItemDamageEvent event = new PlayerItemDamageEvent(serverPlayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), amount, originalDamage); // Paper - Add EntityDamageItemEvent & Expand PlayerItemDamageEvent
amount = EnchantmentHelper.processDurabilityChange(world, this, amount);
@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder {
}