From 5c1a983514ad3a0434c114d4ecb1a919157b4fb9 Mon Sep 17 00:00:00 2001 From: granny Date: Sat, 3 May 2025 20:12:19 -0700 Subject: [PATCH] fix issue with `shift-right-click-repairs-mending-points` properly consume XP when a tool is at 1 durability and `shift-right-click-repairs-mending-points` is set to 1. Co-authored-by: William Blake Galbreath --- .../net/minecraft/server/level/ServerPlayerGameMode.java.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/purpur-server/minecraft-patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/purpur-server/minecraft-patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch index 13642640b..27489dad2 100644 --- a/purpur-server/minecraft-patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch +++ b/purpur-server/minecraft-patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -35,7 +35,7 @@ + if (this.player.level().purpurConfig.shiftRightClickRepairsMendingPoints > 0 && this.player.isShiftKeyDown() && this.player.getBukkitEntity().hasPermission("purpur.mending_shift_click")) { + int points = Math.min(this.player.totalExperience, this.player.level().purpurConfig.shiftRightClickRepairsMendingPoints); + if (points > 0 && itemstack.isDamaged() && net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.MENDING, itemstack) > 0) { -+ this.player.giveExperiencePoints(-points); ++ this.player.giveExperiencePoints(points == 1 ? -2 : -points); + this.player.level().addFreshEntity(new net.minecraft.world.entity.ExperienceOrb(this.player.level(), this.player.getX(), this.player.getY(), this.player.getZ(), points, org.bukkit.entity.ExperienceOrb.SpawnReason.UNKNOWN, this.player, this.player)); + return true; + }