-
Bug
-
Resolution: Fixed
-
1.19.4, 1.20 Release Candidate 1, 1.20.1, 1.20.2 Pre-release 2
-
None
-
Confirmed
-
Enchantments
-
Normal
-
Platform
The bug
(All code references are using Mojang's mappings)
Each experience point should repair 2 durability according to ExperienceOrb#xpToDurability, but the recursive ExperienceOrb#repairPlayerItems doesn't use the correct value to calculate the xp amount left over for more repairs. It still uses the overall value of the orb for each call of repairPlayerItems instead of the amount parameter, which is the correct value after the first recursive call.
For this issue to occur, its required that 1 item have less durability that the xp value * 2 so the function has a chance to engage in recursion.
The fix should be as simple as using the amount parameter instead of this.value.
To reproduce
You can see the incorrect results by doing the following:
- Give yourself 2 pieces of armor both with 20 damage with
/give @s <some_armor>{Damage:20}
and equip them.
- Apply the mending enchant to both of them with
/enchant @s mending
- Spawn an experience orb with a value of 11 with
/summon experience_orb ~5 ~ ~5 {Value:11}
- Collect the xp orb.
Observed result
Both armor pieces were fully repaired, repairing 40 damage.
Expected result
Only 22 damage should've been repaired.
EDIT #1: This has probably been a bug since 21w13a which included the fixes for MC-194183 and MC-205918 which I assume caused this, looking at the diff between ExperienceOrb.java for that version and 1.20-rc1.