Skip to content

fix: rescale vanilla damage when a skin changes a crafted piece's material - #51

Merged
XxFran10xX merged 1 commit into
mainfrom
fix/skin-durability-rescale
Nov 6, 2026
Merged

XxFran10xX merged 1 commit into
mainfrom
fix/skin-durability-rescale

Conversation

@XxFran10xX

Copy link
Copy Markdown
Contributor

Problem

A crafted helmet that had a hat look (carved pumpkin, head or skull) and was then given a leather armour skin showed Durability: 0 / 55 in the vanilla tooltip and could not be worn, although its MMOItems durability was fine (816 / 1003 on Main, reported by a player on 2026-11-06).

Hat looks get their own vanilla bar sized to the MMOItems durability (CosmeticHelmetFix), so the helmet had damage 187 of max_damage 1003. The skin changed the material to leather_helmet and only re-profiled the bar when the new material was also a hat. The 187 damage stayed; once the 1003 bar was gone (the player's saved item had none), it counted against leather's 55 and read as broken.

Change

  • CosmeticHelmetFix.afterAppearanceChange: when the new material is not a hat, drop the bar a hat look added (max_damage equal to the MMOItems max, coming from a hat material) and map the MMOItems durability onto the new material's bar the way MMOItems does (SkinnedArmorDurability.vanillaDamage, one-point tolerance). Items without MMOITEMS_MAX_DURABILITY (mage weapons wear the vanilla bar itself) are not touched.
  • FalseBreakRepair (item scan handler, subscribed in TLibs.onEnable): a piece whose vanilla bar is at or past its end while MMOItems durability is left gets its bar put back in line. This fixes pieces already broken this way (e.g. the reported helmet) without a reskin. It only matches that state, so other items are skipped until they change.

MMOItems durability, skins, names and tags are not changed.

Testing

  • mvn verify: 264 tests, 0 failures, line coverage gate clean. New tests in CosmeticHelmetTest cover the hat-to-leather rescale (816/1003 gives 10 damage of 55), reskinning an already broken piece, bars a hat did not add, items without MMOItems durability, undamageable materials, the false-break check and repair (including one point past the end), and the scan handler for inventories and pickups.
  • Dev (TFMCDev01, bot TestChar1 as Spellblade): crafted Medium Steel helmet at 814/1000, Kettle Helm hat, then the first Player Armor skin through the /armourshop GUI.
    • TLibs 2.7.0: the leather skin keeps 186 damage; the player's exact saved state (damage 185, no max_damage) stays at 0/55.
    • This branch: the leather skin gives 45/55 with no leftover max_damage; the saved-state item is repaired to 45/55 by the scan within half a second. MMOItems durability stays 814.

🤖 Generated with Claude Code

…erial

A crafted helmet moved from a hat look (vanilla bar sized to its MMOItems
durability, e.g. 187 of 1003) to a leather armour skin kept the 187 damage
against leather's bar of 55, so it read 0/55 and could not be worn.

- afterAppearanceChange now drops the bar a hat look added and maps the
  MMOItems durability onto the new material's bar, as MMOItems does
- FalseBreakRepair (item scan) fixes pieces that already read broken
  while MMOItems durability is left

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved durability display when cosmetic helmets change appearance, keeping the vanilla damage bar aligned with the item’s remaining durability.
    • Fixed items that appeared broken despite having custom durability remaining; eligible items are now repaired during scans.

The change rescales vanilla damage after cosmetic appearance changes and adds scan-based detection and repair for false-broken items. Startup registers the repair handler with ItemScanService. Tests cover rescaling, detection, repair and inventory updates.

Changes: Cosmetic helmet durability

Layer / File(s) Summary
Rescale vanilla damage
src/main/java/net/tfminecraft/tlibs/armour/CosmeticHelmetFix.java, src/test/java/net/tfminecraft/tlibs/armour/CosmeticHelmetTest.java
Appearance changes can rescale vanilla damage and remove a matching max-damage override for cosmetic helmet materials. Tests cover rescaling and cases where items remain unchanged.
Detect and repair false breaks
src/main/java/net/tfminecraft/tlibs/armour/CosmeticHelmetFix.java, src/test/java/net/tfminecraft/tlibs/armour/CosmeticHelmetTest.java
False-break detection checks for remaining custom durability when vanilla damage reaches its maximum. Repair aligns the damage and restores missing tags. Tests cover detection and repair boundaries.
Register false-break scanning
src/main/java/net/tfminecraft/tlibs/armour/FalseBreakRepair.java, src/main/java/net/tfminecraft/tlibs/TLibs.java, src/test/java/net/tfminecraft/tlibs/armour/CosmeticHelmetTest.java
The scan handler delegates matching and repair to CosmeticHelmetFix, updates an inventory slot after a successful repair, and is registered at startup. Tests cover inventory and pickup updates.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

  • TF-Minecraft/TLibs#50: Changes the scan contract used by the FalseBreakRepair handler, including when the handler checks items.

Suggested reviewers: drefvelin

Merge Risk: Minimal · up to 13857

The repair handler will inspect saved items on a subsequent scan. No merge-blocking issue was established; normal checks remain appropriate.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 88d2ca5f-09ea-4e73-8f50-922b0e0932af
Commits

Reviewing files that changed from the base of the PR and between f6627d5 and 1385752.

Files selected for processing: 4

  • src/main/java/net/tfminecraft/tlibs/TLibs.java
  • src/main/java/net/tfminecraft/tlibs/armour/CosmeticHelmetFix.java
  • src/main/java/net/tfminecraft/tlibs/armour/FalseBreakRepair.java
  • src/test/java/net/tfminecraft/tlibs/armour/CosmeticHelmetTest.java

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@XxFran10xX

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@github-actions github-actions Bot added the size:L 100-499 effective changed lines (tests excluded in mixed PRs). label Nov 6, 2026
@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@XxFran10xX
XxFran10xX merged commit 64ff730 into main Nov 6, 2026
5 checks passed
@XxFran10xX
XxFran10xX deleted the fix/skin-durability-rescale branch November 6, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 effective changed lines (tests excluded in mixed PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant