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/__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..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 @@ -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/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 93d9909aa..862a36b84 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': [ @@ -99,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: [ @@ -198,7 +210,19 @@ 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': [ @@ -298,26 +322,29 @@ 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 = '1.15' } of cases) { const treeNode: ArgumentTreeNode = { type: 'argument', parser: parserName as any, properties, } + const project = mockProjectData({ ctx: { loadedVersion: version } }) + 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 = version !== '1.15' + ? ` in version ${version}` + : '' + const itTitle = `Parse "${ + showWhitespaceGlyph(string) + }"${propertiesString}${versionString}` it(itTitle, () => { snapshotWithUri({ specName: `mcfunction argument ${parserName} ${itTitle}`, @@ -329,7 +356,7 @@ describe('mcfunction argument parser', () => { import.meta.url, ), value: testParser(argument(treeNode)!, string, { - project: { meta }, + project, removeTopLevelChildren: RemoveExtraChildren.has( parserName, ),