From 2a5a5bc355191f1defa76ed846ce4a3092e43976 Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Wed, 29 May 2024 21:20:47 -0400 Subject: [PATCH 1/5] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Allow=20specifying=20v?= =?UTF-8?q?ersion=20in=20argument=20parser=20test=20cases=20-=20tests=20do?= =?UTF-8?q?n't=20include=20version=20in=20name=20if=20it's=20`1.15`=20(def?= =?UTF-8?q?ault)=20to=20minimize=20diffs=20here?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/mcfunction/parser/argument.spec.ts | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/packages/java-edition/test/mcfunction/parser/argument.spec.ts b/packages/java-edition/test/mcfunction/parser/argument.spec.ts index 3aa7cdee8..11284d69d 100644 --- a/packages/java-edition/test/mcfunction/parser/argument.spec.ts +++ b/packages/java-edition/test/mcfunction/parser/argument.spec.ts @@ -11,7 +11,10 @@ import * as nbt from '@spyglassmc/nbt' import { describe, it } from 'mocha' const Suites: Partial< - Record + Record< + ArgumentTreeNode['parser'], + { content: string[]; properties?: any; version?: string }[] + > > = { 'brigadier:bool': [{ content: ['false', 'true'] }], 'brigadier:double': [ @@ -290,26 +293,32 @@ const RemoveExtraChildren = new Set([ 'minecraft:score_holder', ]) -const project = mockProjectData() - -json.initialize(project) -nbt.initialize(project) - -const { meta } = project - describe('mcfunction argument parser', () => { for (const [parserName, cases] of Object.entries(Suites)) { describe(parserName, () => { - for (const { content, properties } of cases) { + for (const { content, properties, version } of cases) { const treeNode: ArgumentTreeNode = { type: 'argument', parser: parserName as any, properties, } + const ctx = typeof version !== 'undefined' + ? { loadedVersion: version } + : void 0 + const project = mockProjectData({ ctx }) + json.initialize(project) + nbt.initialize(project) + for (const string of content) { - const itTitle = `Parse "${showWhitespaceGlyph(string)}"${ - properties ? ` with ${JSON.stringify(properties)}` : '' - }` + const propertiesString = properties + ? ` with ${JSON.stringify(properties)}` + : '' + const versionString = typeof version !== 'undefined' + ? `in version ${version}` + : '' + const itTitle = `Parse "${ + showWhitespaceGlyph(string) + }"${propertiesString}${versionString}` it(itTitle, () => { snapshotWithUri({ specName: `mcfunction argument ${parserName} ${itTitle}`, @@ -321,7 +330,7 @@ describe('mcfunction argument parser', () => { import.meta.url, ), value: testParser(argument(treeNode)!, string, { - project: { meta }, + project, removeTopLevelChildren: RemoveExtraChildren.has( parserName, ), From fdc29f4ec304f2ab4d211bb02bafdd53720d7dfa Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Wed, 29 May 2024 21:31:06 -0400 Subject: [PATCH 2/5] =?UTF-8?q?=E2=9C=85=20Add=20tests=20for=20`particle`?= =?UTF-8?q?=20argument=20parser=20for=20`1.20.5`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../parser/argument/minecraftParticle.spec.js | 585 ++++++++++++++++++ .../test/mcfunction/parser/argument.spec.ts | 14 +- 2 files changed, 598 insertions(+), 1 deletion(-) diff --git a/__snapshots__/packages/java-edition/test-out/mcfunction/parser/argument/minecraftParticle.spec.js b/__snapshots__/packages/java-edition/test-out/mcfunction/parser/argument/minecraftParticle.spec.js index 2ab998416..939e7eb26 100644 --- a/__snapshots__/packages/java-edition/test-out/mcfunction/parser/argument/minecraftParticle.spec.js +++ b/__snapshots__/packages/java-edition/test-out/mcfunction/parser/argument/minecraftParticle.spec.js @@ -60,6 +60,451 @@ exports['mcfunction argument minecraft:particle Parse "block stone" 1'] = { "errors": [] } +exports['mcfunction argument minecraft:particle Parse "block stone" in version 1.20.5 1'] = { + "node": { + "type": "mcfunction:particle", + "range": { + "start": 0, + "end": 5 + }, + "children": [ + { + "type": "resource_location", + "range": { + "start": 0, + "end": 5 + }, + "path": [ + "block" + ] + } + ], + "id": { + "type": "resource_location", + "range": { + "start": 0, + "end": 5 + }, + "path": [ + "block" + ] + } + }, + "errors": [] +} + +exports['mcfunction argument minecraft:particle Parse "block{block_state:"diamond_block"} ~ ~ ~" 1'] = { + "node": { + "type": "mcfunction:particle", + "range": { + "start": 0, + "end": 34 + }, + "children": [ + { + "type": "resource_location", + "range": { + "start": 0, + "end": 5 + }, + "path": [ + "block" + ] + }, + { + "type": "mcfunction:block", + "range": { + "start": 5, + "end": 34 + }, + "children": [ + { + "type": "resource_location", + "range": { + "start": 5, + "end": 5 + } + }, + { + "type": "nbt:compound", + "range": { + "start": 5, + "end": 34 + }, + "children": [ + { + "type": "pair", + "range": { + "start": 6, + "end": 33 + }, + "children": [ + { + "type": "string", + "range": { + "start": 6, + "end": 17 + }, + "value": "block_state", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 6, + "end": 6 + } + } + ] + }, + { + "type": "string", + "range": { + "start": 18, + "end": 33 + }, + "value": "diamond_block", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 19, + "end": 19 + } + } + ] + } + ], + "key": { + "type": "string", + "range": { + "start": 6, + "end": 17 + }, + "value": "block_state", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 6, + "end": 6 + } + } + ] + }, + "sep": { + "start": 17, + "end": 18 + }, + "value": { + "type": "string", + "range": { + "start": 18, + "end": 33 + }, + "value": "diamond_block", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 19, + "end": 19 + } + } + ] + } + } + ] + } + ], + "id": { + "type": "resource_location", + "range": { + "start": 5, + "end": 5 + } + }, + "nbt": { + "type": "nbt:compound", + "range": { + "start": 5, + "end": 34 + }, + "children": [ + { + "type": "pair", + "range": { + "start": 6, + "end": 33 + }, + "children": [ + { + "type": "string", + "range": { + "start": 6, + "end": 17 + }, + "value": "block_state", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 6, + "end": 6 + } + } + ] + }, + { + "type": "string", + "range": { + "start": 18, + "end": 33 + }, + "value": "diamond_block", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 19, + "end": 19 + } + } + ] + } + ], + "key": { + "type": "string", + "range": { + "start": 6, + "end": 17 + }, + "value": "block_state", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 6, + "end": 6 + } + } + ] + }, + "sep": { + "start": 17, + "end": 18 + }, + "value": { + "type": "string", + "range": { + "start": 18, + "end": 33 + }, + "value": "diamond_block", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 19, + "end": 19 + } + } + ] + } + } + ] + } + } + ], + "id": { + "type": "resource_location", + "range": { + "start": 0, + "end": 5 + }, + "path": [ + "block" + ] + } + }, + "errors": [ + { + "range": { + "start": 5, + "end": 5 + }, + "message": "Expected a space (ā€œ ā€)", + "severity": 3 + }, + { + "range": { + "start": 5, + "end": 5 + }, + "message": "Expected a resource location", + "severity": 3 + } + ] +} + +exports['mcfunction argument minecraft:particle Parse "block{block_state:"diamond_block"} ~ ~ ~" in version 1.20.5 1'] = { + "node": { + "type": "mcfunction:particle", + "range": { + "start": 0, + "end": 34 + }, + "children": [ + { + "type": "resource_location", + "range": { + "start": 0, + "end": 5 + }, + "path": [ + "block" + ] + }, + { + "type": "nbt:compound", + "range": { + "start": 5, + "end": 34 + }, + "children": [ + { + "type": "pair", + "range": { + "start": 6, + "end": 33 + }, + "children": [ + { + "type": "string", + "range": { + "start": 6, + "end": 17 + }, + "value": "block_state", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 6, + "end": 6 + } + } + ] + }, + { + "type": "string", + "range": { + "start": 18, + "end": 33 + }, + "value": "diamond_block", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 19, + "end": 19 + } + } + ] + } + ], + "key": { + "type": "string", + "range": { + "start": 6, + "end": 17 + }, + "value": "block_state", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 6, + "end": 6 + } + } + ] + }, + "sep": { + "start": 17, + "end": 18 + }, + "value": { + "type": "string", + "range": { + "start": 18, + "end": 33 + }, + "value": "diamond_block", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 19, + "end": 19 + } + } + ] + } + } + ] + } + ], + "id": { + "type": "resource_location", + "range": { + "start": 0, + "end": 5 + }, + "path": [ + "block" + ] + } + }, + "errors": [] +} + exports['mcfunction argument minecraft:particle Parse "cloud" 1'] = { "node": { "type": "mcfunction:particle", @@ -182,6 +627,39 @@ exports['mcfunction argument minecraft:particle Parse "dust 0.2 0.4 0.6 0.8" 1'] "errors": [] } +exports['mcfunction argument minecraft:particle Parse "dust 0.2 0.4 0.6 0.8" in version 1.20.5 1'] = { + "node": { + "type": "mcfunction:particle", + "range": { + "start": 0, + "end": 4 + }, + "children": [ + { + "type": "resource_location", + "range": { + "start": 0, + "end": 4 + }, + "path": [ + "dust" + ] + } + ], + "id": { + "type": "resource_location", + "range": { + "start": 0, + "end": 4 + }, + "path": [ + "dust" + ] + } + }, + "errors": [] +} + exports['mcfunction argument minecraft:particle Parse "dust_color_transition 0.1 0.2 0.3 0.4 0.5 0.6 0.7" 1'] = { "node": { "type": "mcfunction:particle", @@ -319,6 +797,113 @@ exports['mcfunction argument minecraft:particle Parse "dust_color_transition 0.1 "errors": [] } +exports['mcfunction argument minecraft:particle Parse "end_rod" in version 1.20.5 1'] = { + "node": { + "type": "mcfunction:particle", + "range": { + "start": 0, + "end": 7 + }, + "children": [ + { + "type": "resource_location", + "range": { + "start": 0, + "end": 7 + }, + "path": [ + "end_rod" + ] + } + ], + "id": { + "type": "resource_location", + "range": { + "start": 0, + "end": 7 + }, + "path": [ + "end_rod" + ] + } + }, + "errors": [] +} + +exports['mcfunction argument minecraft:particle Parse "end_rod{}" 1'] = { + "node": { + "type": "mcfunction:particle", + "range": { + "start": 0, + "end": 7 + }, + "children": [ + { + "type": "resource_location", + "range": { + "start": 0, + "end": 7 + }, + "path": [ + "end_rod" + ] + } + ], + "id": { + "type": "resource_location", + "range": { + "start": 0, + "end": 7 + }, + "path": [ + "end_rod" + ] + } + }, + "errors": [] +} + +exports['mcfunction argument minecraft:particle Parse "end_rod{}" in version 1.20.5 1'] = { + "node": { + "type": "mcfunction:particle", + "range": { + "start": 0, + "end": 9 + }, + "children": [ + { + "type": "resource_location", + "range": { + "start": 0, + "end": 7 + }, + "path": [ + "end_rod" + ] + }, + { + "type": "nbt:compound", + "range": { + "start": 7, + "end": 9 + }, + "children": [] + } + ], + "id": { + "type": "resource_location", + "range": { + "start": 0, + "end": 7 + }, + "path": [ + "end_rod" + ] + } + }, + "errors": [] +} + exports['mcfunction argument minecraft:particle Parse "item carrot_on_a_stick" 1'] = { "node": { "type": "mcfunction:particle", diff --git a/packages/java-edition/test/mcfunction/parser/argument.spec.ts b/packages/java-edition/test/mcfunction/parser/argument.spec.ts index 11284d69d..deefc3d50 100644 --- a/packages/java-edition/test/mcfunction/parser/argument.spec.ts +++ b/packages/java-edition/test/mcfunction/parser/argument.spec.ts @@ -193,8 +193,20 @@ const Suites: Partial< 'sculk_charge 4.2', 'shriek 20', 'vibration 0.1 0.2 0.3 40', + 'block{block_state:"diamond_block"} ~ ~ ~', + 'end_rod{}', ], }, + { + content: [ + 'block stone', + 'dust 0.2 0.4 0.6 0.8', + 'block{block_state:"diamond_block"} ~ ~ ~', + 'end_rod', + 'end_rod{}', + ], + version: '1.20.5', + }, ], 'minecraft:resource': [ { @@ -314,7 +326,7 @@ describe('mcfunction argument parser', () => { ? ` with ${JSON.stringify(properties)}` : '' const versionString = typeof version !== 'undefined' - ? `in version ${version}` + ? ` in version ${version}` : '' const itTitle = `Parse "${ showWhitespaceGlyph(string) From 1ba92631a86c0861265c0e6abbc84c4112b0fe8f Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Wed, 29 May 2024 22:10:52 -0400 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=94=A5=20Delete=20extra=20string=20co?= =?UTF-8?q?ntent=20from=20test=20cases=20-=20https://github.com/SpyglassMC?= =?UTF-8?q?/Spyglass/pull/1216#discussion=5Fr1619713214=20-=20https://gith?= =?UTF-8?q?ub.com/SpyglassMC/Spyglass/pull/1216#discussion=5Fr1619713619?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mcfunction/parser/argument/minecraftParticle.spec.js | 4 ++-- packages/java-edition/test/mcfunction/parser/argument.spec.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/__snapshots__/packages/java-edition/test-out/mcfunction/parser/argument/minecraftParticle.spec.js b/__snapshots__/packages/java-edition/test-out/mcfunction/parser/argument/minecraftParticle.spec.js index 939e7eb26..babecd242 100644 --- a/__snapshots__/packages/java-edition/test-out/mcfunction/parser/argument/minecraftParticle.spec.js +++ b/__snapshots__/packages/java-edition/test-out/mcfunction/parser/argument/minecraftParticle.spec.js @@ -93,7 +93,7 @@ exports['mcfunction argument minecraft:particle Parse "block stone" in version 1 "errors": [] } -exports['mcfunction argument minecraft:particle Parse "block{block_state:"diamond_block"} ~ ~ ~" 1'] = { +exports['mcfunction argument minecraft:particle Parse "block{block_state:"diamond_block"}" 1'] = { "node": { "type": "mcfunction:particle", "range": { @@ -370,7 +370,7 @@ exports['mcfunction argument minecraft:particle Parse "block{block_state:"diamon ] } -exports['mcfunction argument minecraft:particle Parse "block{block_state:"diamond_block"} ~ ~ ~" in version 1.20.5 1'] = { +exports['mcfunction argument minecraft:particle Parse "block{block_state:"diamond_block"}" in version 1.20.5 1'] = { "node": { "type": "mcfunction:particle", "range": { diff --git a/packages/java-edition/test/mcfunction/parser/argument.spec.ts b/packages/java-edition/test/mcfunction/parser/argument.spec.ts index deefc3d50..86cbe69b8 100644 --- a/packages/java-edition/test/mcfunction/parser/argument.spec.ts +++ b/packages/java-edition/test/mcfunction/parser/argument.spec.ts @@ -193,7 +193,7 @@ const Suites: Partial< 'sculk_charge 4.2', 'shriek 20', 'vibration 0.1 0.2 0.3 40', - 'block{block_state:"diamond_block"} ~ ~ ~', + 'block{block_state:"diamond_block"}', 'end_rod{}', ], }, @@ -201,7 +201,7 @@ const Suites: Partial< content: [ 'block stone', 'dust 0.2 0.4 0.6 0.8', - 'block{block_state:"diamond_block"} ~ ~ ~', + 'block{block_state:"diamond_block"}', 'end_rod', 'end_rod{}', ], From 90337feeca422fae57cbe2f0f6742149538ec5a0 Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Thu, 30 May 2024 21:10:41 -0400 Subject: [PATCH 4/5] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Remove=20default=20`lo?= =?UTF-8?q?adedVersion`=20from=20`mockProjectData`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/test/utils.ts | 2 +- .../java-edition/test/mcfunction/parser/argument.spec.ts | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/core/test/utils.ts b/packages/core/test/utils.ts index 2f484cd22..65903bf8e 100644 --- a/packages/core/test/utils.ts +++ b/packages/core/test/utils.ts @@ -58,7 +58,7 @@ export function mockProjectData(data: Partial = {}): ProjectData { return { cacheRoot, config: data.config ?? VanillaConfig, - ctx: data.ctx ?? { loadedVersion: '1.15' }, + ctx: data.ctx ?? {}, downloader, ensureBindingStarted: data.ensureBindingStarted!, externals, diff --git a/packages/java-edition/test/mcfunction/parser/argument.spec.ts b/packages/java-edition/test/mcfunction/parser/argument.spec.ts index 86cbe69b8..10a02cf77 100644 --- a/packages/java-edition/test/mcfunction/parser/argument.spec.ts +++ b/packages/java-edition/test/mcfunction/parser/argument.spec.ts @@ -308,16 +308,13 @@ const RemoveExtraChildren = new Set([ describe('mcfunction argument parser', () => { for (const [parserName, cases] of Object.entries(Suites)) { describe(parserName, () => { - for (const { content, properties, version } of cases) { + for (const { content, properties, version = '1.15' } of cases) { const treeNode: ArgumentTreeNode = { type: 'argument', parser: parserName as any, properties, } - const ctx = typeof version !== 'undefined' - ? { loadedVersion: version } - : void 0 - const project = mockProjectData({ ctx }) + const project = mockProjectData({ ctx: { loadedVersion: version } }) json.initialize(project) nbt.initialize(project) @@ -325,7 +322,7 @@ describe('mcfunction argument parser', () => { const propertiesString = properties ? ` with ${JSON.stringify(properties)}` : '' - const versionString = typeof version !== 'undefined' + const versionString = version !== '1.15' ? ` in version ${version}` : '' const itTitle = `Parse "${ From 65ccd10da8618d03a7331140d08972c3efef70da Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Thu, 30 May 2024 21:22:04 -0400 Subject: [PATCH 5/5] =?UTF-8?q?=E2=9C=85=20Add=20`@n`=20argument=20parser?= =?UTF-8?q?=20tests=20with=20version=20`1.21`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../parser/argument/minecraftEntity.spec.js | 902 +++++++++++++++--- .../test/mcfunction/parser/argument.spec.ts | 9 + 2 files changed, 794 insertions(+), 117 deletions(-) diff --git a/__snapshots__/packages/java-edition/test-out/mcfunction/parser/argument/minecraftEntity.spec.js b/__snapshots__/packages/java-edition/test-out/mcfunction/parser/argument/minecraftEntity.spec.js index 70b0e332d..76c49313a 100644 --- a/__snapshots__/packages/java-edition/test-out/mcfunction/parser/argument/minecraftEntity.spec.js +++ b/__snapshots__/packages/java-edition/test-out/mcfunction/parser/argument/minecraftEntity.spec.js @@ -10044,18 +10044,693 @@ exports['mcfunction argument minecraft:entity Parse "@n" with {"amount":"single" ] } +exports['mcfunction argument minecraft:entity Parse "@n" with {"amount":"single","type":"entities"} in version 1.21 1'] = { + "node": { + "type": "mcfunction:entity", + "range": { + "start": 0, + "end": 2 + }, + "selector": { + "type": "mcfunction:entity_selector", + "range": { + "start": 0, + "end": 2 + }, + "children": [ + { + "type": "literal", + "range": { + "start": 0, + "end": 2 + }, + "value": "@n" + } + ], + "variable": "n", + "currentEntity": false, + "playersOnly": false, + "single": true, + "typeLimited": false, + "hover": "**Performance**: šŸ¤¢\n- `chunkLimited`: `false`\n- `dimensionLimited`: `false`\n- `playersOnly`: `false`\n- `typeLimited`: `false`" + } + }, + "errors": [] +} + exports['mcfunction argument minecraft:entity Parse "@n[distance=..5]" with {"amount":"single","type":"entities"} 1'] = { "node": { "type": "mcfunction:entity", "range": { "start": 0, - "end": 16 + "end": 16 + }, + "selector": { + "type": "mcfunction:entity_selector", + "range": { + "start": 0, + "end": 16 + }, + "children": [ + { + "type": "literal", + "range": { + "start": 0, + "end": 2 + }, + "value": "@n" + }, + { + "type": "mcfunction:entity_selector/arguments", + "range": { + "start": 2, + "end": 16 + }, + "children": [ + { + "type": "pair", + "range": { + "start": 3, + "end": 15 + }, + "children": [ + { + "type": "string", + "range": { + "start": 3, + "end": 11 + }, + "value": "distance", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 3, + "end": 3 + } + } + ], + "children": [ + { + "type": "literal", + "range": { + "start": 3, + "end": 11 + }, + "value": "distance" + } + ] + }, + { + "type": "mcfunction:float_range", + "range": { + "start": 12, + "end": 15 + }, + "children": [ + { + "type": "literal", + "range": { + "start": 12, + "end": 14 + }, + "value": ".." + }, + { + "type": "float", + "range": { + "start": 14, + "end": 15 + }, + "value": 5 + } + ], + "value": [ + null, + 5 + ] + } + ], + "key": { + "type": "string", + "range": { + "start": 3, + "end": 11 + }, + "value": "distance", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 3, + "end": 3 + } + } + ], + "children": [ + { + "type": "literal", + "range": { + "start": 3, + "end": 11 + }, + "value": "distance" + } + ] + }, + "sep": { + "start": 11, + "end": 12 + }, + "value": { + "type": "mcfunction:float_range", + "range": { + "start": 12, + "end": 15 + }, + "children": [ + { + "type": "literal", + "range": { + "start": 12, + "end": 14 + }, + "value": ".." + }, + { + "type": "float", + "range": { + "start": 14, + "end": 15 + }, + "value": 5 + } + ], + "value": [ + null, + 5 + ] + } + } + ] + } + ], + "variable": "n", + "arguments": { + "type": "mcfunction:entity_selector/arguments", + "range": { + "start": 2, + "end": 16 + }, + "children": [ + { + "type": "pair", + "range": { + "start": 3, + "end": 15 + }, + "children": [ + { + "type": "string", + "range": { + "start": 3, + "end": 11 + }, + "value": "distance", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 3, + "end": 3 + } + } + ], + "children": [ + { + "type": "literal", + "range": { + "start": 3, + "end": 11 + }, + "value": "distance" + } + ] + }, + { + "type": "mcfunction:float_range", + "range": { + "start": 12, + "end": 15 + }, + "children": [ + { + "type": "literal", + "range": { + "start": 12, + "end": 14 + }, + "value": ".." + }, + { + "type": "float", + "range": { + "start": 14, + "end": 15 + }, + "value": 5 + } + ], + "value": [ + null, + 5 + ] + } + ], + "key": { + "type": "string", + "range": { + "start": 3, + "end": 11 + }, + "value": "distance", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 3, + "end": 3 + } + } + ], + "children": [ + { + "type": "literal", + "range": { + "start": 3, + "end": 11 + }, + "value": "distance" + } + ] + }, + "sep": { + "start": 11, + "end": 12 + }, + "value": { + "type": "mcfunction:float_range", + "range": { + "start": 12, + "end": 15 + }, + "children": [ + { + "type": "literal", + "range": { + "start": 12, + "end": 14 + }, + "value": ".." + }, + { + "type": "float", + "range": { + "start": 14, + "end": 15 + }, + "value": 5 + } + ], + "value": [ + null, + 5 + ] + } + } + ] + }, + "chunkLimited": true, + "currentEntity": false, + "dimensionLimited": true, + "playersOnly": false, + "single": true, + "typeLimited": false, + "hover": "**Performance**: Good\n- `chunkLimited`: `true`\n- `dimensionLimited`: `true`\n- `playersOnly`: `false`\n- `typeLimited`: `true`" + } + }, + "errors": [ + { + "range": { + "start": 0, + "end": 2 + }, + "message": "Invalid entity selector: ā€œ@nā€", + "severity": 3 + } + ] +} + +exports['mcfunction argument minecraft:entity Parse "@n[distance=..5]" with {"amount":"single","type":"entities"} in version 1.21 1'] = { + "node": { + "type": "mcfunction:entity", + "range": { + "start": 0, + "end": 16 + }, + "selector": { + "type": "mcfunction:entity_selector", + "range": { + "start": 0, + "end": 16 + }, + "children": [ + { + "type": "literal", + "range": { + "start": 0, + "end": 2 + }, + "value": "@n" + }, + { + "type": "mcfunction:entity_selector/arguments", + "range": { + "start": 2, + "end": 16 + }, + "children": [ + { + "type": "pair", + "range": { + "start": 3, + "end": 15 + }, + "children": [ + { + "type": "string", + "range": { + "start": 3, + "end": 11 + }, + "value": "distance", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 3, + "end": 3 + } + } + ], + "children": [ + { + "type": "literal", + "range": { + "start": 3, + "end": 11 + }, + "value": "distance" + } + ] + }, + { + "type": "mcfunction:float_range", + "range": { + "start": 12, + "end": 15 + }, + "children": [ + { + "type": "literal", + "range": { + "start": 12, + "end": 14 + }, + "value": ".." + }, + { + "type": "float", + "range": { + "start": 14, + "end": 15 + }, + "value": 5 + } + ], + "value": [ + null, + 5 + ] + } + ], + "key": { + "type": "string", + "range": { + "start": 3, + "end": 11 + }, + "value": "distance", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 3, + "end": 3 + } + } + ], + "children": [ + { + "type": "literal", + "range": { + "start": 3, + "end": 11 + }, + "value": "distance" + } + ] + }, + "sep": { + "start": 11, + "end": 12 + }, + "value": { + "type": "mcfunction:float_range", + "range": { + "start": 12, + "end": 15 + }, + "children": [ + { + "type": "literal", + "range": { + "start": 12, + "end": 14 + }, + "value": ".." + }, + { + "type": "float", + "range": { + "start": 14, + "end": 15 + }, + "value": 5 + } + ], + "value": [ + null, + 5 + ] + } + } + ] + } + ], + "variable": "n", + "arguments": { + "type": "mcfunction:entity_selector/arguments", + "range": { + "start": 2, + "end": 16 + }, + "children": [ + { + "type": "pair", + "range": { + "start": 3, + "end": 15 + }, + "children": [ + { + "type": "string", + "range": { + "start": 3, + "end": 11 + }, + "value": "distance", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 3, + "end": 3 + } + } + ], + "children": [ + { + "type": "literal", + "range": { + "start": 3, + "end": 11 + }, + "value": "distance" + } + ] + }, + { + "type": "mcfunction:float_range", + "range": { + "start": 12, + "end": 15 + }, + "children": [ + { + "type": "literal", + "range": { + "start": 12, + "end": 14 + }, + "value": ".." + }, + { + "type": "float", + "range": { + "start": 14, + "end": 15 + }, + "value": 5 + } + ], + "value": [ + null, + 5 + ] + } + ], + "key": { + "type": "string", + "range": { + "start": 3, + "end": 11 + }, + "value": "distance", + "valueMap": [ + { + "inner": { + "start": 0, + "end": 0 + }, + "outer": { + "start": 3, + "end": 3 + } + } + ], + "children": [ + { + "type": "literal", + "range": { + "start": 3, + "end": 11 + }, + "value": "distance" + } + ] + }, + "sep": { + "start": 11, + "end": 12 + }, + "value": { + "type": "mcfunction:float_range", + "range": { + "start": 12, + "end": 15 + }, + "children": [ + { + "type": "literal", + "range": { + "start": 12, + "end": 14 + }, + "value": ".." + }, + { + "type": "float", + "range": { + "start": 14, + "end": 15 + }, + "value": 5 + } + ], + "value": [ + null, + 5 + ] + } + } + ] + }, + "chunkLimited": true, + "currentEntity": false, + "dimensionLimited": true, + "playersOnly": false, + "single": true, + "typeLimited": false, + "hover": "**Performance**: Good\n- `chunkLimited`: `true`\n- `dimensionLimited`: `true`\n- `playersOnly`: `false`\n- `typeLimited`: `true`" + } + }, + "errors": [] +} + +exports['mcfunction argument minecraft:entity Parse "@n[type=cow]" with {"amount":"single","type":"entities"} 1'] = { + "node": { + "type": "mcfunction:entity", + "range": { + "start": 0, + "end": 12 }, "selector": { "type": "mcfunction:entity_selector", "range": { "start": 0, - "end": 16 + "end": 12 }, "children": [ { @@ -10070,23 +10745,23 @@ exports['mcfunction argument minecraft:entity Parse "@n[distance=..5]" with {"am "type": "mcfunction:entity_selector/arguments", "range": { "start": 2, - "end": 16 + "end": 12 }, "children": [ { "type": "pair", "range": { "start": 3, - "end": 15 + "end": 11 }, "children": [ { "type": "string", "range": { "start": 3, - "end": 11 + "end": 7 }, - "value": "distance", + "value": "type", "valueMap": [ { "inner": { @@ -10104,49 +10779,50 @@ exports['mcfunction argument minecraft:entity Parse "@n[distance=..5]" with {"am "type": "literal", "range": { "start": 3, - "end": 11 + "end": 7 }, - "value": "distance" + "value": "type" } ] }, { - "type": "mcfunction:float_range", + "type": "mcfunction:entity_selector/arguments/value/invertable", "range": { - "start": 12, - "end": 15 + "start": 8, + "end": 11 }, "children": [ { - "type": "literal", - "range": { - "start": 12, - "end": 14 - }, - "value": ".." - }, - { - "type": "float", + "type": "resource_location", "range": { - "start": 14, - "end": 15 + "start": 8, + "end": 11 }, - "value": 5 + "path": [ + "cow" + ] } ], - "value": [ - null, - 5 - ] + "inverted": false, + "value": { + "type": "resource_location", + "range": { + "start": 8, + "end": 11 + }, + "path": [ + "cow" + ] + } } ], "key": { "type": "string", "range": { "start": 3, - "end": 11 + "end": 7 }, - "value": "distance", + "value": "type", "valueMap": [ { "inner": { @@ -10164,44 +10840,45 @@ exports['mcfunction argument minecraft:entity Parse "@n[distance=..5]" with {"am "type": "literal", "range": { "start": 3, - "end": 11 + "end": 7 }, - "value": "distance" + "value": "type" } ] }, "sep": { - "start": 11, - "end": 12 + "start": 7, + "end": 8 }, "value": { - "type": "mcfunction:float_range", + "type": "mcfunction:entity_selector/arguments/value/invertable", "range": { - "start": 12, - "end": 15 + "start": 8, + "end": 11 }, "children": [ { - "type": "literal", - "range": { - "start": 12, - "end": 14 - }, - "value": ".." - }, - { - "type": "float", + "type": "resource_location", "range": { - "start": 14, - "end": 15 + "start": 8, + "end": 11 }, - "value": 5 + "path": [ + "cow" + ] } ], - "value": [ - null, - 5 - ] + "inverted": false, + "value": { + "type": "resource_location", + "range": { + "start": 8, + "end": 11 + }, + "path": [ + "cow" + ] + } } } ] @@ -10212,23 +10889,23 @@ exports['mcfunction argument minecraft:entity Parse "@n[distance=..5]" with {"am "type": "mcfunction:entity_selector/arguments", "range": { "start": 2, - "end": 16 + "end": 12 }, "children": [ { "type": "pair", "range": { "start": 3, - "end": 15 + "end": 11 }, "children": [ { "type": "string", "range": { "start": 3, - "end": 11 + "end": 7 }, - "value": "distance", + "value": "type", "valueMap": [ { "inner": { @@ -10246,49 +10923,50 @@ exports['mcfunction argument minecraft:entity Parse "@n[distance=..5]" with {"am "type": "literal", "range": { "start": 3, - "end": 11 + "end": 7 }, - "value": "distance" + "value": "type" } ] }, { - "type": "mcfunction:float_range", + "type": "mcfunction:entity_selector/arguments/value/invertable", "range": { - "start": 12, - "end": 15 + "start": 8, + "end": 11 }, "children": [ { - "type": "literal", - "range": { - "start": 12, - "end": 14 - }, - "value": ".." - }, - { - "type": "float", + "type": "resource_location", "range": { - "start": 14, - "end": 15 + "start": 8, + "end": 11 }, - "value": 5 + "path": [ + "cow" + ] } ], - "value": [ - null, - 5 - ] + "inverted": false, + "value": { + "type": "resource_location", + "range": { + "start": 8, + "end": 11 + }, + "path": [ + "cow" + ] + } } ], "key": { "type": "string", "range": { "start": 3, - "end": 11 + "end": 7 }, - "value": "distance", + "value": "type", "valueMap": [ { "inner": { @@ -10306,55 +10984,54 @@ exports['mcfunction argument minecraft:entity Parse "@n[distance=..5]" with {"am "type": "literal", "range": { "start": 3, - "end": 11 + "end": 7 }, - "value": "distance" + "value": "type" } ] }, "sep": { - "start": 11, - "end": 12 + "start": 7, + "end": 8 }, "value": { - "type": "mcfunction:float_range", + "type": "mcfunction:entity_selector/arguments/value/invertable", "range": { - "start": 12, - "end": 15 + "start": 8, + "end": 11 }, "children": [ { - "type": "literal", - "range": { - "start": 12, - "end": 14 - }, - "value": ".." - }, - { - "type": "float", + "type": "resource_location", "range": { - "start": 14, - "end": 15 + "start": 8, + "end": 11 }, - "value": 5 + "path": [ + "cow" + ] } ], - "value": [ - null, - 5 - ] + "inverted": false, + "value": { + "type": "resource_location", + "range": { + "start": 8, + "end": 11 + }, + "path": [ + "cow" + ] + } } } ] }, - "chunkLimited": true, "currentEntity": false, - "dimensionLimited": true, "playersOnly": false, "single": true, - "typeLimited": false, - "hover": "**Performance**: Good\n- `chunkLimited`: `true`\n- `dimensionLimited`: `true`\n- `playersOnly`: `false`\n- `typeLimited`: `true`" + "typeLimited": true, + "hover": "**Performance**: šŸ˜…\n- `chunkLimited`: `false`\n- `dimensionLimited`: `false`\n- `playersOnly`: `false`\n- `typeLimited`: `false`" } }, "errors": [ @@ -10369,7 +11046,7 @@ exports['mcfunction argument minecraft:entity Parse "@n[distance=..5]" with {"am ] } -exports['mcfunction argument minecraft:entity Parse "@n[type=cow]" with {"amount":"single","type":"entities"} 1'] = { +exports['mcfunction argument minecraft:entity Parse "@n[type=cow]" with {"amount":"single","type":"entities"} in version 1.21 1'] = { "node": { "type": "mcfunction:entity", "range": { @@ -10684,16 +11361,7 @@ exports['mcfunction argument minecraft:entity Parse "@n[type=cow]" with {"amount "hover": "**Performance**: šŸ˜…\n- `chunkLimited`: `false`\n- `dimensionLimited`: `false`\n- `playersOnly`: `false`\n- `typeLimited`: `false`" } }, - "errors": [ - { - "range": { - "start": 0, - "end": 2 - }, - "message": "Invalid entity selector: ā€œ@nā€", - "severity": 3 - } - ] + "errors": [] } exports['mcfunction argument minecraft:entity Parse "@r" with {"amount":"single","type":"players"} 1'] = { diff --git a/packages/java-edition/test/mcfunction/parser/argument.spec.ts b/packages/java-edition/test/mcfunction/parser/argument.spec.ts index 5aa1c159c..862a36b84 100644 --- a/packages/java-edition/test/mcfunction/parser/argument.spec.ts +++ b/packages/java-edition/test/mcfunction/parser/argument.spec.ts @@ -102,6 +102,15 @@ const Suites: Partial< '@n[distance=..5]', ], }, + { + properties: { amount: 'single', type: 'entities' }, + content: [ + '@n', + '@n[type=cow]', + '@n[distance=..5]', + ], + version: '1.21', + }, { properties: { amount: 'single', type: 'players' }, content: [