@spyglassmc/java-edition 0.1.3 → 0.2.0
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 +4 -32
- package/lib/dependency/common.js +6 -9
- package/lib/dependency/index.d.ts +6 -6
- package/lib/dependency/index.js +18 -49
- 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 +259 -262
- 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 +369 -372
- 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.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 +4 -8
- package/lib/json/checker/util/block_states.d.ts +1 -1
- package/lib/json/checker/util/block_states.js +21 -49
- package/lib/json/checker/util/color.d.ts +1 -1
- package/lib/json/checker/util/color.js +20 -25
- 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 +17 -22
- 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 +92 -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 +3 -3
- package/lib/mcfunction/node/argument.js +37 -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 +71 -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,14 @@ 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
|
-
vibration:
|
|
363
|
+
vibration: sequence([vec, vec, integer()], sep),
|
|
391
364
|
};
|
|
392
|
-
return core.map(
|
|
365
|
+
return core.map(sequence([
|
|
393
366
|
core.resourceLocation({ category: 'particle_type' }),
|
|
394
367
|
{
|
|
395
368
|
get: res => {
|
|
@@ -434,7 +407,7 @@ function range(type, min, max, cycleable) {
|
|
|
434
407
|
: [valueNodes[0].value, valueNodes[0].value],
|
|
435
408
|
};
|
|
436
409
|
if (!cycleable && ans.value[0] !== undefined && ans.value[1] !== undefined && ans.value[0] > ans.value[1]) {
|
|
437
|
-
ctx.err.report(
|
|
410
|
+
ctx.err.report(localize('mcfunction.parser.range.min>max', ans.value[0], ans.value[1]), res);
|
|
438
411
|
}
|
|
439
412
|
return ans;
|
|
440
413
|
});
|
|
@@ -451,7 +424,7 @@ function selector() {
|
|
|
451
424
|
let single;
|
|
452
425
|
let typeLimited;
|
|
453
426
|
return core.map(core.sequence([
|
|
454
|
-
core.failOnEmpty(core.literal({ pool:
|
|
427
|
+
core.failOnEmpty(core.literal({ pool: EntitySelectorAtVariables, colorTokenType: 'keyword' })),
|
|
455
428
|
{
|
|
456
429
|
get: res => {
|
|
457
430
|
const variable = core.LiteralNode.is(res.children?.[0]) ? res.children[0].value : undefined;
|
|
@@ -482,7 +455,7 @@ function selector() {
|
|
|
482
455
|
key: core.string({
|
|
483
456
|
...core.BrigadierStringOptions,
|
|
484
457
|
value: {
|
|
485
|
-
parser: core.literal({ pool: [...
|
|
458
|
+
parser: core.literal({ pool: [...EntitySelectorNode.ArgumentKeys], colorTokenType: 'property' }),
|
|
486
459
|
type: 'literal',
|
|
487
460
|
},
|
|
488
461
|
}),
|
|
@@ -529,7 +502,7 @@ function selector() {
|
|
|
529
502
|
end: '}',
|
|
530
503
|
}), (res, _, ctx) => {
|
|
531
504
|
if (hasKey(key.value)) {
|
|
532
|
-
ctx.err.report(
|
|
505
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
533
506
|
}
|
|
534
507
|
const ans = {
|
|
535
508
|
...res,
|
|
@@ -541,9 +514,9 @@ function selector() {
|
|
|
541
514
|
return core.map(range('float', 0), (res, _, ctx) => {
|
|
542
515
|
dimensionLimited = true;
|
|
543
516
|
// 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
|
|
517
|
+
chunkLimited ??= !playersOnly && res.value[1] !== undefined;
|
|
545
518
|
if (hasKey(key.value)) {
|
|
546
|
-
ctx.err.report(
|
|
519
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
547
520
|
}
|
|
548
521
|
return res;
|
|
549
522
|
});
|
|
@@ -557,7 +530,7 @@ function selector() {
|
|
|
557
530
|
})), (res, _, ctx) => {
|
|
558
531
|
playersOnly = true;
|
|
559
532
|
if (res.inverted ? hasNonInvertedKey(key.value) : hasKey(key.value)) {
|
|
560
|
-
ctx.err.report(
|
|
533
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
561
534
|
}
|
|
562
535
|
return res;
|
|
563
536
|
});
|
|
@@ -565,10 +538,10 @@ function selector() {
|
|
|
565
538
|
return core.map(integer(0), (res, _, ctx) => {
|
|
566
539
|
single = res.value <= 1;
|
|
567
540
|
if (hasKey(key.value)) {
|
|
568
|
-
ctx.err.report(
|
|
541
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
569
542
|
}
|
|
570
543
|
if (currentEntity) {
|
|
571
|
-
ctx.err.report(
|
|
544
|
+
ctx.err.report(localize('mcfunction.parser.entity-selector.arguments.not-applicable', localeQuote(key.value)), key);
|
|
572
545
|
}
|
|
573
546
|
return res;
|
|
574
547
|
});
|
|
@@ -576,14 +549,14 @@ function selector() {
|
|
|
576
549
|
return core.map(range('integer', 0), (res, _, ctx) => {
|
|
577
550
|
playersOnly = true;
|
|
578
551
|
if (hasKey(key.value)) {
|
|
579
|
-
ctx.err.report(
|
|
552
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
580
553
|
}
|
|
581
554
|
return res;
|
|
582
555
|
});
|
|
583
556
|
case 'name':
|
|
584
557
|
return core.map(invertable(core.brigadierString), (res, _, ctx) => {
|
|
585
558
|
if (res.inverted ? hasNonInvertedKey(key.value) : hasKey(key.value)) {
|
|
586
|
-
ctx.err.report(
|
|
559
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
587
560
|
}
|
|
588
561
|
return res;
|
|
589
562
|
});
|
|
@@ -604,7 +577,7 @@ function selector() {
|
|
|
604
577
|
end: '}',
|
|
605
578
|
}), (res, _, ctx) => {
|
|
606
579
|
if (hasKey(key.value)) {
|
|
607
|
-
ctx.err.report(
|
|
580
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
608
581
|
}
|
|
609
582
|
const ans = {
|
|
610
583
|
...res,
|
|
@@ -621,10 +594,10 @@ function selector() {
|
|
|
621
594
|
},
|
|
622
595
|
}), (res, _, ctx) => {
|
|
623
596
|
if (hasKey(key.value)) {
|
|
624
|
-
ctx.err.report(
|
|
597
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
625
598
|
}
|
|
626
599
|
if (currentEntity) {
|
|
627
|
-
ctx.err.report(
|
|
600
|
+
ctx.err.report(localize('mcfunction.parser.entity-selector.arguments.not-applicable', localeQuote(key.value)), key);
|
|
628
601
|
}
|
|
629
602
|
return res;
|
|
630
603
|
});
|
|
@@ -633,7 +606,7 @@ function selector() {
|
|
|
633
606
|
case 'team':
|
|
634
607
|
return core.map(invertable(team('reference', ['[', '=', ',', ']', '{', '}'])), (res, _, ctx) => {
|
|
635
608
|
if (res.inverted ? hasNonInvertedKey(key.value) : hasKey(key.value)) {
|
|
636
|
-
ctx.err.report(
|
|
609
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
637
610
|
}
|
|
638
611
|
return res;
|
|
639
612
|
});
|
|
@@ -641,10 +614,10 @@ function selector() {
|
|
|
641
614
|
return core.map(invertable(core.resourceLocation({ category: 'entity_type', allowTag: true })), (res, _, ctx) => {
|
|
642
615
|
if (typeLimited) {
|
|
643
616
|
if (hasKey(key.value)) {
|
|
644
|
-
ctx.err.report(
|
|
617
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
645
618
|
}
|
|
646
619
|
else {
|
|
647
|
-
ctx.err.report(
|
|
620
|
+
ctx.err.report(localize('mcfunction.parser.entity-selector.arguments.not-applicable', localeQuote(key.value)), key);
|
|
648
621
|
}
|
|
649
622
|
}
|
|
650
623
|
else if (!res.inverted && !res.value.isTag) {
|
|
@@ -661,7 +634,7 @@ function selector() {
|
|
|
661
634
|
return core.map(double(), (res, _, ctx) => {
|
|
662
635
|
dimensionLimited = true;
|
|
663
636
|
if (hasKey(key.value)) {
|
|
664
|
-
ctx.err.report(
|
|
637
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
665
638
|
}
|
|
666
639
|
return res;
|
|
667
640
|
});
|
|
@@ -672,7 +645,7 @@ function selector() {
|
|
|
672
645
|
dimensionLimited = true;
|
|
673
646
|
chunkLimited = !playersOnly;
|
|
674
647
|
if (hasKey(key.value)) {
|
|
675
|
-
ctx.err.report(
|
|
648
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
676
649
|
}
|
|
677
650
|
return res;
|
|
678
651
|
});
|
|
@@ -680,7 +653,7 @@ function selector() {
|
|
|
680
653
|
case 'y_rotation':
|
|
681
654
|
return core.map(range('float', undefined, undefined, true), (res, _, ctx) => {
|
|
682
655
|
if (hasKey(key.value)) {
|
|
683
|
-
ctx.err.report(
|
|
656
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
684
657
|
}
|
|
685
658
|
return res;
|
|
686
659
|
});
|
|
@@ -690,7 +663,7 @@ function selector() {
|
|
|
690
663
|
default:
|
|
691
664
|
// The key is unknown.
|
|
692
665
|
return (_src, ctx) => {
|
|
693
|
-
ctx.err.report(
|
|
666
|
+
ctx.err.report(localize('mcfunction.parser.entity-selector.arguments.unknown', localeQuote(key.value)), key);
|
|
694
667
|
return core.Failure;
|
|
695
668
|
};
|
|
696
669
|
}
|
|
@@ -715,7 +688,7 @@ function selector() {
|
|
|
715
688
|
range: res.range,
|
|
716
689
|
children: res.children,
|
|
717
690
|
variable: res.children.find(core.LiteralNode.is).value.slice(1),
|
|
718
|
-
arguments: res.children.find(
|
|
691
|
+
arguments: res.children.find(EntitySelectorArgumentsNode.is),
|
|
719
692
|
chunkLimited,
|
|
720
693
|
currentEntity,
|
|
721
694
|
dimensionLimited,
|
|
@@ -760,15 +733,15 @@ ${node.predicates.map(p => `- \`${p}\``).join('\n')}`;
|
|
|
760
733
|
}
|
|
761
734
|
return ans;
|
|
762
735
|
}
|
|
763
|
-
|
|
736
|
+
export const scoreHolderFakeName = validateLength(symbol('score_holder'), FakeNameMaxLength, 'mcfunction.parser.score_holder.fake-name.too-long');
|
|
764
737
|
function scoreHolder(amount) {
|
|
765
738
|
return core.map(core.select([
|
|
766
739
|
{
|
|
767
|
-
predicate: src =>
|
|
740
|
+
predicate: src => EntitySelectorAtVariable.is(src.peek(2)),
|
|
768
741
|
parser: selector(),
|
|
769
742
|
},
|
|
770
743
|
{
|
|
771
|
-
parser:
|
|
744
|
+
parser: scoreHolderFakeName,
|
|
772
745
|
},
|
|
773
746
|
]), (res, _src, ctx) => {
|
|
774
747
|
const ans = {
|
|
@@ -783,7 +756,7 @@ function scoreHolder(amount) {
|
|
|
783
756
|
ans.selector = res;
|
|
784
757
|
}
|
|
785
758
|
if (amount === 'single' && ans.selector && !ans.selector.single) {
|
|
786
|
-
ctx.err.report(
|
|
759
|
+
ctx.err.report(localize('mcfunction.parser.entity-selector.multiple-disallowed'), ans);
|
|
787
760
|
}
|
|
788
761
|
return ans;
|
|
789
762
|
});
|
|
@@ -801,7 +774,7 @@ const objectiveCriteria = core.map(core.any([
|
|
|
801
774
|
{
|
|
802
775
|
get: res => {
|
|
803
776
|
if (core.ResourceLocationNode.is(res.children[0])) {
|
|
804
|
-
const category =
|
|
777
|
+
const category = ObjectiveCriteriaNode.ComplexCategories.get(core.ResourceLocationNode.toString(res.children[0], 'short'));
|
|
805
778
|
if (category) {
|
|
806
779
|
return core.resourceLocation({ category, namespacePathSep: '.' });
|
|
807
780
|
}
|
|
@@ -810,7 +783,7 @@ const objectiveCriteria = core.map(core.any([
|
|
|
810
783
|
},
|
|
811
784
|
},
|
|
812
785
|
]),
|
|
813
|
-
core.literal(...
|
|
786
|
+
core.literal(...ObjectiveCriteriaNode.SimpleValues),
|
|
814
787
|
]), res => {
|
|
815
788
|
const ans = {
|
|
816
789
|
type: 'mcfunction:objective_criteria',
|
|
@@ -824,18 +797,16 @@ const objectiveCriteria = core.map(core.any([
|
|
|
824
797
|
}
|
|
825
798
|
return ans;
|
|
826
799
|
});
|
|
827
|
-
function tag(terminators = []) {
|
|
800
|
+
export function tag(terminators = []) {
|
|
828
801
|
return unquotableSymbol('tag', terminators);
|
|
829
802
|
}
|
|
830
|
-
|
|
831
|
-
function team(usageType, terminators = []) {
|
|
803
|
+
export function team(usageType, terminators = []) {
|
|
832
804
|
return unquotableSymbol({ category: 'team', usageType }, terminators);
|
|
833
805
|
}
|
|
834
|
-
exports.team = team;
|
|
835
806
|
function unquotableSymbol(options, terminators) {
|
|
836
807
|
return validateUnquotable(symbol(options, terminators));
|
|
837
808
|
}
|
|
838
|
-
const time = core.map(core.sequence([float(0, undefined), core.optional(core.failOnEmpty(core.literal(...
|
|
809
|
+
const time = core.map(core.sequence([float(0, undefined), core.optional(core.failOnEmpty(core.literal(...TimeNode.Units)))]), res => {
|
|
839
810
|
const valueNode = res.children.find(core.FloatNode.is);
|
|
840
811
|
const unitNode = res.children.find(core.LiteralNode.is);
|
|
841
812
|
const ans = {
|
|
@@ -881,7 +852,7 @@ const uuid = (src, ctx) => {
|
|
|
881
852
|
}
|
|
882
853
|
ans.range.end = src.cursor;
|
|
883
854
|
if (!isLegal) {
|
|
884
|
-
ctx.err.report(
|
|
855
|
+
ctx.err.report(localize('mcfunction.parser.uuid.invalid'), ans);
|
|
885
856
|
}
|
|
886
857
|
return ans;
|
|
887
858
|
};
|
|
@@ -892,7 +863,7 @@ function validateLength(parser, maxLength, localeKey) {
|
|
|
892
863
|
}
|
|
893
864
|
return core.map(parser, (res, _src, ctx) => {
|
|
894
865
|
if (res.value.length > maxLength) {
|
|
895
|
-
ctx.err.report(
|
|
866
|
+
ctx.err.report(localize(localeKey, maxLength), res);
|
|
896
867
|
}
|
|
897
868
|
return res;
|
|
898
869
|
})(src, ctx);
|
|
@@ -901,7 +872,7 @@ function validateLength(parser, maxLength, localeKey) {
|
|
|
901
872
|
function validateUnquotable(parser) {
|
|
902
873
|
return core.map(parser, (res, _src, ctx) => {
|
|
903
874
|
if (!res.value.match(core.BrigadierUnquotablePattern)) {
|
|
904
|
-
ctx.err.report(
|
|
875
|
+
ctx.err.report(localize('parser.string.illegal-brigadier', localeQuote(res.value)), res);
|
|
905
876
|
}
|
|
906
877
|
return res;
|
|
907
878
|
});
|
|
@@ -925,11 +896,11 @@ function vector(options) {
|
|
|
925
896
|
const coord = options.integersOnly ? coordinate(options.integersOnly)(src, ctx) : coordinate(options.integersOnly)(src, ctx);
|
|
926
897
|
ans.children.push(coord);
|
|
927
898
|
if ((ans.system === 1 /* CoordinateSystem.Local */) !== (coord.notation === '^')) {
|
|
928
|
-
ctx.err.report(
|
|
899
|
+
ctx.err.report(localize('mcfunction.parser.vector.mixed'), coord);
|
|
929
900
|
}
|
|
930
901
|
}
|
|
931
902
|
if (options.noLocal && ans.system === 1 /* CoordinateSystem.Local */) {
|
|
932
|
-
ctx.err.report(
|
|
903
|
+
ctx.err.report(localize('mcfunction.parser.vector.local-disallowed'), ans);
|
|
933
904
|
}
|
|
934
905
|
ans.range.end = src.cursor;
|
|
935
906
|
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
|