Skip to content

Forging Station checks an alloy's base Smith perk - #55

Open
XxFran10xX wants to merge 1 commit into
mainfrom
alloy-forge-perk
Open

XxFran10xX wants to merge 1 commit into
mainfrom
alloy-forge-perk

Conversation

@XxFran10xX

@XxFran10xX XxFran10xX commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Status record

  • Reviewed: Fable 5.2 APPROVE at 4add29f (no findings)
  • Second opinion: CodeRabbit APPROVED at 4add29f (no comments)
  • Dev-tested: pending
  • Local tests: passed at 4add29f (mvn -o verify: 192 tests, coverage gate met; the 4 StationDatabaseCoverageTest/EdgeCoverageTest failures are Windows-only and fail the same way on unmodified origin/main)

What changed

  • CraftingStation.addMaterial now checks an alloy's Smith perk before accepting it. Until now ingredients were checked (canUseIngredient, the permission: in ingredients.yml) but alloys skipped the check, so a player without e.g. Mythril Smith could forge gear from a Mythril-based alloy.
  • An alloy needs the same permission as its base: the ingredient recorded as recipe.base in the alloy's JSON (the metal or wood it was forged on). Wood bases use their own permission:, which on Main is the matching Smith perk (barkwood iron, maplewood steel, elderwood abyssalite, demonwood mythril).
  • A refused alloy gets the same message ingredients use ("You are not skilled enough in ... to work this material.") and is not taken from the hand.
  • If the base can't be found (no recipe in the alloy file, or the base ingredient is no longer configured), or the base has no permission, the alloy keeps working as today.
  • New helpers ProfessionPermissions.alloyPermission / canUseAlloy.

Other places that accept alloys (checked, unchanged)

  • Alloy Forge: only takes ingredients, never alloys, and already checks every input.
  • Stat Preview (ingredient station, IngredientManager.convertItem) and the converter: only show stats or turn raw items into ingredient items; nothing is forged there.
  • Staff tryCompleteAdminCraft: staff only.
  • Other plugins (Recycler, Thievery, ActivityTF, TFMCCore) read AdvancedCrafting items but none forge with alloys.

Saved data

None written or changed. Reads the existing recipe.base from alloy JSON files. On Main all 192 alloy files record a base (138 steel, 18 iron, 18 abyssalite, 16 maplewood, 1 barkwood, 1 elderwood; no mythril-based alloy exists yet).

How to test on Dev

  1. On a test character without professions.steel_smith (check with /lp user <name> permission check professions.steel_smith), take a steel-based alloy (any alloy whose data/alloys/<id>.json has "base": "steel_ingot").
  2. Start a metal recipe at a Forging Station and right-click with the alloy: expect the refusal message naming the steel perk, a villager "no" sound, and the alloy still in hand.
  3. Grant professions.steel_smith and right-click again: the alloy is added ("Added ..." title).
  4. Right-click with an iron ingredient without professions.iron_smith: same refusal as before (unchanged).

🤖 Generated with Claude Code

An alloy put into a Forging Station now needs the same permission as its
base ingredient (the metal or wood it was forged on), with the same
refusal message ingredients use. Alloys with no recorded base, or whose
base is no longer configured, keep working as before.

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

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Alloy materials now require the permission associated with their base ingredient. If permission is missing, the station displays a message and does not add the alloy or consume materials.
    • Alloys without a known base ingredient continue to be accepted.

Alloy admission now checks the permission of its recorded base ingredient. CraftingStation rejects alloys when the player lacks that permission. Tests cover permission resolution and alloy admission.

Changes: Alloy permission checks

Layer / File(s) Summary
Resolve alloy base permissions
src/main/java/net/tfminecraft/advancedcrafting/utils/ProfessionPermissions.java, src/test/java/net/tfminecraft/advancedcrafting/MathCoverageTest.java
ProfessionPermissions resolves the base ingredient permission for an alloy and checks player access. Tests cover unavailable recipe data, permission resolution, and access checks.
Enforce permissions at the crafting station
src/main/java/net/tfminecraft/advancedcrafting/objects/crafting/CraftingStation.java, src/test/java/net/tfminecraft/advancedcrafting/StationCoverageTest.java
CraftingStation.addMaterial returns NO_PERMS when the player lacks the alloy’s base ingredient permission. Tests cover rejection, acceptance when permission is granted, and alloys without a recorded base.

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

Change: Bug fix

Suggested reviewers: ryanbarlow97

Merge Risk: Minimal · up to 4add2

Alloys inserted into a Forging Station now require the permission of their base ingredient. A denied alloy gets the same refusal message as a denied ingredient and stays in the player's hand. Alloys with no recorded or configured base work as before. No actionable merge risk was found.

- [ ] 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: b3cb3d2e-5c85-4cfe-bfab-429c4e868004
Commits

Reviewing files that changed from the base of the PR and between a145cf0 and 4add29f.

Files selected for processing: 4

  • src/main/java/net/tfminecraft/advancedcrafting/objects/crafting/CraftingStation.java
  • src/main/java/net/tfminecraft/advancedcrafting/utils/ProfessionPermissions.java
  • src/test/java/net/tfminecraft/advancedcrafting/MathCoverageTest.java
  • src/test/java/net/tfminecraft/advancedcrafting/StationCoverageTest.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.

@github-actions github-actions Bot added the size:M 30-99 effective changed lines (tests excluded in mixed PRs). label Nov 21, 2026
@XxFran10xX

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 21, 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.

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