aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrew Teeter <[email protected]>2024-05-01 06:01:48 -0400
committerGitHub <[email protected]>2024-05-01 12:01:48 +0200
commitb8c454c2ba204af066685d2a5c4dcdd65299050d (patch)
treebf8d8780c4980c18444d344d8e83ae37eab7435a
parent4cfd9e25fad4ab9a40452acb090467249c19d105 (diff)
downloadPaper-b8c454c2ba204af066685d2a5c4dcdd65299050d.tar.gz
Paper-b8c454c2ba204af066685d2a5c4dcdd65299050d.zip
Add damage check for mending (#10631)
-rw-r--r--patches/server/0167-Ability-to-apply-mending-to-XP-API.patch4
1 files changed, 2 insertions, 2 deletions
diff --git a/patches/server/0167-Ability-to-apply-mending-to-XP-API.patch b/patches/server/0167-Ability-to-apply-mending-to-XP-API.patch
index 4dbdc50fe5..92a6a66574 100644
--- a/patches/server/0167-Ability-to-apply-mending-to-XP-API.patch
+++ b/patches/server/0167-Ability-to-apply-mending-to-XP-API.patch
@@ -14,7 +14,7 @@ public net.minecraft.world.entity.ExperienceOrb durabilityToXp(I)I
public net.minecraft.world.entity.ExperienceOrb xpToDurability(I)I
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
-index 7e1f6e23980f12786abaa4218d8d77dd1a8feb3c..791b655890ce5b144f8649f687945c17a390ce76 100644
+index 7e1f6e23980f12786abaa4218d8d77dd1a8feb3c..96277af4b3c1ebe081bf4aa42c7b78f1f084cbd6 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1624,7 +1624,37 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -27,7 +27,7 @@ index 7e1f6e23980f12786abaa4218d8d77dd1a8feb3c..791b655890ce5b144f8649f687945c17
+ ServerPlayer handle = this.getHandle();
+ // Logic copied from EntityExperienceOrb and remapped to unobfuscated methods/properties
+ final var stackEntry = net.minecraft.world.item.enchantment.EnchantmentHelper
-+ .getRandomItemWith(net.minecraft.world.item.enchantment.Enchantments.MENDING, handle);
++ .getRandomItemWith(net.minecraft.world.item.enchantment.Enchantments.MENDING, handle, net.minecraft.world.item.ItemStack::isDamaged);
+ final net.minecraft.world.item.ItemStack itemstack = stackEntry != null ? stackEntry.getValue() : net.minecraft.world.item.ItemStack.EMPTY;
+ if (!itemstack.isEmpty() && itemstack.getItem().components().has(net.minecraft.core.component.DataComponents.MAX_DAMAGE)) {
+ net.minecraft.world.entity.ExperienceOrb orb = net.minecraft.world.entity.EntityType.EXPERIENCE_ORB.create(handle.level());