loader: pass tags through to mcData#457
Open
VasilisDragon wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the loader half discussed in PrismarineJS/minecraft-data#412 and resolves #315 (block tags feature request, 2023):
lib/loader.jsreturns a fixed object and never passedtagsthrough, somcData.tags(andregistry.tagsdownstream) stayedundefinedeven once tags data exists. This adds the passthrough.bin/generate_data.jsalready buildsdata.jsgetters from everydataPathskey, 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, somcData.tagsisundefinedeverywhere: this merges green now, stays inert, and activates automatically on the next submodule bump after minecraft-data#1080 (+ its schema) land.Changes
lib/loader.js—tags: mcData.tagspassthrough. Plain map likematerials; no id index applies (tags are already name-keyed).typings/index-template.d.ts—tags?: { [registry: string]: { [tagName: string]: string[] } }. Structural type for now; once the tags schema is in the submodule, the generatedTagsinterface (the typings generator walksschemas/) can replace it.doc/api.md—mcData.tagssection with theundefined-when-absent caveat.test/load.js— per-version shape contract:tagsis eitherundefinedor registry → tag → array. Currently exercises theundefinedpath on every version; picks up real data automatically on bump.Verified locally
npm testchain green with the change (generate:types, generate:data, lint, test:types, mocha — 1,735 passing).tags.json+dataPathsentry applied to the submodule andgenerate:datare-run,require('minecraft-data')('1.21.8').tagsreturns the full object (194 block / 179 item / 2 fluid / 39 entity_type tags;minecraft:diamond_oreresolvable through bothminecraft:mineable/pickaxeandminecraft:needs_iron_tool— the minecraft-data#987 case), while('1.21.1').tagsand('bedrock_1.18.0').tagsstayundefined. No loader re-touch needed at bump time.Out of scope
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.schemasexport inindex.jsand swapping the structural typing for the generatedTagsinterface — both need the tags schema present in the submodule, so they belong in a follow-up after the first post-schema submodule bump.