Skip to content

loader: pass tags through to mcData#457

Open
VasilisDragon wants to merge 1 commit into
PrismarineJS:masterfrom
VasilisDragon:vasilis-expose-tags
Open

loader: pass tags through to mcData#457
VasilisDragon wants to merge 1 commit into
PrismarineJS:masterfrom
VasilisDragon:vasilis-expose-tags

Conversation

@VasilisDragon

Copy link
Copy Markdown

Summary

Implements the loader half discussed in PrismarineJS/minecraft-data#412 and resolves #315 (block tags feature request, 2023): lib/loader.js returns a fixed object and never passed tags through, so mcData.tags (and registry.tags downstream) stayed undefined even once tags data exists. This adds the passthrough.

bin/generate_data.js already builds data.js getters from every dataPaths key, so the data side needs no change here — the loader's return object was the only gap. With the current submodule pin no version has tags data, so mcData.tags is undefined everywhere: this merges green now, stays inert, and activates automatically on the next submodule bump after minecraft-data#1080 (+ its schema) land.

Changes

  • lib/loader.jstags: mcData.tags passthrough. Plain map like materials; no id index applies (tags are already name-keyed).
  • typings/index-template.d.tstags?: { [registry: string]: { [tagName: string]: string[] } }. Structural type for now; once the tags schema is in the submodule, the generated Tags interface (the typings generator walks schemas/) can replace it.
  • doc/api.mdmcData.tags section with the undefined-when-absent caveat.
  • test/load.js — per-version shape contract: tags is either undefined or registry → tag → array. Currently exercises the undefined path on every version; picks up real data automatically on bump.

Verified locally

  • Full npm test chain green with the change (generate:types, generate:data, lint, test:types, mocha — 1,735 passing).
  • End-to-end simulation of the post-#1080 world: with that PR's tags.json + dataPaths entry applied to the submodule and generate:data re-run, require('minecraft-data')('1.21.8').tags returns the full object (194 block / 179 item / 2 fluid / 39 entity_type tags; minecraft:diamond_ore resolvable through both minecraft:mineable/pickaxe and minecraft:needs_iron_tool — the minecraft-data#987 case), while ('1.21.1').tags and ('bedrock_1.18.0').tags stay undefined. No loader re-touch needed at bump time.

Out of scope

  • A tag-based digTime()/harvest path in prismarine-block. That needs a design decision on where tool-tier speeds live (see minecraft-data#412); this PR only makes the data reachable so that discussion can happen against something concrete.
  • The module-level schemas export in index.js and swapping the structural typing for the generated Tags interface — both need the tags schema present in the submodule, so they belong in a follow-up after the first post-schema submodule bump.

lib/loader.js returns a fixed object, so the tags key emitted by
dataPaths-driven data.js getters never reached mcData even once tags
data exists in the submodule (minecraft-data#1080). Add the passthrough
plus typings, docs, and a per-version shape contract test.

With the current submodule pin no version has tags data, so mcData.tags
is undefined everywhere: this is inert now and activates on the first
submodule bump after minecraft-data#1080 and its schema land.

Resolves PrismarineJS#315. Loader half of the plan discussed in minecraft-data#412.
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.

[Feature Request] Getting block tags

1 participant