diff --git a/__snapshots__/packages/java-edition/test-out/dependency/mcmeta.spec.js b/__snapshots__/packages/java-edition/test-out/dependency/mcmeta.spec.js index b742ad294..874ac481b 100644 --- a/__snapshots__/packages/java-edition/test-out/dependency/mcmeta.spec.js +++ b/__snapshots__/packages/java-edition/test-out/dependency/mcmeta.spec.js @@ -489,6 +489,61 @@ CATEGORY worldgen/tree_decorator_type + + declaration: + + + {"uri":"mcmeta://summary/registries.json"} ------------ +CATEGORY mcdoc/dispatcher ++ SYMBOL mcdoc:block_states {mcdoc/dispatcher} [Public] ++ + declaration: ++ + + {"uri":"mcmeta://summary/registries.json"} ++ + + ------------ ++ + + {"uri":"mcmeta://summary/registries.json"} ++ + members: ++ + + SYMBOL mcdoc:block_states.acacia_button {mcdoc/dispatcher} [Public] ++ + + + data: {"typeDef":{"kind":"struct","fields":[{"kind":"pair","key":"face","optional":true,"type":{"kind":"union","members":[{"kind":"literal","value":{"kind":"string","value":"floor"}},{"kind":"literal","value":{"kind":"string","value":"wall"}},{"kind":"literal","value":{"kind":"string","value":"ceiling"}}]}},{"kind":"pair","key":"facing","optional":true,"type":{"kind":"union","members":[{"kind":"literal","value":{"kind":"string","value":"north"}},{"kind":"literal","value":{"kind":"string","value":"south"}},{"kind":"literal","value":{"kind":"string","value":"west"}},{"kind":"literal","value":{"kind":"string","value":"east"}}]}},{"kind":"pair","key":"powered","optional":true,"type":{"kind":"union","members":[{"kind":"literal","value":{"kind":"string","value":"true"}},{"kind":"literal","value":{"kind":"string","value":"false"}}]}}]}} ++ + + + declaration: ++ + + + + {"uri":"mcmeta://summary/registries.json"} ++ + + + + ------------ ++ + + + + {"uri":"mcmeta://summary/registries.json"} ++ + + ------------ ++ + + SYMBOL mcdoc:block_states.acacia_door {mcdoc/dispatcher} [Public] ++ + + + data: {"typeDef":{"kind":"struct","fields":[{"kind":"pair","key":"facing","optional":true,"type":{"kind":"union","members":[{"kind":"literal","value":{"kind":"string","value":"north"}},{"kind":"literal","value":{"kind":"string","value":"south"}},{"kind":"literal","value":{"kind":"string","value":"west"}},{"kind":"literal","value":{"kind":"string","value":"east"}}]}},{"kind":"pair","key":"half","optional":true,"type":{"kind":"union","members":[{"kind":"literal","value":{"kind":"string","value":"upper"}},{"kind":"literal","value":{"kind":"string","value":"lower"}}]}},{"kind":"pair","key":"hinge","optional":true,"type":{"kind":"union","members":[{"kind":"literal","value":{"kind":"string","value":"left"}},{"kind":"literal","value":{"kind":"string","value":"right"}}]}},{"kind":"pair","key":"open","optional":true,"type":{"kind":"union","members":[{"kind":"literal","value":{"kind":"string","value":"true"}},{"kind":"literal","value":{"kind":"string","value":"false"}}]}},{"kind":"pair","key":"powered","optional":true,"type":{"kind":"union","members":[{"kind":"literal","value":{"kind":"string","value":"true"}},{"kind":"literal","value":{"kind":"string","value":"false"}}]}}]}} ++ + + + declaration: ++ + + + + {"uri":"mcmeta://summary/registries.json"} ++ + + + + ------------ ++ + + + + {"uri":"mcmeta://summary/registries.json"} ++ + + ------------ ++ + + SYMBOL mcdoc:block_states.acacia_fence {mcdoc/dispatcher} [Public] ++ + + + data: {"typeDef":{"kind":"struct","fields":[{"kind":"pair","key":"east","optional":true,"type":{"kind":"union","members":[{"kind":"literal","value":{"kind":"string","value":"true"}},{"kind":"literal","value":{"kind":"string","value":"false"}}]}},{"kind":"pair","key":"north","optional":true,"type":{"kind":"union","members":[{"kind":"literal","value":{"kind":"string","value":"true"}},{"kind":"literal","value":{"kind":"string","value":"false"}}]}},{"kind":"pair","key":"south","optional":true,"type":{"kind":"union","members":[{"kind":"literal","value":{"kind":"string","value":"true"}},{"kind":"literal","value":{"kind":"string","value":"false"}}]}},{"kind":"pair","key":"waterlogged","optional":true,"type":{"kind":"union","members":[{"kind":"literal","value":{"kind":"string","value":"true"}},{"kind":"literal","value":{"kind":"string","value":"false"}}]}},{"kind":"pair","key":"west","optional":true,"type":{"kind":"union","members":[{"kind":"literal","value":{"kind":"string","value":"true"}},{"kind":"literal","value":{"kind":"string","value":"false"}}]}}]}} ++ + + + declaration: ++ + + + + {"uri":"mcmeta://summary/registries.json"} ++ + + + + ------------ ++ + + + + {"uri":"mcmeta://summary/registries.json"} ++ ------------ ++ SYMBOL mcdoc:block_state_keys {mcdoc/dispatcher} [Public] ++ + declaration: ++ + + {"uri":"mcmeta://summary/registries.json"} ++ + + ------------ ++ + + {"uri":"mcmeta://summary/registries.json"} ++ + members: ++ + + SYMBOL mcdoc:block_state_keys.acacia_button {mcdoc/dispatcher} [Public] ++ + + + data: {"typeDef":{"kind":"union","members":[{"kind":"literal","value":{"kind":"string","value":"face"}},{"kind":"literal","value":{"kind":"string","value":"facing"}},{"kind":"literal","value":{"kind":"string","value":"powered"}}]}} ++ + + + declaration: ++ + + + + {"uri":"mcmeta://summary/registries.json"} ++ + + + + ------------ ++ + + + + {"uri":"mcmeta://summary/registries.json"} ++ + + ------------ ++ + + SYMBOL mcdoc:block_state_keys.acacia_door {mcdoc/dispatcher} [Public] ++ + + + data: {"typeDef":{"kind":"union","members":[{"kind":"literal","value":{"kind":"string","value":"facing"}},{"kind":"literal","value":{"kind":"string","value":"half"}},{"kind":"literal","value":{"kind":"string","value":"hinge"}},{"kind":"literal","value":{"kind":"string","value":"open"}},{"kind":"literal","value":{"kind":"string","value":"powered"}}]}} ++ + + + declaration: ++ + + + + {"uri":"mcmeta://summary/registries.json"} ++ + + + + ------------ ++ + + + + {"uri":"mcmeta://summary/registries.json"} ++ + + ------------ ++ + + SYMBOL mcdoc:block_state_keys.acacia_fence {mcdoc/dispatcher} [Public] ++ + + + data: {"typeDef":{"kind":"union","members":[{"kind":"literal","value":{"kind":"string","value":"east"}},{"kind":"literal","value":{"kind":"string","value":"north"}},{"kind":"literal","value":{"kind":"string","value":"south"}},{"kind":"literal","value":{"kind":"string","value":"waterlogged"}},{"kind":"literal","value":{"kind":"string","value":"west"}}]}} ++ + + + declaration: ++ + + + + {"uri":"mcmeta://summary/registries.json"} ++ + + + + ------------ ++ + + + + {"uri":"mcmeta://summary/registries.json"} +------------ CATEGORY loot_table + SYMBOL minecraft:empty {loot_table} [Public] + + declaration: diff --git a/packages/java-edition/src/dependency/mcmeta.ts b/packages/java-edition/src/dependency/mcmeta.ts index a4f3ed9f3..c2640da81 100644 --- a/packages/java-edition/src/dependency/mcmeta.ts +++ b/packages/java-edition/src/dependency/mcmeta.ts @@ -1,4 +1,5 @@ import * as core from '@spyglassmc/core' +import type { TypeDefSymbolData } from '@spyglassmc/mcdoc/lib/binder/index.js' import type { PackMcmeta, ReleaseVersion, VersionInfo } from './common.js' /** @@ -160,6 +161,54 @@ export function symbolRegistrar(summary: McmetaSummary): core.SymbolRegistrar { }, ) } + + symbols.query(McmetaSummaryUri, 'mcdoc/dispatcher', 'mcdoc:block_states').enter({ + usage: { type: 'declaration' }, + }).onEach(Object.entries(summary.blocks), ([id, [properties]], blockQuery) => { + const data: TypeDefSymbolData = { + typeDef: { + kind: 'struct', + fields: Object.entries(properties).map(([propKey, propValues]) => ({ + kind: 'pair', + key: propKey, + optional: true, + type: { + kind: 'union', + members: propValues.map(value => ({ + kind: 'literal', + value: { kind: 'string', value }, + })), + }, + })), + }, + } + blockQuery.member(id, (stateQuery) => { + stateQuery.enter({ + data: { data }, + usage: { type: 'declaration' }, + }) + }) + }) + + symbols.query(McmetaSummaryUri, 'mcdoc/dispatcher', 'mcdoc:block_state_keys').enter({ + usage: { type: 'declaration' }, + }).onEach(Object.entries(summary.blocks), ([id, [properties]], blockQuery) => { + const data: TypeDefSymbolData = { + typeDef: { + kind: 'union', + members: Object.keys(properties).map(propKey => ({ + kind: 'literal', + value: { kind: 'string', value: propKey }, + })), + }, + } + blockQuery.member(id, (stateQuery) => { + stateQuery.enter({ + data: { data }, + usage: { type: 'declaration' }, + }) + }) + }) } function addRegistriesSymbols(registries: McmetaRegistries, symbols: core.SymbolUtil) {