Skip to content

Keep alloys working after ac reload - #40

Merged
XxFran10xX merged 1 commit into
mainfrom
fix/alloy-reload
Oct 10, 2026
Merged

XxFran10xX merged 1 commit into
mainfrom
fix/alloy-reload

Conversation

@XxFran10xX

Copy link
Copy Markdown
Contributor

Problem

After ac reload every alloy stops working until the server restarts (seen on TFMCDev01 after someone ran ac reload):

  • /ac give equipment medium_helmet alloy.darksteel fails with "You only have 0 out of 4 Metal items".
  • Putting Darksteel into a forging station throws an NPE in CraftingStation.addMaterial, and nothing is crafted.

ac reload builds new IngredientType, HitType, CraftingHit and scheme objects, but the loaded alloys (and any open station) keep the old ones. Stations count materials in maps keyed by those objects, which compared by identity. So an old alloy type never matched the station's new "metal" type. Ingredients were fine because they are rebuilt on reload. Main would hit the same bug if anyone ran ac reload there.

Change

  • IngredientType, HitType and CraftingHit compare by id (equals/hashCode). Old and new objects for the same id now match everywhere: station type and hit counts, restored stations, Cache.combinations.
  • ac reload now also points every loaded alloy at the reloaded type, hits, colour scheme and model scheme (AlloyManager.relinkAlloys → AlloyData.relink). An id that is no longer in the config keeps its old object, as before.

Revision hashes use ids only, so nothing gets re-revisioned.

Testing

  • New AlloyReloadTest: an alloy loaded before a reload fills a station by hand and through the give command's restore path; relink swaps in the reloaded objects and keeps missing ones; id equality. Without the fix, the station case throws the same NPE as on Dev.
  • mvn verify locally without EdgeCoverageTest/StationDatabaseCoverageTest (they always fail on Windows, also on main): all 141 other tests pass, and the changed classes are fully covered.
  • TFMCDev01: see the comment below.

🤖 Generated with Claude Code

`ac reload` rebuilt ingredient types, hits and schemes as new objects,
but loaded alloys and open stations kept the old ones, and stations
looked them up by object. Every alloy then stopped counting as its type
until a restart: `ac give equipment ... alloy.<id>` said "0 out of 4
Metal items" and adding an alloy to a station threw.

Ingredient types, hit types and hits now compare by id, and a reload
points the loaded alloys at the reloaded objects.

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

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 10, 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: 7e237d47-a98e-42f4-9f4c-3fa5d6c2a6cf

📥 Commits

Reviewing files that changed from the base of the PR and between f512a24 and f0719a3.


📒 Files selected for processing (7)
  • src/main/java/net/tfminecraft/advancedcrafting/AdvancedCrafting.java
  • src/main/java/net/tfminecraft/advancedcrafting/managers/AlloyManager.java
  • src/main/java/net/tfminecraft/advancedcrafting/objects/crafting/hits/CraftingHit.java
  • src/main/java/net/tfminecraft/advancedcrafting/objects/crafting/hits/HitType.java
  • src/main/java/net/tfminecraft/advancedcrafting/objects/data/AlloyData.java
  • src/main/java/net/tfminecraft/advancedcrafting/objects/ingredients/IngredientType.java
  • src/test/java/net/tfminecraft/advancedcrafting/AlloyReloadTest.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

    • Alloy recipes now refresh their ingredient types, colour and model schemes, and crafting hits after configuration reloads. References are retained when no replacement is available.
    • Objects with matching IDs are now recognised as equal, supporting consistent lookups after reloads.
  • Tests

    • Added coverage for alloy reloads, refreshed and missing references, and ID-based equality.

Walkthrough

Configuration reloads now relink registered alloy data to refreshed configuration objects. Ingredient types, hit types and crafting hits use ID-based equality and hashing. Tests cover relinking, station material filling and equality behaviour.

Changes

Alloy reload relinking

Layer / File(s) Summary
ID-based equality and hashing
src/main/java/net/tfminecraft/advancedcrafting/objects/ingredients/IngredientType.java, src/main/java/net/tfminecraft/advancedcrafting/objects/crafting/hits/HitType.java, src/main/java/net/tfminecraft/advancedcrafting/objects/crafting/hits/CraftingHit.java, src/test/java/net/tfminecraft/advancedcrafting/AlloyReloadTest.java
Ingredient types, hit types and crafting hits compare equal when their IDs match and derive their hash codes from those IDs. Tests cover matching IDs, differing IDs and objects of other types.
Relink alloy data after configuration reload
src/main/java/net/tfminecraft/advancedcrafting/AdvancedCrafting.java, src/main/java/net/tfminecraft/advancedcrafting/managers/AlloyManager.java, src/main/java/net/tfminecraft/advancedcrafting/objects/data/AlloyData.java, src/test/java/net/tfminecraft/advancedcrafting/AlloyReloadTest.java
reload() relinks registered alloy data after loading configurations and before flushing the revision tracker. Relinking refreshes type, scheme and hit references by ID. Existing values remain when no replacement is found, and null values remain null. Tests cover relinking and station material filling.

Priority: ➖ Normal

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant AdvancedCrafting
  participant AlloyManager
  participant AlloyData
  participant Loaders
  AdvancedCrafting->>AdvancedCrafting: loadConfigs()
  AdvancedCrafting->>AlloyManager: relinkAlloys()
  AlloyManager->>AlloyData: relink() for each registered alloy
  AlloyData->>Loaders: Look up type, schemes and hits by ID
Loading

Suggested reviewers: ryanbarlow97


Merge Risk: ⚪ Minimal · up to f0719

No merge-blocking issue was established; proceed with 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.

@coderabbitai

coderabbitai Bot commented Oct 10, 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

Copy link
Copy Markdown
Contributor Author

TFMCDev01 (PR jar f0719a3, bot test ~/ac-reload-test/test.js): after /ac reload, ac give equipment medium_helmet alloy.darksteel <bot> gave the helmet (tagged iron), and 4 Darksteel + 4 feathers at a forging station made a light helmet tagged iron. No AdvancedCrafting errors in the log since the reload. On 2.3.0 the same steps gave "You only have 0 out of 4 Metal items" (~/as-hat-test/run4.log).

@XxFran10xX
XxFran10xX merged commit 70f0ce4 into main Oct 10, 2026
2 checks passed
@XxFran10xX
XxFran10xX deleted the fix/alloy-reload branch October 10, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant