Skip to content

Keep ArmourShop skins when a mage weapon is rebuilt - #55

Merged
ryanbarlow97 merged 2 commits into
mainfrom
fix/gear-refresh-keeps-skin
Oct 12, 2026
Merged

ryanbarlow97 merged 2 commits into
mainfrom
fix/gear-refresh-keeps-skin

Conversation

@ryanbarlow97

@ryanbarlow97 ryanbarlow97 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

AlokVocayne reported on Main that a skinned staff lost its skin after switching hotbar slots away and back, which cost them two skin scrolls. Their saved staff still carries the Heir Staff amodel 66 tag, but its model is back to 2, the steel scheme's staff. Something rebuilt the weapon after the skin went on.

Two paths rebuild a mage weapon: GearRefresher (hotbar switch, click, join, chest open, /magic refresh, station reclaim) and GearItemBuilder.rewriteSockets (charging). Both build from the MMOItems template and then apply the part model scheme, so neither kept a skin. The likely trigger is socketing a rune. MMOItems cancels that click, so Magic's click refresh skips it and the rune stays unstamped until the next hotbar switch, which then rebuilds the staff.

GearSkin.keep now runs after the scheme model on both paths and puts the old weapon's look back through TLibs' ItemSkinPreserver, the same helper AdvancedCrafting uses. A weapon only counts as skinned when its amodel tag matches its current model, or when it has an ItemsAdder skin without one. Alok's staff, whose tag outlived its skin, keeps the part model and does not get a free Heir Staff skin back.

The POM pins local:item-nbt-api-plugin as provided, matching AdvancedCrafting, because ItemSkinPreserver needs NBTAPI types for Mockito to load it in tests. The ServerAssets catalogue already lists it.

Main runs Magic 0.4.17 and this branch builds on the unreleased character-identity work (TLibs 2.3.0), so the fix ships with that set unless a 0.4.x hotfix is wanted.

Docs: TF-Minecraft/Docs#191.

mvn clean verify passes locally: 503 tests, 100% line, branch and instruction coverage.

🤖 Generated with Claude Code

A refresh or socket rewrite rebuilt the weapon from its MMOItems template
and the part model scheme, which dropped any skin the player had applied
and wasted the skin scroll. Players hit this after socketing a rune: the
next hotbar switch refreshed the staff and reset its model.

GearSkin puts the old weapon's skin back through TLibs' ItemSkinPreserver.
A weapon whose amodel tag no longer matches its model already lost its skin,
so it keeps the part model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the size:M 30-99 effective changed lines (tests excluded in mixed PRs). label Oct 12, 2026
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 725880e9-73b1-43be-81a6-c78950c11d1b

📥 Commits

Reviewing files that changed from the base of the PR and between 206b410 and b32774b.


📒 Files selected for processing (10)
  • .github/dependencies.sha256
  • .github/scripts/install-local-dependencies.sh
  • .github/scripts/prepare-release.sh
  • pom.xml
  • src/main/java/net/tfminecraft/magic/gear/GearItemBuilder.java
  • src/main/java/net/tfminecraft/magic/gear/GearRefresher.java
  • src/main/java/net/tfminecraft/magic/gear/GearSkin.java
  • src/test/java/net/tfminecraft/magic/GearItemCoverageTest.java
  • src/test/java/net/tfminecraft/magic/GearRefresherCoverageTest.java
  • src/test/java/net/tfminecraft/magic/GearSkinTest.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.



📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Gear items now retain their existing skins when sockets are rewritten or gear is rebuilt, where the skin remains compatible with the item’s model.
  • Chores
    • Updated local dependency setup to include the required item data support.

Walkthrough

The change adds a utility that preserves qualifying skin data when gear items are rebuilt. It uses this utility in socket rewriting and gear refresh. The build scripts and Maven configuration add the NBT API dependency.

Changes

Gear skin preservation

Layer / File(s) Summary
Skin eligibility and preservation
.github/dependencies.sha256, .github/scripts/prepare-release.sh, .github/scripts/install-local-dependencies.sh, pom.xml, src/main/java/net/tfminecraft/magic/gear/GearSkin.java, src/test/java/net/tfminecraft/magic/GearSkinTest.java
The build setup downloads, checks and installs the NBT API dependency. GearSkin.keep applies the old item’s skin when its skin data qualifies; tests cover its eligibility checks and return values.
Rebuild path integration
src/main/java/net/tfminecraft/magic/gear/GearItemBuilder.java, src/main/java/net/tfminecraft/magic/gear/GearRefresher.java, src/test/java/net/tfminecraft/magic/GearItemCoverageTest.java, src/test/java/net/tfminecraft/magic/GearRefresherCoverageTest.java
Socket rewriting and gear refresh pass the rebuilt item and original item to GearSkin.keep. Tests verify these calls.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Suggested reviewers: xxfran10xx


Merge Risk: ⚪ Minimal · up to b3277

The skin-preservation paths match the intended behavior; no identified issue prevents merging after normal checks.

  • 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

Comment @coderabbitai help to get the list of available commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ryanbarlow97
ryanbarlow97 merged commit ee73987 into main Oct 12, 2026
3 checks passed
@ryanbarlow97
ryanbarlow97 deleted the fix/gear-refresh-keeps-skin branch October 12, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 effective changed lines (tests excluded in mixed PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant