@spyglassmc/java-edition 0.1.3 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/binder/index.d.ts +1 -1
- package/lib/binder/index.js +11 -17
- package/lib/common/index.js +6 -33
- package/lib/dependency/common.js +6 -9
- package/lib/dependency/index.d.ts +6 -8
- package/lib/dependency/index.js +34 -59
- package/lib/dependency/mcmeta.d.ts +2 -2
- package/lib/dependency/mcmeta.js +8 -37
- package/lib/index.d.ts +3 -3
- package/lib/index.js +21 -48
- package/lib/json/checker/data/advancement.d.ts +13 -13
- package/lib/json/checker/data/advancement.js +263 -266
- package/lib/json/checker/data/biome.d.ts +3 -3
- package/lib/json/checker/data/biome.js +98 -101
- package/lib/json/checker/data/common.d.ts +1 -1
- package/lib/json/checker/data/common.js +145 -152
- package/lib/json/checker/data/dimension.d.ts +3 -3
- package/lib/json/checker/data/dimension.js +148 -151
- package/lib/json/checker/data/feature.d.ts +8 -8
- package/lib/json/checker/data/feature.js +370 -373
- package/lib/json/checker/data/index.d.ts +2 -2
- package/lib/json/checker/data/index.js +36 -39
- package/lib/json/checker/data/loot_table.d.ts +7 -7
- package/lib/json/checker/data/loot_table.js +125 -128
- package/lib/json/checker/data/recipe.d.ts +1 -1
- package/lib/json/checker/data/recipe.js +25 -28
- package/lib/json/checker/data/structure.d.ts +7 -7
- package/lib/json/checker/data/structure.js +80 -83
- package/lib/json/checker/data/tag.d.ts +6 -6
- package/lib/json/checker/data/tag.js +23 -26
- package/lib/json/checker/data/text_component.d.ts +1 -1
- package/lib/json/checker/data/text_component.js +61 -64
- package/lib/json/checker/index.js +14 -19
- package/lib/json/checker/util/advancement.d.ts +1 -1
- package/lib/json/checker/util/advancement.js +6 -10
- package/lib/json/checker/util/block_states.d.ts +1 -1
- package/lib/json/checker/util/block_states.js +25 -53
- package/lib/json/checker/util/color.d.ts +1 -1
- package/lib/json/checker/util/color.js +24 -29
- package/lib/json/checker/util/index.d.ts +7 -7
- package/lib/json/checker/util/index.js +7 -23
- package/lib/json/checker/util/nbt.d.ts +1 -1
- package/lib/json/checker/util/nbt.js +23 -28
- package/lib/json/checker/util/recipe.d.ts +1 -1
- package/lib/json/checker/util/recipe.js +4 -8
- package/lib/json/checker/util/uuid.d.ts +1 -1
- package/lib/json/checker/util/uuid.js +4 -7
- package/lib/json/checker/util/version.d.ts +2 -2
- package/lib/json/checker/util/version.js +7 -13
- package/lib/json/index.d.ts +1 -1
- package/lib/json/index.js +4 -31
- package/lib/mcfunction/checker/index.d.ts +1 -1
- package/lib/mcfunction/checker/index.js +24 -53
- package/lib/mcfunction/colorizer/index.d.ts +1 -1
- package/lib/mcfunction/colorizer/index.js +6 -35
- package/lib/mcfunction/common/index.js +7 -33
- package/lib/mcfunction/completer/argument.js +93 -120
- package/lib/mcfunction/completer/index.d.ts +1 -1
- package/lib/mcfunction/completer/index.js +1 -17
- package/lib/mcfunction/index.d.ts +5 -5
- package/lib/mcfunction/index.js +16 -43
- package/lib/mcfunction/inlayHintProvider.js +3 -30
- package/lib/mcfunction/node/argument.d.ts +7 -7
- package/lib/mcfunction/node/argument.js +38 -63
- package/lib/mcfunction/node/index.d.ts +1 -1
- package/lib/mcfunction/node/index.js +1 -17
- package/lib/mcfunction/parser/argument.d.ts +1 -1
- package/lib/mcfunction/parser/argument.js +72 -100
- package/lib/mcfunction/parser/index.d.ts +1 -1
- package/lib/mcfunction/parser/index.js +1 -17
- package/lib/mcfunction/signatureHelpProvider.js +3 -30
- package/lib/mcfunction/tree/argument.js +1 -2
- package/lib/mcfunction/tree/index.d.ts +1 -1
- package/lib/mcfunction/tree/index.js +1 -17
- package/lib/mcfunction/tree/patch.d.ts +1 -1
- package/lib/mcfunction/tree/patch.js +5 -9
- package/package.json +8 -7
|
@@ -1,38 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.team = exports.tag = exports.scoreHolderFakeName = exports.particle = exports.component = exports.blockPredicate = exports.argument = void 0;
|
|
27
|
-
const core = __importStar(require("@spyglassmc/core"));
|
|
28
|
-
const core_1 = require("@spyglassmc/core");
|
|
29
|
-
const json = __importStar(require("@spyglassmc/json"));
|
|
30
|
-
const locales_1 = require("@spyglassmc/locales");
|
|
31
|
-
const mcf = __importStar(require("@spyglassmc/mcfunction"));
|
|
32
|
-
const nbt = __importStar(require("@spyglassmc/nbt"));
|
|
33
|
-
const dependency_1 = require("../../dependency");
|
|
34
|
-
const common_1 = require("../common");
|
|
35
|
-
const node_1 = require("../node");
|
|
1
|
+
import * as core from '@spyglassmc/core';
|
|
2
|
+
import { sequence } from '@spyglassmc/core';
|
|
3
|
+
import * as json from '@spyglassmc/json';
|
|
4
|
+
import { localeQuote, localize } from '@spyglassmc/locales';
|
|
5
|
+
import * as mcf from '@spyglassmc/mcfunction';
|
|
6
|
+
import * as nbt from '@spyglassmc/nbt';
|
|
7
|
+
import { ReleaseVersion } from '../../dependency/index.js';
|
|
8
|
+
import { ColorArgumentValues, EntityAnchorArgumentValues, ItemSlotArgumentValues, OperationArgumentValues, ScoreboardSlotArgumentValues, SwizzleArgumentValues } from '../common/index.js';
|
|
9
|
+
import { BlockStatesNode, EntitySelectorArgumentsNode, EntitySelectorAtVariable, EntitySelectorAtVariables, EntitySelectorNode, ObjectiveCriteriaNode, TimeNode } from '../node/index.js';
|
|
36
10
|
const IntegerPattern = /^-?\d+$/;
|
|
37
11
|
/**
|
|
38
12
|
* A combination of:
|
|
@@ -61,13 +35,13 @@ const ObjectiveMaxLength = 16;
|
|
|
61
35
|
const PlayerNameMaxLength = 16;
|
|
62
36
|
function shouldValidateLength(ctx) {
|
|
63
37
|
const release = ctx.project['loadedVersion'];
|
|
64
|
-
return !release ||
|
|
38
|
+
return !release || ReleaseVersion.cmp(release, '1.18') < 0;
|
|
65
39
|
}
|
|
66
40
|
/**
|
|
67
41
|
* @returns The parser for the specified argument tree node. All argument parsers used in the `mcfunction` package
|
|
68
42
|
* fail on empty input.
|
|
69
43
|
*/
|
|
70
|
-
const argument = (rawTreeNode) => {
|
|
44
|
+
export const argument = (rawTreeNode) => {
|
|
71
45
|
const treeNode = rawTreeNode;
|
|
72
46
|
const wrap = (parser) => core.failOnEmpty(core.stopBefore(parser, '\r', '\n'));
|
|
73
47
|
switch (treeNode.parser) {
|
|
@@ -92,15 +66,15 @@ const argument = (rawTreeNode) => {
|
|
|
92
66
|
return wrap(greedyString);
|
|
93
67
|
}
|
|
94
68
|
case 'minecraft:angle':
|
|
95
|
-
return wrap(core.validate(coordinate(), res => res.notation !== '^',
|
|
69
|
+
return wrap(core.validate(coordinate(), res => res.notation !== '^', localize('mcfunction.parser.vector.local-disallowed')));
|
|
96
70
|
case 'minecraft:block_pos':
|
|
97
71
|
return wrap(vector({ dimension: 3, integersOnly: true }));
|
|
98
72
|
case 'minecraft:block_predicate':
|
|
99
|
-
return wrap(
|
|
73
|
+
return wrap(blockPredicate);
|
|
100
74
|
case 'minecraft:block_state':
|
|
101
75
|
return wrap(blockState);
|
|
102
76
|
case 'minecraft:color':
|
|
103
|
-
return wrap(core.map(core.literal(...
|
|
77
|
+
return wrap(core.map(core.literal(...ColorArgumentValues), res => ({
|
|
104
78
|
...res,
|
|
105
79
|
color: core.Color.NamedColors.has(res.value)
|
|
106
80
|
? core.Color.fromCompositeInt(core.Color.NamedColors.get(res.value))
|
|
@@ -109,7 +83,7 @@ const argument = (rawTreeNode) => {
|
|
|
109
83
|
case 'minecraft:column_pos':
|
|
110
84
|
return wrap(vector({ dimension: 2, integersOnly: true }));
|
|
111
85
|
case 'minecraft:component':
|
|
112
|
-
return wrap(
|
|
86
|
+
return wrap(component);
|
|
113
87
|
case 'minecraft:dimension':
|
|
114
88
|
return wrap(core.resourceLocation({
|
|
115
89
|
category: 'dimension',
|
|
@@ -117,7 +91,7 @@ const argument = (rawTreeNode) => {
|
|
|
117
91
|
case 'minecraft:entity':
|
|
118
92
|
return wrap(entity(treeNode.properties.amount, treeNode.properties.type));
|
|
119
93
|
case 'minecraft:entity_anchor':
|
|
120
|
-
return wrap(core.literal(...
|
|
94
|
+
return wrap(core.literal(...EntityAnchorArgumentValues));
|
|
121
95
|
case 'minecraft:entity_summon':
|
|
122
96
|
return wrap(core.resourceLocation({
|
|
123
97
|
category: 'entity_type',
|
|
@@ -140,7 +114,7 @@ const argument = (rawTreeNode) => {
|
|
|
140
114
|
case 'minecraft:item_predicate':
|
|
141
115
|
return wrap(itemPredicate);
|
|
142
116
|
case 'minecraft:item_slot':
|
|
143
|
-
return wrap(core.literal(...
|
|
117
|
+
return wrap(core.literal(...ItemSlotArgumentValues));
|
|
144
118
|
case 'minecraft:item_stack':
|
|
145
119
|
return wrap(itemStack);
|
|
146
120
|
case 'minecraft:message':
|
|
@@ -163,11 +137,11 @@ const argument = (rawTreeNode) => {
|
|
|
163
137
|
return wrap(objectiveCriteria);
|
|
164
138
|
case 'minecraft:operation':
|
|
165
139
|
return wrap(core.literal({
|
|
166
|
-
pool:
|
|
140
|
+
pool: OperationArgumentValues,
|
|
167
141
|
colorTokenType: 'operator',
|
|
168
142
|
}));
|
|
169
143
|
case 'minecraft:particle':
|
|
170
|
-
return wrap(
|
|
144
|
+
return wrap(particle);
|
|
171
145
|
case 'minecraft:resource':
|
|
172
146
|
case 'minecraft:resource_or_tag':
|
|
173
147
|
return wrap(core.resourceLocation({
|
|
@@ -186,9 +160,9 @@ const argument = (rawTreeNode) => {
|
|
|
186
160
|
case 'minecraft:scoreboard_slot':
|
|
187
161
|
// `BELOWNAME` and `sidebar.team.r--.+++e----__d` are also legal slots.
|
|
188
162
|
// But I do not want to spend time supporting them.
|
|
189
|
-
return wrap(core.literal(...
|
|
163
|
+
return wrap(core.literal(...ScoreboardSlotArgumentValues));
|
|
190
164
|
case 'minecraft:swizzle':
|
|
191
|
-
return wrap(core.literal(...
|
|
165
|
+
return wrap(core.literal(...SwizzleArgumentValues));
|
|
192
166
|
case 'minecraft:team':
|
|
193
167
|
return wrap(team(core.SymbolUsageType.is(treeNode.properties?.usageType)
|
|
194
168
|
? treeNode.properties?.usageType
|
|
@@ -208,7 +182,6 @@ const argument = (rawTreeNode) => {
|
|
|
208
182
|
return undefined;
|
|
209
183
|
}
|
|
210
184
|
};
|
|
211
|
-
exports.argument = argument;
|
|
212
185
|
function block(isPredicate) {
|
|
213
186
|
return core.map(core.sequence([
|
|
214
187
|
core.resourceLocation({ category: 'block', allowTag: isPredicate }),
|
|
@@ -236,15 +209,15 @@ function block(isPredicate) {
|
|
|
236
209
|
range: res.range,
|
|
237
210
|
children: res.children,
|
|
238
211
|
id: res.children.find(core.ResourceLocationNode.is),
|
|
239
|
-
states: res.children.find(
|
|
212
|
+
states: res.children.find(BlockStatesNode.is),
|
|
240
213
|
nbt: res.children.find(nbt.NbtCompoundNode.is),
|
|
241
214
|
};
|
|
242
215
|
return ans;
|
|
243
216
|
});
|
|
244
217
|
}
|
|
245
218
|
const blockState = block(false);
|
|
246
|
-
|
|
247
|
-
|
|
219
|
+
export const blockPredicate = block(true);
|
|
220
|
+
export const component = json.parser.json();
|
|
248
221
|
function double(min = DoubleMin, max = DoubleMax) {
|
|
249
222
|
return core.float({
|
|
250
223
|
pattern: FloatPattern,
|
|
@@ -298,7 +271,7 @@ function coordinate(integerOnly = false) {
|
|
|
298
271
|
function entity(amount, type) {
|
|
299
272
|
return core.map(core.select([
|
|
300
273
|
{
|
|
301
|
-
predicate: src =>
|
|
274
|
+
predicate: src => EntitySelectorAtVariable.is(src.peek(2)),
|
|
302
275
|
parser: selector(),
|
|
303
276
|
},
|
|
304
277
|
{
|
|
@@ -316,17 +289,17 @@ function entity(amount, type) {
|
|
|
316
289
|
if (core.StringNode.is(res)) {
|
|
317
290
|
ans.playerName = res;
|
|
318
291
|
}
|
|
319
|
-
else if (
|
|
292
|
+
else if (EntitySelectorNode.is(res)) {
|
|
320
293
|
ans.selector = res;
|
|
321
294
|
}
|
|
322
295
|
else {
|
|
323
296
|
ans.uuid = res;
|
|
324
297
|
}
|
|
325
298
|
if (amount === 'single' && ans.selector && !ans.selector.single) {
|
|
326
|
-
ctx.err.report(
|
|
299
|
+
ctx.err.report(localize('mcfunction.parser.entity-selector.multiple-disallowed'), ans);
|
|
327
300
|
}
|
|
328
301
|
if (type === 'players' && (ans.uuid || (ans.selector && !ans.selector.playersOnly && !ans.selector.currentEntity))) {
|
|
329
|
-
ctx.err.report(
|
|
302
|
+
ctx.err.report(localize('mcfunction.parser.entity-selector.entities-disallowed'), ans);
|
|
330
303
|
}
|
|
331
304
|
return ans;
|
|
332
305
|
});
|
|
@@ -358,16 +331,16 @@ const message = (src, ctx) => {
|
|
|
358
331
|
children: [],
|
|
359
332
|
};
|
|
360
333
|
while (src.canReadInLine()) {
|
|
361
|
-
if (
|
|
334
|
+
if (EntitySelectorAtVariable.is(src.peek(2))) {
|
|
362
335
|
ans.children.push(selector()(src, ctx));
|
|
363
336
|
}
|
|
364
337
|
else {
|
|
365
|
-
ans.children.push(core.stopBefore(greedyString, ...
|
|
338
|
+
ans.children.push(core.stopBefore(greedyString, ...EntitySelectorAtVariables)(src, ctx));
|
|
366
339
|
}
|
|
367
340
|
}
|
|
368
341
|
return ans;
|
|
369
342
|
};
|
|
370
|
-
|
|
343
|
+
export const particle = (() => {
|
|
371
344
|
const sep = core.map(mcf.sep, () => []);
|
|
372
345
|
const vec = vector({ dimension: 3 });
|
|
373
346
|
const color = core.map(vec, res => ({
|
|
@@ -382,14 +355,15 @@ exports.particle = (() => {
|
|
|
382
355
|
const map = {
|
|
383
356
|
block: blockState,
|
|
384
357
|
block_marker: blockState,
|
|
385
|
-
dust:
|
|
386
|
-
dust_color_transition:
|
|
358
|
+
dust: sequence([color, float()], sep),
|
|
359
|
+
dust_color_transition: sequence([color, float(), color], sep),
|
|
387
360
|
falling_dust: blockState,
|
|
388
361
|
item: itemStack,
|
|
389
362
|
sculk_charge: float(),
|
|
390
|
-
|
|
363
|
+
shriek: integer(),
|
|
364
|
+
vibration: sequence([vec, integer()], sep),
|
|
391
365
|
};
|
|
392
|
-
return core.map(
|
|
366
|
+
return core.map(sequence([
|
|
393
367
|
core.resourceLocation({ category: 'particle_type' }),
|
|
394
368
|
{
|
|
395
369
|
get: res => {
|
|
@@ -434,7 +408,7 @@ function range(type, min, max, cycleable) {
|
|
|
434
408
|
: [valueNodes[0].value, valueNodes[0].value],
|
|
435
409
|
};
|
|
436
410
|
if (!cycleable && ans.value[0] !== undefined && ans.value[1] !== undefined && ans.value[0] > ans.value[1]) {
|
|
437
|
-
ctx.err.report(
|
|
411
|
+
ctx.err.report(localize('mcfunction.parser.range.min>max', ans.value[0], ans.value[1]), res);
|
|
438
412
|
}
|
|
439
413
|
return ans;
|
|
440
414
|
});
|
|
@@ -451,7 +425,7 @@ function selector() {
|
|
|
451
425
|
let single;
|
|
452
426
|
let typeLimited;
|
|
453
427
|
return core.map(core.sequence([
|
|
454
|
-
core.failOnEmpty(core.literal({ pool:
|
|
428
|
+
core.failOnEmpty(core.literal({ pool: EntitySelectorAtVariables, colorTokenType: 'keyword' })),
|
|
455
429
|
{
|
|
456
430
|
get: res => {
|
|
457
431
|
const variable = core.LiteralNode.is(res.children?.[0]) ? res.children[0].value : undefined;
|
|
@@ -482,7 +456,7 @@ function selector() {
|
|
|
482
456
|
key: core.string({
|
|
483
457
|
...core.BrigadierStringOptions,
|
|
484
458
|
value: {
|
|
485
|
-
parser: core.literal({ pool: [...
|
|
459
|
+
parser: core.literal({ pool: [...EntitySelectorNode.ArgumentKeys], colorTokenType: 'property' }),
|
|
486
460
|
type: 'literal',
|
|
487
461
|
},
|
|
488
462
|
}),
|
|
@@ -529,7 +503,7 @@ function selector() {
|
|
|
529
503
|
end: '}',
|
|
530
504
|
}), (res, _, ctx) => {
|
|
531
505
|
if (hasKey(key.value)) {
|
|
532
|
-
ctx.err.report(
|
|
506
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
533
507
|
}
|
|
534
508
|
const ans = {
|
|
535
509
|
...res,
|
|
@@ -541,9 +515,9 @@ function selector() {
|
|
|
541
515
|
return core.map(range('float', 0), (res, _, ctx) => {
|
|
542
516
|
dimensionLimited = true;
|
|
543
517
|
// x, y, z, dx, dy, dz take precedence over distance, so we use ??= instead of = to ensure it won't override the result.
|
|
544
|
-
chunkLimited
|
|
518
|
+
chunkLimited ??= !playersOnly && res.value[1] !== undefined;
|
|
545
519
|
if (hasKey(key.value)) {
|
|
546
|
-
ctx.err.report(
|
|
520
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
547
521
|
}
|
|
548
522
|
return res;
|
|
549
523
|
});
|
|
@@ -557,7 +531,7 @@ function selector() {
|
|
|
557
531
|
})), (res, _, ctx) => {
|
|
558
532
|
playersOnly = true;
|
|
559
533
|
if (res.inverted ? hasNonInvertedKey(key.value) : hasKey(key.value)) {
|
|
560
|
-
ctx.err.report(
|
|
534
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
561
535
|
}
|
|
562
536
|
return res;
|
|
563
537
|
});
|
|
@@ -565,10 +539,10 @@ function selector() {
|
|
|
565
539
|
return core.map(integer(0), (res, _, ctx) => {
|
|
566
540
|
single = res.value <= 1;
|
|
567
541
|
if (hasKey(key.value)) {
|
|
568
|
-
ctx.err.report(
|
|
542
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
569
543
|
}
|
|
570
544
|
if (currentEntity) {
|
|
571
|
-
ctx.err.report(
|
|
545
|
+
ctx.err.report(localize('mcfunction.parser.entity-selector.arguments.not-applicable', localeQuote(key.value)), key);
|
|
572
546
|
}
|
|
573
547
|
return res;
|
|
574
548
|
});
|
|
@@ -576,14 +550,14 @@ function selector() {
|
|
|
576
550
|
return core.map(range('integer', 0), (res, _, ctx) => {
|
|
577
551
|
playersOnly = true;
|
|
578
552
|
if (hasKey(key.value)) {
|
|
579
|
-
ctx.err.report(
|
|
553
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
580
554
|
}
|
|
581
555
|
return res;
|
|
582
556
|
});
|
|
583
557
|
case 'name':
|
|
584
558
|
return core.map(invertable(core.brigadierString), (res, _, ctx) => {
|
|
585
559
|
if (res.inverted ? hasNonInvertedKey(key.value) : hasKey(key.value)) {
|
|
586
|
-
ctx.err.report(
|
|
560
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
587
561
|
}
|
|
588
562
|
return res;
|
|
589
563
|
});
|
|
@@ -604,7 +578,7 @@ function selector() {
|
|
|
604
578
|
end: '}',
|
|
605
579
|
}), (res, _, ctx) => {
|
|
606
580
|
if (hasKey(key.value)) {
|
|
607
|
-
ctx.err.report(
|
|
581
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
608
582
|
}
|
|
609
583
|
const ans = {
|
|
610
584
|
...res,
|
|
@@ -621,10 +595,10 @@ function selector() {
|
|
|
621
595
|
},
|
|
622
596
|
}), (res, _, ctx) => {
|
|
623
597
|
if (hasKey(key.value)) {
|
|
624
|
-
ctx.err.report(
|
|
598
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
625
599
|
}
|
|
626
600
|
if (currentEntity) {
|
|
627
|
-
ctx.err.report(
|
|
601
|
+
ctx.err.report(localize('mcfunction.parser.entity-selector.arguments.not-applicable', localeQuote(key.value)), key);
|
|
628
602
|
}
|
|
629
603
|
return res;
|
|
630
604
|
});
|
|
@@ -633,7 +607,7 @@ function selector() {
|
|
|
633
607
|
case 'team':
|
|
634
608
|
return core.map(invertable(team('reference', ['[', '=', ',', ']', '{', '}'])), (res, _, ctx) => {
|
|
635
609
|
if (res.inverted ? hasNonInvertedKey(key.value) : hasKey(key.value)) {
|
|
636
|
-
ctx.err.report(
|
|
610
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
637
611
|
}
|
|
638
612
|
return res;
|
|
639
613
|
});
|
|
@@ -641,10 +615,10 @@ function selector() {
|
|
|
641
615
|
return core.map(invertable(core.resourceLocation({ category: 'entity_type', allowTag: true })), (res, _, ctx) => {
|
|
642
616
|
if (typeLimited) {
|
|
643
617
|
if (hasKey(key.value)) {
|
|
644
|
-
ctx.err.report(
|
|
618
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
645
619
|
}
|
|
646
620
|
else {
|
|
647
|
-
ctx.err.report(
|
|
621
|
+
ctx.err.report(localize('mcfunction.parser.entity-selector.arguments.not-applicable', localeQuote(key.value)), key);
|
|
648
622
|
}
|
|
649
623
|
}
|
|
650
624
|
else if (!res.inverted && !res.value.isTag) {
|
|
@@ -661,7 +635,7 @@ function selector() {
|
|
|
661
635
|
return core.map(double(), (res, _, ctx) => {
|
|
662
636
|
dimensionLimited = true;
|
|
663
637
|
if (hasKey(key.value)) {
|
|
664
|
-
ctx.err.report(
|
|
638
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
665
639
|
}
|
|
666
640
|
return res;
|
|
667
641
|
});
|
|
@@ -672,7 +646,7 @@ function selector() {
|
|
|
672
646
|
dimensionLimited = true;
|
|
673
647
|
chunkLimited = !playersOnly;
|
|
674
648
|
if (hasKey(key.value)) {
|
|
675
|
-
ctx.err.report(
|
|
649
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
676
650
|
}
|
|
677
651
|
return res;
|
|
678
652
|
});
|
|
@@ -680,7 +654,7 @@ function selector() {
|
|
|
680
654
|
case 'y_rotation':
|
|
681
655
|
return core.map(range('float', undefined, undefined, true), (res, _, ctx) => {
|
|
682
656
|
if (hasKey(key.value)) {
|
|
683
|
-
ctx.err.report(
|
|
657
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
684
658
|
}
|
|
685
659
|
return res;
|
|
686
660
|
});
|
|
@@ -690,7 +664,7 @@ function selector() {
|
|
|
690
664
|
default:
|
|
691
665
|
// The key is unknown.
|
|
692
666
|
return (_src, ctx) => {
|
|
693
|
-
ctx.err.report(
|
|
667
|
+
ctx.err.report(localize('mcfunction.parser.entity-selector.arguments.unknown', localeQuote(key.value)), key);
|
|
694
668
|
return core.Failure;
|
|
695
669
|
};
|
|
696
670
|
}
|
|
@@ -715,7 +689,7 @@ function selector() {
|
|
|
715
689
|
range: res.range,
|
|
716
690
|
children: res.children,
|
|
717
691
|
variable: res.children.find(core.LiteralNode.is).value.slice(1),
|
|
718
|
-
arguments: res.children.find(
|
|
692
|
+
arguments: res.children.find(EntitySelectorArgumentsNode.is),
|
|
719
693
|
chunkLimited,
|
|
720
694
|
currentEntity,
|
|
721
695
|
dimensionLimited,
|
|
@@ -760,15 +734,15 @@ ${node.predicates.map(p => `- \`${p}\``).join('\n')}`;
|
|
|
760
734
|
}
|
|
761
735
|
return ans;
|
|
762
736
|
}
|
|
763
|
-
|
|
737
|
+
export const scoreHolderFakeName = validateLength(symbol('score_holder'), FakeNameMaxLength, 'mcfunction.parser.score_holder.fake-name.too-long');
|
|
764
738
|
function scoreHolder(amount) {
|
|
765
739
|
return core.map(core.select([
|
|
766
740
|
{
|
|
767
|
-
predicate: src =>
|
|
741
|
+
predicate: src => EntitySelectorAtVariable.is(src.peek(2)),
|
|
768
742
|
parser: selector(),
|
|
769
743
|
},
|
|
770
744
|
{
|
|
771
|
-
parser:
|
|
745
|
+
parser: scoreHolderFakeName,
|
|
772
746
|
},
|
|
773
747
|
]), (res, _src, ctx) => {
|
|
774
748
|
const ans = {
|
|
@@ -783,7 +757,7 @@ function scoreHolder(amount) {
|
|
|
783
757
|
ans.selector = res;
|
|
784
758
|
}
|
|
785
759
|
if (amount === 'single' && ans.selector && !ans.selector.single) {
|
|
786
|
-
ctx.err.report(
|
|
760
|
+
ctx.err.report(localize('mcfunction.parser.entity-selector.multiple-disallowed'), ans);
|
|
787
761
|
}
|
|
788
762
|
return ans;
|
|
789
763
|
});
|
|
@@ -801,7 +775,7 @@ const objectiveCriteria = core.map(core.any([
|
|
|
801
775
|
{
|
|
802
776
|
get: res => {
|
|
803
777
|
if (core.ResourceLocationNode.is(res.children[0])) {
|
|
804
|
-
const category =
|
|
778
|
+
const category = ObjectiveCriteriaNode.ComplexCategories.get(core.ResourceLocationNode.toString(res.children[0], 'short'));
|
|
805
779
|
if (category) {
|
|
806
780
|
return core.resourceLocation({ category, namespacePathSep: '.' });
|
|
807
781
|
}
|
|
@@ -810,7 +784,7 @@ const objectiveCriteria = core.map(core.any([
|
|
|
810
784
|
},
|
|
811
785
|
},
|
|
812
786
|
]),
|
|
813
|
-
core.literal(...
|
|
787
|
+
core.literal(...ObjectiveCriteriaNode.SimpleValues),
|
|
814
788
|
]), res => {
|
|
815
789
|
const ans = {
|
|
816
790
|
type: 'mcfunction:objective_criteria',
|
|
@@ -824,18 +798,16 @@ const objectiveCriteria = core.map(core.any([
|
|
|
824
798
|
}
|
|
825
799
|
return ans;
|
|
826
800
|
});
|
|
827
|
-
function tag(terminators = []) {
|
|
801
|
+
export function tag(terminators = []) {
|
|
828
802
|
return unquotableSymbol('tag', terminators);
|
|
829
803
|
}
|
|
830
|
-
|
|
831
|
-
function team(usageType, terminators = []) {
|
|
804
|
+
export function team(usageType, terminators = []) {
|
|
832
805
|
return unquotableSymbol({ category: 'team', usageType }, terminators);
|
|
833
806
|
}
|
|
834
|
-
exports.team = team;
|
|
835
807
|
function unquotableSymbol(options, terminators) {
|
|
836
808
|
return validateUnquotable(symbol(options, terminators));
|
|
837
809
|
}
|
|
838
|
-
const time = core.map(core.sequence([float(0, undefined), core.optional(core.failOnEmpty(core.literal(...
|
|
810
|
+
const time = core.map(core.sequence([float(0, undefined), core.optional(core.failOnEmpty(core.literal(...TimeNode.Units)))]), res => {
|
|
839
811
|
const valueNode = res.children.find(core.FloatNode.is);
|
|
840
812
|
const unitNode = res.children.find(core.LiteralNode.is);
|
|
841
813
|
const ans = {
|
|
@@ -881,7 +853,7 @@ const uuid = (src, ctx) => {
|
|
|
881
853
|
}
|
|
882
854
|
ans.range.end = src.cursor;
|
|
883
855
|
if (!isLegal) {
|
|
884
|
-
ctx.err.report(
|
|
856
|
+
ctx.err.report(localize('mcfunction.parser.uuid.invalid'), ans);
|
|
885
857
|
}
|
|
886
858
|
return ans;
|
|
887
859
|
};
|
|
@@ -892,7 +864,7 @@ function validateLength(parser, maxLength, localeKey) {
|
|
|
892
864
|
}
|
|
893
865
|
return core.map(parser, (res, _src, ctx) => {
|
|
894
866
|
if (res.value.length > maxLength) {
|
|
895
|
-
ctx.err.report(
|
|
867
|
+
ctx.err.report(localize(localeKey, maxLength), res);
|
|
896
868
|
}
|
|
897
869
|
return res;
|
|
898
870
|
})(src, ctx);
|
|
@@ -901,7 +873,7 @@ function validateLength(parser, maxLength, localeKey) {
|
|
|
901
873
|
function validateUnquotable(parser) {
|
|
902
874
|
return core.map(parser, (res, _src, ctx) => {
|
|
903
875
|
if (!res.value.match(core.BrigadierUnquotablePattern)) {
|
|
904
|
-
ctx.err.report(
|
|
876
|
+
ctx.err.report(localize('parser.string.illegal-brigadier', localeQuote(res.value)), res);
|
|
905
877
|
}
|
|
906
878
|
return res;
|
|
907
879
|
});
|
|
@@ -925,11 +897,11 @@ function vector(options) {
|
|
|
925
897
|
const coord = options.integersOnly ? coordinate(options.integersOnly)(src, ctx) : coordinate(options.integersOnly)(src, ctx);
|
|
926
898
|
ans.children.push(coord);
|
|
927
899
|
if ((ans.system === 1 /* CoordinateSystem.Local */) !== (coord.notation === '^')) {
|
|
928
|
-
ctx.err.report(
|
|
900
|
+
ctx.err.report(localize('mcfunction.parser.vector.mixed'), coord);
|
|
929
901
|
}
|
|
930
902
|
}
|
|
931
903
|
if (options.noLocal && ans.system === 1 /* CoordinateSystem.Local */) {
|
|
932
|
-
ctx.err.report(
|
|
904
|
+
ctx.err.report(localize('mcfunction.parser.vector.local-disallowed'), ans);
|
|
933
905
|
}
|
|
934
906
|
ans.range.end = src.cursor;
|
|
935
907
|
return ans;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './argument';
|
|
1
|
+
export * from './argument.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./argument"), exports);
|
|
1
|
+
export * from './argument.js';
|
|
18
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,36 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.signatureHelpProvider = void 0;
|
|
27
|
-
const core = __importStar(require("@spyglassmc/core"));
|
|
28
|
-
const mcf = __importStar(require("@spyglassmc/mcfunction"));
|
|
1
|
+
import * as core from '@spyglassmc/core';
|
|
2
|
+
import * as mcf from '@spyglassmc/mcfunction';
|
|
29
3
|
/**
|
|
30
4
|
* Only command options that can be satisfied by the current command node will be listed in `signatures`.
|
|
31
5
|
* Only parameters at and immediately after the `offset` will be listed in `parameters`.
|
|
32
6
|
*/
|
|
33
|
-
function signatureHelpProvider(commandTreeName) {
|
|
7
|
+
export function signatureHelpProvider(commandTreeName) {
|
|
34
8
|
const rootTreeNode = mcf.CommandTreeRegistry.instance.get(commandTreeName);
|
|
35
9
|
return (fileNode, ctx) => {
|
|
36
10
|
if (fileNode.children[0]?.type !== 'mcfunction:entry') {
|
|
@@ -78,7 +52,6 @@ function signatureHelpProvider(commandTreeName) {
|
|
|
78
52
|
return ans;
|
|
79
53
|
};
|
|
80
54
|
}
|
|
81
|
-
exports.signatureHelpProvider = signatureHelpProvider;
|
|
82
55
|
function getSelectedCommandNode(fileNode, offset) {
|
|
83
56
|
return core.AstNode.findChild(fileNode.children[0], offset, true);
|
|
84
57
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './argument';
|
|
1
|
+
export * from './argument.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./argument"), exports);
|
|
1
|
+
export * from './argument.js';
|
|
18
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { PartialRootTreeNode } from '@spyglassmc/mcfunction';
|
|
2
|
-
import { ReleaseVersion } from '../../dependency';
|
|
2
|
+
import { ReleaseVersion } from '../../dependency/index.js';
|
|
3
3
|
export declare function getPatch(release: ReleaseVersion): PartialRootTreeNode;
|
|
4
4
|
//# sourceMappingURL=patch.d.ts.map
|