Skip to content

fix: make durability reduce returns, default rates to 0.5 - #27

Merged
XxFran10xX merged 1 commit into
mainfrom
fix/durability-and-half-rates
Sep 30, 2026
Merged

XxFran10xX merged 1 commit into
mainfrom
fix/durability-and-half-rates

Conversation

@XxFran10xX

@XxFran10xX XxFran10xX commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Durability never reduced returns. DurabilityScaler had two bugs, so worn gear always recycled as if new:

  • Custom durability read MMOITEMS_CUSTOM_DURABILITY, which MMOItems 6.10 never writes. The live counter is MMOITEMS_DURABILITY (against MMOITEMS_MAX_DURABILITY; absent means never damaged). This is what AdvancedCrafting gear and Magic weapon parts use.
  • Vanilla durability used the material's default maximum and ignored the item's max_damage component (MMOItems max-item-damage).

Both are fixed. The old unit test asserted the wrong tag and is updated.

Rates. All return_rates defaults are now 0.5; recipes stays 1.0. The recipes entry now explains that it multiplies the fixed outputs written in recipes/*.yml.

Testing

  • mvn verify passes with the 100% coverage gate.
  • TFMCDev01, mage staff recording 10 steel (Dev config at 0.8): full durability → 8, 250/500 vanilla damage → 4, 25/100 MMOItems custom durability → 2. Before the fix all three gave 8.
  • Found while testing: mage staffs on a STICK base (e.g. MAGE_IRON_STAFF with max-item-damage) are stackable, so Paper refuses to damage them; they never wear and keep a full return.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Changes
    • Reduced the default return rate for advanced crafting, magic gear, guns, and goldsmith items from 80% to 50%. Recipe and scrap return rates are unchanged.
    • Improved durability-based return calculations for MMOItems and items with custom maximum durability, including safer fallback behavior when durability information is missing or invalid.

DurabilityScaler read MMOITEMS_CUSTOM_DURABILITY, which MMOItems 6.10
never writes, and ignored the max_damage component, so worn gear always
returned as if new. It now reads MMOITEMS_DURABILITY against
MMOITEMS_MAX_DURABILITY (full when not yet damaged), and otherwise vanilla
damage against max_damage or the material default.

All item-type return rates default to 0.5 (recipes stay 1.0), and the
recipes entry now explains what it scales.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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: f8a629a3-ef4d-4d18-9cf2-da18d634bbea

📥 Commits

Reviewing files that changed from the base of the PR and between da737ea and 48bdebd.

📒 Files selected for processing (6)
  • src/main/java/net/tfminecraft/recycler/Cache.java
  • src/main/java/net/tfminecraft/recycler/loader/ConfigLoader.java
  • src/main/java/net/tfminecraft/recycler/util/DurabilityScaler.java
  • src/main/resources/config.yml
  • src/test/java/net/tfminecraft/recycler/LoadersTest.java
  • src/test/java/net/tfminecraft/recycler/UtilitiesTest.java

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


📝 Walkthrough

Walkthrough

Default return rates for several crafted-item categories change from 0.8 to 0.5. Durability scaling now uses MMOItems maximum and remaining durability tags, and uses item-specific maximum damage when available.

Changes

Crafted-Item Return Rates

Layer / File(s) Summary
Update crafted-item return defaults
src/main/java/net/tfminecraft/recycler/Cache.java, src/main/java/net/tfminecraft/recycler/loader/ConfigLoader.java, src/main/resources/config.yml, src/test/java/net/tfminecraft/recycler/LoadersTest.java
The default return rate for advanced crafting, magic gear, guns, and goldsmith items changes from 0.8 to 0.5. The configuration comments and loader tests reflect the new defaults. Scrap remains at 0.5. Recipe outputs are documented as multiplied by the configured rate.

Durability Scaling

Layer / File(s) Summary
Calculate durability factors
src/main/java/net/tfminecraft/recycler/util/DurabilityScaler.java, src/test/java/net/tfminecraft/recycler/UtilitiesTest.java
MMOItems scaling uses maximum and remaining durability tags, defaults missing remaining durability to the maximum, and clamps the ratio to [0.0, 1.0]. Missing or nonpositive maximum durability falls back to vanilla scaling. Vanilla scaling uses item-specific maximum damage when available.

Priority: ➖ Normal

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

Change: Bug fix

Suggested reviewers: ryanbarlow97

Merge Risk: ⚪ Minimal · up to 48bde

The PR’s return-rate changes are consistent, and recipe outputs follow the documented multiplier. The MMOItems tag conversion could not be confirmed, but no concrete merge-blocking failure is established.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 48bde

The inspected changes do not demonstrate a new permission bypass or broader access. They primarily reduce recycling returns while preserving configured overrides. Compatibility with the deployed durability reader remains unverified, so the intended output behavior is not fully established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated exposure is recycling output value for submitted items. The inspected changes affect item metadata interpretation and category rates without establishing a new authority transition or broader service access.

Trust Boundaries and Controls

  • observed — Submitted item metadata influences the durability factor, but output identities and base amounts still come from the selected provider. Finite durability factors are clamped to zero through one. Preview and confirmation both use the existing provider-chain resolver.

Resilience and Maintainability Implications

  • inferred — A reload between preview and confirmation can change the calculated yield because confirmation resolves again against live configuration. This is an existing consistency characteristic, not a substantiated PR-introduced security concern; actual concurrent execution remains unverified.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 5 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes both main changes: durability-based return reduction and default return rates of 0.5.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 5 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


A rabbit checks the rates at dawn,
Half the crafted share goes on.
Durability tags now guide the way,
Item max damage joins the play.
The tests hop through each case in line,
Then nibble clover, pleased and fine.

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

@XxFran10xX
XxFran10xX merged commit fb26e34 into main Sep 30, 2026
2 checks passed
@XxFran10xX
XxFran10xX deleted the fix/durability-and-half-rates branch September 30, 2026 15:16
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