Skip to content

fix(tomes): stop the Extraction Tome destroying low-durability and stacked items - #322

Merged
rfizzle merged 1 commit into
masterfrom
fix/extraction-tome-item-loss
Nov 15, 2026
Merged

rfizzle merged 1 commit into
masterfrom
fix/extraction-tome-item-loss

Conversation

@rfizzle

@rfizzle rfizzle commented Nov 15, 2026

Copy link
Copy Markdown
Owner

The Extraction Tome promises to keep the source item, but a player reported losing one. A gametest that drives the real anvil take path showed the restore itself works (click, shift-click, Q-drop, rename-then-take, close-after-take). The loss comes from three other paths, fixed here:

  • Durability cost is now a percentage. The flat 50-point cost drove small-durability items to 1 durability, so a golden sword always came back at 1/32 and broke on its next use. The new tomes.extractionTomeItemDamagePercent (default 0.05, at least one point) scales with the item: diamond sword 78, iron sword 12, golden sword 1. The never-break clamp is unchanged. A v11 → v12 config migration drops the old extractionTomeItemDamage key; a flat value has no meaningful percentage equivalent, so the new key starts at its default.
  • Stacked left input is declined. Vanilla's take clears the whole left slot but only one stripped item is restored, so 4 enchanted items went in and 1 came back. The handler now shows no result for a stack.
  • Restore before awarding. AnvilMenuMixin#meridian$restoreLeft wrote the item back after firing the salvage advancement, so a throwing trigger would have stranded it.

Tests: new gametests take the result through AnvilMenu#clicked (click and shift-click) and cover the stacked decline and the golden-sword case; the existing gametests only inspected the preview slot. Unit tests cover the percentage math and the migration.

Docs: site/pages/config.json (setting row, examples, configVersion 12), site/pages/guide.json (salvage tome summary), and design/SPEC.md.

Closes #321

…acked items

The Extraction Tome promises to preserve the source item, but three paths
broke that promise:

- The flat 50-point durability cost drove small-durability items to 1
  durability (a golden sword always came back at 1/32), so they broke on
  their next use. The cost is now a share of max durability,
  tomes.extractionTomeItemDamagePercent (default 0.05, at least one
  point), with the existing never-break clamp kept. A v11 to v12 config
  migration drops the old flat key.
- A stacked left input was claimed, but vanilla's take clears the whole
  left slot while only one stripped item is restored. The handler now
  declines stacks.
- The take hook awarded the salvage advancement before restoring the
  item, so a throwing trigger would strand it. The restore now runs first.

Adds gametests that drive the real take path (click and shift-click),
the stacked-input decline, and the small-durability case, plus unit
tests for the percentage math and the migration. Updates the config,
guide, and SPEC docs.

Closes #321
@github-actions

Copy link
Copy Markdown
Contributor

Reviewed at c2084c1 · 2026-11-15 04:19 UTC

Code Review — c2084c1

Verdict: APPROVE — 0 must-fix, 1 optional

Category Score Notes
Spec alignment ✓ All 7 acceptance criteria covered. The stacked-decline check is tested by a gametest, not the unit test the spec named.
Conventions ✓ Mojang names used, files are in the right source sets, and the commit title follows Conventional Commits with a topical scope.
Correctness ✓ CI is green. damageFor and the clamp math are correct, and the migration is null-safe.
Thread safety ✓ No new shared state.
Mixin safety ✓ meridian$restoreLeft is reordered inside the same @At("RETURN") inject; it still clears pendingResult first and checks for null and empty.
Test coverage ⚠ No unit test for the stacked-left decline.
Site docs ✓ config.json (setting row, example, configVersion 12) and guide.json are updated, and match the code.
Performance ✓ One integer check and one float multiply per anvil preview.
Lifecycle edges ✓ The config version bump (v11 → v12) is covered by ConfigMigratorTest#migrate_v11_dropsFlatExtractionTomeItemDamage. The stacked-input path is covered by TomeAnvilGameTest#extractionTomeDeclinesStackedLeft.
Compat risk ✓ The config schema change is migrated: the old key is dropped and the new key loads at its default. The Cloth entry is updated to match.

Acceptance criteria

Criterion Status Where / what's missing
Replace the flat extractionTomeItemDamage with extractionTomeItemDamagePercent (default 0.05, clamped 0.0–1.0) ✅ covered MeridianConfig.java:358 sets the field; MeridianConfig.java:225 clamps it with clampUnit
Damage is max(1, floor(maxDamage * percent)) when percent > 0, and the never-break clamp stays ✅ covered ExtractionTomeHandler.java damageFor and stripAndDamage → clampDamage
Config migration drops the old flat key, and the new key starts at its default ✅ covered ConfigMigrator.java:80-89, with CURRENT_VERSION = 12
Decline a left input with count > 1 ✅ covered ExtractionTomeHandler.java:82-84
Restore the left item before awarding the advancement ✅ covered AnvilMenuMixin.java:133-142
Unit tests for the percentage math and the stacked-left decline 🟠 partial DamageClampMathTest and TomeHandlerLogicTest cover the percentage math. The stacked decline is covered only by the gametest (minor gap; the behaviour is still verified).
Gametests: take through AnvilMenu#clicked (click and shift-click), stacked decline, and a golden sword keeping more than 1 durability ✅ covered TomeAnvilGameTest: extractionTomeTakeRestoresStrippedItem, extractionTomeShiftClickTakeRestoresStrippedItem, extractionTomeDeclinesStackedLeft, extractionTomeKeepsSmallDurabilityItemUsable
Docs: describe the cost as a percentage on the site; rename the config entry and its tooltip ✅ covered site/pages/guide.json, site/pages/config.json, en_us.json:191-192, MeridianConfigScreen.java:158-163

🟡 Optional

  • src/test/java/com/rfizzle/meridian/anvil/TomeHandlerLogicTest.java: the spec asks for a unit test of the stacked-left decline. Only TomeAnvilGameTest#extractionTomeDeclinesStackedLeft exercises the left.getCount() > 1 branch.

@rfizzle
rfizzle merged commit 6d393f8 into master Nov 15, 2026
1 check passed
@rfizzle
rfizzle deleted the fix/extraction-tome-item-loss branch November 15, 2026 04:19
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.

fix(tomes): stop the Extraction Tome destroying low-durability and stacked items

1 participant