diff options
Diffstat (limited to 'patches/server/0693-Expand-PlayerItemDamageEvent.patch')
-rw-r--r-- | patches/server/0693-Expand-PlayerItemDamageEvent.patch | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/patches/server/0693-Expand-PlayerItemDamageEvent.patch b/patches/server/0693-Expand-PlayerItemDamageEvent.patch new file mode 100644 index 0000000000..d550002186 --- /dev/null +++ b/patches/server/0693-Expand-PlayerItemDamageEvent.patch @@ -0,0 +1,23 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: HexedHero <[email protected]> +Date: Sun, 10 Apr 2022 06:26:32 +0100 +Subject: [PATCH] Expand PlayerItemDamageEvent + + +diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java +index eeba6d3aeb50bc7ee6dcfe7cc18eee2487d47357..598507684aed7978fa2e9bae0d959c7d0f9e53d6 100644 +--- a/src/main/java/net/minecraft/world/item/ItemStack.java ++++ b/src/main/java/net/minecraft/world/item/ItemStack.java +@@ -650,10 +650,11 @@ public final class ItemStack implements DataComponentHolder { + if (this.isDamageableItem()) { + if (player == null || !player.hasInfiniteMaterials()) { + if (amount > 0) { ++ int originalDamage = amount; // Paper - Expand PlayerItemDamageEvent + amount = EnchantmentHelper.processDurabilityChange(world, this, amount); + // CraftBukkit start + if (player instanceof ServerPlayer serverPlayer) { // Paper - Add EntityDamageItemEvent +- PlayerItemDamageEvent event = new PlayerItemDamageEvent(serverPlayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), amount); // Paper - Add EntityDamageItemEvent ++ PlayerItemDamageEvent event = new PlayerItemDamageEvent(serverPlayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), amount, originalDamage); // Paper - Add EntityDamageItemEvent & Expand PlayerItemDamageEvent + event.getPlayer().getServer().getPluginManager().callEvent(event); + + if (amount != event.getDamage() || event.isCancelled()) { |