Skip to content

Let a freshly crafted mage weapon take a charge before restart - #59

Merged
XxFran10xX merged 1 commit into
mainfrom
fix/station-cached-item-roundtrip
Oct 17, 2026
Merged

XxFran10xX merged 1 commit into
mainfrom
fix/station-cached-item-roundtrip

Conversation

@XxFran10xX

Copy link
Copy Markdown
Contributor

A mage weapon crafted at a gear station could not take a charge or be taken apart until the server restarted. Every charge said "This station is already mid-attunement", and shift-left-click refunded nothing. Each attempt logged [Magic] Gear property held: Occupancy authority or item changed. Reported on Main on 2026-10-17 (Vaultinfinite's craft at 3784,172,1693).

Cause: GearStationStore.expected() compares the cached weapon's bytes with the copy read back from gear-stations.yml. On a deposit, the cache held the item object that had just been built. Paper serializes a freshly built item's components in a different order than its re-read copy. On Main the stored and re-serialized bytes were the same length, with minecraft:tooltip_display and minecraft:custom_name swapped. So the check failed until a restart reloaded the cache from disk.

Fix: install() (deposit) and update() (end of an orb run) now cache the item decoded from the bytes they just wrote, as a restart does. install() no longer takes the item argument, since it reads it from the row.

Tests:

  • GearStationRereadBytesTest: re-read copies serialize differently in the fixture codec. It fails on main with the production error and passes here.
  • mvn clean verify on Linux: 644 tests, 0 failures, coverage gate met. (The gear file tests cannot run on Windows because of directory fsync.)
  • Dev (TFMCDev01) bot test with a real Mage character and a placed tfmc:magic_crafting_station:
    • On 0.6.2 the bug reproduced: paid craft, then "already mid-attunement" on charge, shift-left-click did nothing, held logged.
    • With this build, in the same server run as the craft: charge accepted and orbs ran; after the run ended a second charge was accepted; shift-left-click mid-run refunded the 2 sticks, 4 iron and 6 enchanted dust. No held lines.

🤖 Generated with Claude Code

The station cache held the weapon object that was just built, while expected()
compares it with the copy read back from gear-stations.yml. Paper writes a
freshly built item's components in another order than its re-read copy, so the
byte check failed: every charge said "already mid-attunement" and shift-left-click
refunded nothing until the next restart reloaded the cache from disk.

install() and update() now cache the re-read copy, as a restart does.

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

coderabbitai Bot commented Oct 17, 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: 73d69aa9-d895-446c-9eed-569d1e8efaaf
📥 Commits

Reviewing files that changed from the base of the PR and between 5734ae3 and fe25cf5.

📒 Files selected for processing: 5
  • src/main/java/net/tfminecraft/magic/gear/GearStationStore.java
  • src/main/java/net/tfminecraft/magic/gear/ownership/GearEffects.java
  • src/test/java/net/tfminecraft/magic/GearCoverageSupport.java
  • src/test/java/net/tfminecraft/magic/GearStationOwnershipBoundaryTest.java
  • src/test/java/net/tfminecraft/magic/GearStationRereadBytesTest.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 stations now reflect the item data saved when an item is deposited, keeping their display and availability in sync with the stored item.
    • Stations remain usable when an item’s data differs after it is saved and loaded again. Ownership handling for ownerless stations remains unchanged.

GearStationStore now decodes station items from persisted rows during installation and updates. Deposit passes the updated row to installation. Tests cover items whose re-read bytes differ and retain the existing ownership assertions.

Changes: Station Item Consistency

Layer / File(s) Summary
Decode station items from persisted rows
src/main/java/net/tfminecraft/magic/gear/GearStationStore.java
Installation decodes the item from the station row before creating the display and occupancy. Updates cache the item decoded from the updated row instead of cloning the supplied item.
Wire deposit and validate re-read behaviour
src/main/java/net/tfminecraft/magic/gear/ownership/GearEffects.java, src/test/java/net/tfminecraft/magic/GearStationRereadBytesTest.java, src/test/java/net/tfminecraft/magic/GearCoverageSupport.java, src/test/java/net/tfminecraft/magic/GearStationOwnershipBoundaryTest.java
Deposit passes the updated row to installation. The new test checks that an item with different re-read bytes remains accepted before and after an attunement update, and can be released and acknowledged for abort. Fixture snapshots are stored on the test-support instance. The ownership boundary test uses the updated installation signature.

Priority: ➖ Normal

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

Change: Bug fix

Suggested reviewers: ryanbarlow97

Merge Risk: ⚪ Minimal · up to fe25c

The changed paths address the fresh-item mismatch, and no actionable merge-blocking risk remains 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.

@XxFran10xX

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@github-actions github-actions Bot added the size:S 10-29 effective changed lines (tests excluded in mixed PRs). label Oct 17, 2026
@coderabbitai

coderabbitai Bot commented Oct 17, 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 c2c3e88 into main Oct 17, 2026
3 checks passed
@XxFran10xX
XxFran10xX deleted the fix/station-cached-item-roundtrip branch October 17, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 effective changed lines (tests excluded in mixed PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant