Repository navigation
Description
A player reported losing an item to the Extraction Tome. The tome promises "Does not destroy the item", but three paths break that promise.
Reproduction
- Small-durability items. Put an enchanted golden sword (or fishing rod, flint and steel, or any worn tool with 50 or less durability left) in an anvil with an Extraction Tome and take the book.
- Stacked left input. Put a stack of 4 enchanted items (e.g. sticks enchanted by command) in the left slot with an Extraction Tome and take the book.
Expected
The source item comes back unenchanted and still usable, and nothing in the left slot disappears.
Actual
- The tome applies a flat
tomes.extractionTomeItemDamage(default 50), clamped so the item keeps 1 durability. A golden sword (max 32) always comes back at 1/32; a fishing rod or flint and steel comes back at 14/64; a worn tool comes back at 1. Each breaks on its next use, which reads as the tome eating the item. - The handler keeps a single-count copy (
copyWithCount(1)) as the left replacement, but vanilla'sonTakeclears the whole left slot. 4 sticks go in, 1 comes back.
Also: AnvilMenuMixin#meridian$restoreLeft awards the salvage advancement before writing the preserved item back, so an exception from the trigger would skip the restore and lose the item.
Verified with a gametest that drives the real take path (AnvilMenu#clicked): click, shift-click, Q-drop, rename-then-take, and close-after-take all restore the item correctly. The loss is limited to the cases above. No existing test exercises the take path; the current gametests only inspect the preview slot.
Minecraft version
1.21.1
Mod version
v1.1.0 (current master)
Fix
- Durability cost becomes a percentage of max durability. Replace
tomes.extractionTomeItemDamage(flat points) withtomes.extractionTomeItemDamagePercent(default0.05, clamped to 0.0–1.0), applied asmax(1, floor(maxDamage * percent))when the percent is above zero. The existing clamp that always leaves at least 1 durability stays. At 5%: diamond sword 78, iron sword 12, golden sword 1, elytra 21. This matches the repair path, which is already percentage-based (extractionTomeRepairPercent). The old flat key is dropped by a config schema migration; a flat value has no meaningful percentage equivalent, so the new key starts at its default. - Decline a stacked left input.
ExtractionTomeHandlerreturns no claim when the left stack's count is above 1, so the anvil simply shows no result instead of silently consuming the rest of the stack. - Restore before awarding. In
meridian$restoreLeft, write the left replacement back before firing the usage advancement. - Tests. Unit tests for the percentage math and the stacked-left decline; a gametest that takes the result through
AnvilMenu#clickedand asserts the item is restored (click and shift-click), the stacked input declines, and a golden sword keeps more than 1 durability.
Docs impact
site/tomes page: describe the Extraction Tome's durability cost as a percentage of max durability.- Config docs / lang: rename the config entry and its tooltip.
Activity