From 454fc0dce3ff5d3e9a5ea618ab4e6037e6934e55 Mon Sep 17 00:00:00 2001 From: Misode Date: Thu, 21 Nov 2024 22:49:34 +0100 Subject: [PATCH 1/2] Parse * wildcard score holder separately from fake players --- .../java-edition/src/mcfunction/node/argument.ts | 3 ++- .../src/mcfunction/parser/argument.ts | 15 ++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/java-edition/src/mcfunction/node/argument.ts b/packages/java-edition/src/mcfunction/node/argument.ts index fb9020267..75fd59180 100644 --- a/packages/java-edition/src/mcfunction/node/argument.ts +++ b/packages/java-edition/src/mcfunction/node/argument.ts @@ -533,9 +533,10 @@ export namespace ParticleNode { export interface ScoreHolderNode extends core.AstNode { type: 'mcfunction:score_holder' - children: [core.SymbolNode | EntitySelectorNode] + children: [core.LiteralNode | core.SymbolNode | EntitySelectorNode] fakeName?: core.SymbolNode selector?: EntitySelectorNode + wildcard?: core.LiteralNode } export namespace ScoreHolderNode { export function mock(range: core.RangeLike): ScoreHolderNode { diff --git a/packages/java-edition/src/mcfunction/parser/argument.ts b/packages/java-edition/src/mcfunction/parser/argument.ts index f27212587..11f94d094 100644 --- a/packages/java-edition/src/mcfunction/parser/argument.ts +++ b/packages/java-edition/src/mcfunction/parser/argument.ts @@ -1353,10 +1353,13 @@ export function scoreHolder( usageType: core.SymbolUsageType, amount: 'multiple' | 'single', ): core.Parser { - return core.map( - core.select([{ predicate: (src) => src.peek() === '@', parser: selector() }, { - parser: scoreHolderFakeName(usageType), - }]), + return core.map( + core.select([ + // Technically score holders can start with *, but this doesn't account for it + { prefix: '*', parser: core.literal('*') }, + { prefix: '@', parser: selector() }, + { parser: scoreHolderFakeName(usageType) }, + ]), (res, _src, ctx) => { const ans: ScoreHolderNode = { type: 'mcfunction:score_holder', @@ -1366,8 +1369,10 @@ export function scoreHolder( if (core.SymbolNode.is(res)) { ans.fakeName = res - } else { + } else if (EntitySelectorNode.is(res)) { ans.selector = res + } else { + ans.wildcard = res } if (amount === 'single' && ans.selector && !ans.selector.single) { From 02d61b538e6a7fc371fda1e71e08b3feee40c30b Mon Sep 17 00:00:00 2001 From: Misode Date: Thu, 21 Nov 2024 22:54:08 +0100 Subject: [PATCH 2/2] Update test snapshot --- .../parser/argument/minecraftScoreHolder.spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/__snapshots__/packages/java-edition/test-out/mcfunction/parser/argument/minecraftScoreHolder.spec.js b/__snapshots__/packages/java-edition/test-out/mcfunction/parser/argument/minecraftScoreHolder.spec.js index f562764a7..08dc833cd 100644 --- a/__snapshots__/packages/java-edition/test-out/mcfunction/parser/argument/minecraftScoreHolder.spec.js +++ b/__snapshots__/packages/java-edition/test-out/mcfunction/parser/argument/minecraftScoreHolder.spec.js @@ -5,8 +5,8 @@ exports['mcfunction argument minecraft:score_holder Parse "*" with {"amount":"mu "start": 0, "end": 1 }, - "fakeName": { - "type": "symbol", + "wildcard": { + "type": "literal", "range": { "start": 0, "end": 1 @@ -24,8 +24,8 @@ exports['mcfunction argument minecraft:score_holder Parse "*" with {"amount":"si "start": 0, "end": 1 }, - "fakeName": { - "type": "symbol", + "wildcard": { + "type": "literal", "range": { "start": 0, "end": 1