Skip to content

fix: add valid pickaxes to incorrect_for_wooden_tool material map (wrong dig times) - #1232

Open
AnonymoDGH wants to merge 1 commit into
PrismarineJS:masterfrom
AnonymoDGH:fix/incorrect-for-wooden-tool-dig-speed
Open

fix: add valid pickaxes to incorrect_for_wooden_tool material map (wrong dig times)#1232
AnonymoDGH wants to merge 1 commit into
PrismarineJS:masterfrom
AnonymoDGH:fix/incorrect-for-wooden-tool-dig-speed

Conversation

@AnonymoDGH

Copy link
Copy Markdown
Contributor

Problem

Reported in PrismarineJS/mineflayer#3921: on 1.21.11, block.digTime() returns wildly wrong values for blocks whose material is incorrect_for_wooden_tool (iron ore, copper ore, obsidian, ancient debris, raw metal blocks, etc.) when holding a valid pickaxe.

Reproduction with prismarine-block + minecraft-data 3.113.2 (1.21.1, iron_ore, hardness 3):

wooden_pickaxe:   canHarvest=undefined digTime=7500ms
stone_pickaxe:    canHarvest=true      digTime=4550ms   <- wrong
iron_pickaxe:     canHarvest=true      digTime=4550ms   <- wrong (vanilla: 750ms)
diamond_pickaxe:  canHarvest=true      digTime=4550ms   <- wrong
netherite_pickaxe: canHarvest=true     digTime=4550ms   <- wrong

Root cause

prismarine-block's digTime looks the held item up in registry.materials[block.material]. The incorrect_for_wooden_tool map only contains the four wooden tools (the incorrect ones), so every valid pickaxe misses the lookup and silently falls back to a block-breaking speed of 1 instead of its real speed (stone 4, iron 6, diamond 8, netherite 9).

Fix

For every version that has this material (1.20.5, 1.21.1, 1.21.3, 1.21.4, 1.21.5, 1.21.6, 1.21.8, 1.21.9, 1.21.11, 26.1), add the non-wooden pickaxes from mineable/pickaxe into incorrect_for_wooden_tool at their correct speeds. The existing wooden-tool entries are preserved untouched (including the 1.21.4 wooden=1.0 values introduced by #1033). On 1.21.9+ this also adds copper_pickaxe at speed 1, matching its mineable/pickaxe entry.

Example (1.21.11):

   "incorrect_for_wooden_tool": {
     "912": 2.0,
     "913": 2.0,
     "914": 2.0,
-    "915": 2.0
+    "915": 2.0,
+    "918": 1.0,
+    "923": 4.0,
+    "928": 12.0,
+    "933": 6.0,
+    "938": 8.0,
+    "943": 9.0
   },

Verification

Schema: all 10 changed files pass materials_schema.json validation (ajv).

End-to-end via prismarine-block digTime after this change (1.21.1 and 1.21.11, iron_ore):

wooden_pickaxe:   canHarvest=undefined digTime=7500ms   (unchanged, no drops)
stone_pickaxe:    canHarvest=true      digTime=1150ms
golden_pickaxe:   canHarvest=undefined digTime=1250ms   (fast but no drops, as in vanilla)
iron_pickaxe:     canHarvest=true      digTime=750ms    <- matches vanilla
diamond_pickaxe:  canHarvest=true      digTime=600ms
netherite_pickaxe: canHarvest=true     digTime=500ms

canHarvest (drop gating via harvestTools) is unaffected; this only corrects the mining speed lookup.

Fixes PrismarineJS/mineflayer#3921 (data side).

The incorrect_for_wooden_tool material map only listed the wooden tools (the incorrect ones), so valid pickaxes (stone/iron/diamond/netherite, plus copper on 1.21.9+) fell back to a mining speed of 1 in prismarine-block digTime. This made iron_ore take ~4550ms with an iron pickaxe instead of the correct ~750ms (mineflayer issue PrismarineJS/mineflayer#3921).

Add the non-wooden pickaxes from mineable/pickaxe into incorrect_for_wooden_tool at their correct speeds, preserving the existing wooden-tool entries (including the 1.21.4 wooden=1.0 values from PrismarineJS#1033). Verified end-to-end via prismarine-block digTime on 1.21.1 and 1.21.11.
@AnonymoDGH

Copy link
Copy Markdown
Contributor Author

Note on CI: the Node 22 build job fails in the bedrock-protocol test step with Cannot find package '@napi-rs/snappy-wasm32-wasi' — a dependency-resolution error at module load, before any data file is read. This is unrelated to this data-only change and is pre-existing: the same failure appears on #1231 and #1230 (and the Node 22 job has been red across recent PRs).

The build (24) job, which runs the full data test suite including materials_schema.json validation, passes here. All 10 changed materials.json files also validate against the schema locally (ajv).

@extremeheat

Copy link
Copy Markdown
Member

Note - optimal thing in future is to remove the legacy material.json handling and replace it with tag system that modern versions use

#463 , #1194

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.

wrong dig time when block material doesn't have tool IDs mapped in registry

2 participants