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 <Blake.Galbreath@GMail.com>
This commit is contained in:
granny
2025-05-03 20:12:19 -07:00
parent 6f5bbae51b
commit 5c1a983514

View File

@@ -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;
+ }