`Player#applyMending(amount)` does not apply mending to itemstacks whose material has no default `max_damage`
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 3.5k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 11
Description
Expected behavior
Both paths repair the item.
Observed/Actual behavior
CraftPlayer#applyMending gates the repair on the item prototype instead of the stack:
// CraftPlayer.java
if (!itemstack.isEmpty() && itemstack.getItem().components().has(DataComponents.MAX_DAMAGE)) {
itemstack.getItem().components() is the default component map of the Item, not of the stack. A stack
that became damageable through its own max_damage/damage components, for example a player_head
used as custom equipment, fails this check and is never repaired.
The check is also redundant: the stack was just selected by
EnchantmentHelper.getRandomItemWith(REPAIR_WITH_XP, handle, ItemStack::isDamaged), and isDamaged()
already requires has(MAX_DAMAGE) on the stack.
ExperienceOrb#repairPlayerItems does not have this check, so the two paths disagree.
Steps/models to reproduce
/give @s player_head[max_damage=100,damage=50,enchantments={mending:1},equippable={slot:"head"},minecraft:max_stack_size=1]
Wear it, then:
- Walk into an experience orb (
/summon minecraft:experience_orb ~ ~ ~ {Value:100}) → repaired. - Have a plugin call
player.giveExp(100, true)→ not repaired, the full amount goes to the XP bar.
The same test with diamond_helmet[damage=50,enchantments={mending:1}] is repaired on both paths,
because minecraft:diamond_helmet carries max_damage in its prototype.
Plugin and Datapack List
None / just a test plugin
Paper version
This server is running Paper version 26.2-124-ver/26.2@22ca6c7 (2026-09-15T17:48:49Z) (Implementing API version 26.2.build.124-stable)
You are running the latest version
Previous version: 26.2-60-1cb58fb (MC: 26.2)
Other
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in CraftPlayer.java at the CraftPlayer#applyMending(amount) check that reads the item prototype, and compare it with ExperienceOrb#repairPlayerItems. Reproduce the difference using the player_head command and both experience paths. Done means a damaged stack with its own max_damage and damage components is repaired through player.giveExp(100, true) as well as by an experience orb.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100