Paper/patches/server/0836-Add-pre-unbreaking-amount-to-PlayerItemDamageEvent.patch

24 lines
1.4 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: HexedHero <6012891+HexedHero@users.noreply.github.com>
Date: Sun, 10 Apr 2022 06:26:32 +0100
Subject: [PATCH] Add pre-unbreaking amount to PlayerItemDamageEvent
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
2022-12-07 22:35:34 +01:00
index 64738fffa5ab0cb9ea22fa7198856ea69d8e9cfd..8450a22b0fc6e8dc5cad0f61ac52a82b3cd3791e 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
2022-12-07 22:35:34 +01:00
@@ -571,10 +571,11 @@ public final class ItemStack {
}
}
+ int originalDamage = amount; // Paper
amount -= k;
// CraftBukkit start
if (player instanceof ServerPlayer serverPlayer) { // Paper
- PlayerItemDamageEvent event = new PlayerItemDamageEvent(serverPlayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), amount); // Paper
+ PlayerItemDamageEvent event = new PlayerItemDamageEvent(serverPlayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), amount, originalDamage); // Paper
event.getPlayer().getServer().getPluginManager().callEvent(event);
if (amount != event.getDamage() || event.isCancelled()) {