@spyglassmc/java-edition 0.1.1 → 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 +3 -3
- package/lib/binder/index.js +11 -17
- package/lib/common/index.js +4 -28
- package/lib/dependency/common.d.ts +8 -5
- package/lib/dependency/common.js +18 -18
- package/lib/dependency/index.d.ts +6 -6
- package/lib/dependency/index.js +21 -48
- package/lib/dependency/mcmeta.d.ts +2 -3
- package/lib/dependency/mcmeta.js +28 -100
- package/lib/index.d.ts +3 -3
- package/lib/index.js +27 -50
- 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 +2 -2
- 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 -45
- 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 -19
- package/lib/json/checker/util/nbt.d.ts +2 -3
- 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 +13 -13
- package/lib/json/checker/util/version.js +7 -13
- package/lib/json/index.d.ts +1 -1
- package/lib/json/index.js +4 -27
- package/lib/mcfunction/checker/index.d.ts +1 -1
- package/lib/mcfunction/checker/index.js +79 -103
- package/lib/mcfunction/colorizer/index.d.ts +1 -1
- package/lib/mcfunction/colorizer/index.js +6 -31
- package/lib/mcfunction/common/index.js +7 -29
- package/lib/mcfunction/completer/argument.js +95 -119
- package/lib/mcfunction/completer/index.d.ts +1 -1
- package/lib/mcfunction/completer/index.js +1 -13
- package/lib/mcfunction/index.d.ts +6 -6
- package/lib/mcfunction/index.js +19 -54
- package/lib/mcfunction/inlayHintProvider.js +3 -26
- package/lib/mcfunction/node/argument.d.ts +3 -3
- package/lib/mcfunction/node/argument.js +47 -69
- package/lib/mcfunction/node/index.d.ts +1 -1
- package/lib/mcfunction/node/index.js +1 -13
- package/lib/mcfunction/parser/argument.d.ts +1 -1
- package/lib/mcfunction/parser/argument.js +76 -101
- package/lib/mcfunction/parser/index.d.ts +1 -1
- package/lib/mcfunction/parser/index.js +1 -13
- package/lib/mcfunction/signatureHelpProvider.js +3 -26
- package/lib/mcfunction/tree/argument.js +1 -2
- package/lib/mcfunction/tree/index.d.ts +1 -6
- package/lib/mcfunction/tree/index.js +1 -18
- package/lib/mcfunction/tree/patch.d.ts +4 -0
- package/lib/mcfunction/tree/patch.js +748 -0
- package/package.json +8 -7
- package/lib/mcfunction/tree/1.15.d.ts +0 -9
- package/lib/mcfunction/tree/1.15.js +0 -542
- package/lib/mcfunction/tree/1.16.d.ts +0 -10
- package/lib/mcfunction/tree/1.16.js +0 -77
- package/lib/mcfunction/tree/1.17.d.ts +0 -12
- package/lib/mcfunction/tree/1.17.js +0 -166
- package/lib/mcfunction/tree/1.18.d.ts +0 -26
- package/lib/mcfunction/tree/1.18.js +0 -6
- package/lib/mcfunction/tree/1.19.d.ts +0 -26
- package/lib/mcfunction/tree/1.19.js +0 -6
|
@@ -1,34 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.team = exports.tag = exports.scoreHolderFakeName = exports.particle = exports.component = exports.blockPredicate = exports.argument = void 0;
|
|
23
|
-
const core = __importStar(require("@spyglassmc/core"));
|
|
24
|
-
const core_1 = require("@spyglassmc/core");
|
|
25
|
-
const json = __importStar(require("@spyglassmc/json"));
|
|
26
|
-
const locales_1 = require("@spyglassmc/locales");
|
|
27
|
-
const mcf = __importStar(require("@spyglassmc/mcfunction"));
|
|
28
|
-
const nbt = __importStar(require("@spyglassmc/nbt"));
|
|
29
|
-
const dependency_1 = require("../../dependency");
|
|
30
|
-
const common_1 = require("../common");
|
|
31
|
-
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';
|
|
32
10
|
const IntegerPattern = /^-?\d+$/;
|
|
33
11
|
/**
|
|
34
12
|
* A combination of:
|
|
@@ -56,14 +34,14 @@ const FakeNameMaxLength = 40;
|
|
|
56
34
|
const ObjectiveMaxLength = 16;
|
|
57
35
|
const PlayerNameMaxLength = 16;
|
|
58
36
|
function shouldValidateLength(ctx) {
|
|
59
|
-
const
|
|
60
|
-
return !
|
|
37
|
+
const release = ctx.project['loadedVersion'];
|
|
38
|
+
return !release || ReleaseVersion.cmp(release, '1.18') < 0;
|
|
61
39
|
}
|
|
62
40
|
/**
|
|
63
41
|
* @returns The parser for the specified argument tree node. All argument parsers used in the `mcfunction` package
|
|
64
42
|
* fail on empty input.
|
|
65
43
|
*/
|
|
66
|
-
const argument = (rawTreeNode) => {
|
|
44
|
+
export const argument = (rawTreeNode) => {
|
|
67
45
|
const treeNode = rawTreeNode;
|
|
68
46
|
const wrap = (parser) => core.failOnEmpty(core.stopBefore(parser, '\r', '\n'));
|
|
69
47
|
switch (treeNode.parser) {
|
|
@@ -88,15 +66,15 @@ const argument = (rawTreeNode) => {
|
|
|
88
66
|
return wrap(greedyString);
|
|
89
67
|
}
|
|
90
68
|
case 'minecraft:angle':
|
|
91
|
-
return wrap(core.validate(coordinate(), res => res.notation !== '^',
|
|
69
|
+
return wrap(core.validate(coordinate(), res => res.notation !== '^', localize('mcfunction.parser.vector.local-disallowed')));
|
|
92
70
|
case 'minecraft:block_pos':
|
|
93
71
|
return wrap(vector({ dimension: 3, integersOnly: true }));
|
|
94
72
|
case 'minecraft:block_predicate':
|
|
95
|
-
return wrap(
|
|
73
|
+
return wrap(blockPredicate);
|
|
96
74
|
case 'minecraft:block_state':
|
|
97
75
|
return wrap(blockState);
|
|
98
76
|
case 'minecraft:color':
|
|
99
|
-
return wrap(core.map(core.literal(...
|
|
77
|
+
return wrap(core.map(core.literal(...ColorArgumentValues), res => ({
|
|
100
78
|
...res,
|
|
101
79
|
color: core.Color.NamedColors.has(res.value)
|
|
102
80
|
? core.Color.fromCompositeInt(core.Color.NamedColors.get(res.value))
|
|
@@ -105,7 +83,7 @@ const argument = (rawTreeNode) => {
|
|
|
105
83
|
case 'minecraft:column_pos':
|
|
106
84
|
return wrap(vector({ dimension: 2, integersOnly: true }));
|
|
107
85
|
case 'minecraft:component':
|
|
108
|
-
return wrap(
|
|
86
|
+
return wrap(component);
|
|
109
87
|
case 'minecraft:dimension':
|
|
110
88
|
return wrap(core.resourceLocation({
|
|
111
89
|
category: 'dimension',
|
|
@@ -113,7 +91,7 @@ const argument = (rawTreeNode) => {
|
|
|
113
91
|
case 'minecraft:entity':
|
|
114
92
|
return wrap(entity(treeNode.properties.amount, treeNode.properties.type));
|
|
115
93
|
case 'minecraft:entity_anchor':
|
|
116
|
-
return wrap(core.literal(...
|
|
94
|
+
return wrap(core.literal(...EntityAnchorArgumentValues));
|
|
117
95
|
case 'minecraft:entity_summon':
|
|
118
96
|
return wrap(core.resourceLocation({
|
|
119
97
|
category: 'entity_type',
|
|
@@ -136,7 +114,7 @@ const argument = (rawTreeNode) => {
|
|
|
136
114
|
case 'minecraft:item_predicate':
|
|
137
115
|
return wrap(itemPredicate);
|
|
138
116
|
case 'minecraft:item_slot':
|
|
139
|
-
return wrap(core.literal(...
|
|
117
|
+
return wrap(core.literal(...ItemSlotArgumentValues));
|
|
140
118
|
case 'minecraft:item_stack':
|
|
141
119
|
return wrap(itemStack);
|
|
142
120
|
case 'minecraft:message':
|
|
@@ -159,11 +137,11 @@ const argument = (rawTreeNode) => {
|
|
|
159
137
|
return wrap(objectiveCriteria);
|
|
160
138
|
case 'minecraft:operation':
|
|
161
139
|
return wrap(core.literal({
|
|
162
|
-
pool:
|
|
140
|
+
pool: OperationArgumentValues,
|
|
163
141
|
colorTokenType: 'operator',
|
|
164
142
|
}));
|
|
165
143
|
case 'minecraft:particle':
|
|
166
|
-
return wrap(
|
|
144
|
+
return wrap(particle);
|
|
167
145
|
case 'minecraft:resource':
|
|
168
146
|
case 'minecraft:resource_or_tag':
|
|
169
147
|
return wrap(core.resourceLocation({
|
|
@@ -182,9 +160,9 @@ const argument = (rawTreeNode) => {
|
|
|
182
160
|
case 'minecraft:scoreboard_slot':
|
|
183
161
|
// `BELOWNAME` and `sidebar.team.r--.+++e----__d` are also legal slots.
|
|
184
162
|
// But I do not want to spend time supporting them.
|
|
185
|
-
return wrap(core.literal(...
|
|
163
|
+
return wrap(core.literal(...ScoreboardSlotArgumentValues));
|
|
186
164
|
case 'minecraft:swizzle':
|
|
187
|
-
return wrap(core.literal(...
|
|
165
|
+
return wrap(core.literal(...SwizzleArgumentValues));
|
|
188
166
|
case 'minecraft:team':
|
|
189
167
|
return wrap(team(core.SymbolUsageType.is(treeNode.properties?.usageType)
|
|
190
168
|
? treeNode.properties?.usageType
|
|
@@ -204,7 +182,6 @@ const argument = (rawTreeNode) => {
|
|
|
204
182
|
return undefined;
|
|
205
183
|
}
|
|
206
184
|
};
|
|
207
|
-
exports.argument = argument;
|
|
208
185
|
function block(isPredicate) {
|
|
209
186
|
return core.map(core.sequence([
|
|
210
187
|
core.resourceLocation({ category: 'block', allowTag: isPredicate }),
|
|
@@ -232,15 +209,15 @@ function block(isPredicate) {
|
|
|
232
209
|
range: res.range,
|
|
233
210
|
children: res.children,
|
|
234
211
|
id: res.children.find(core.ResourceLocationNode.is),
|
|
235
|
-
states: res.children.find(
|
|
212
|
+
states: res.children.find(BlockStatesNode.is),
|
|
236
213
|
nbt: res.children.find(nbt.NbtCompoundNode.is),
|
|
237
214
|
};
|
|
238
215
|
return ans;
|
|
239
216
|
});
|
|
240
217
|
}
|
|
241
218
|
const blockState = block(false);
|
|
242
|
-
|
|
243
|
-
|
|
219
|
+
export const blockPredicate = block(true);
|
|
220
|
+
export const component = json.parser.json();
|
|
244
221
|
function double(min = DoubleMin, max = DoubleMax) {
|
|
245
222
|
return core.float({
|
|
246
223
|
pattern: FloatPattern,
|
|
@@ -294,7 +271,7 @@ function coordinate(integerOnly = false) {
|
|
|
294
271
|
function entity(amount, type) {
|
|
295
272
|
return core.map(core.select([
|
|
296
273
|
{
|
|
297
|
-
predicate: src =>
|
|
274
|
+
predicate: src => EntitySelectorAtVariable.is(src.peek(2)),
|
|
298
275
|
parser: selector(),
|
|
299
276
|
},
|
|
300
277
|
{
|
|
@@ -312,17 +289,17 @@ function entity(amount, type) {
|
|
|
312
289
|
if (core.StringNode.is(res)) {
|
|
313
290
|
ans.playerName = res;
|
|
314
291
|
}
|
|
315
|
-
else if (
|
|
292
|
+
else if (EntitySelectorNode.is(res)) {
|
|
316
293
|
ans.selector = res;
|
|
317
294
|
}
|
|
318
295
|
else {
|
|
319
296
|
ans.uuid = res;
|
|
320
297
|
}
|
|
321
298
|
if (amount === 'single' && ans.selector && !ans.selector.single) {
|
|
322
|
-
ctx.err.report(
|
|
299
|
+
ctx.err.report(localize('mcfunction.parser.entity-selector.multiple-disallowed'), ans);
|
|
323
300
|
}
|
|
324
301
|
if (type === 'players' && (ans.uuid || (ans.selector && !ans.selector.playersOnly && !ans.selector.currentEntity))) {
|
|
325
|
-
ctx.err.report(
|
|
302
|
+
ctx.err.report(localize('mcfunction.parser.entity-selector.entities-disallowed'), ans);
|
|
326
303
|
}
|
|
327
304
|
return ans;
|
|
328
305
|
});
|
|
@@ -354,16 +331,16 @@ const message = (src, ctx) => {
|
|
|
354
331
|
children: [],
|
|
355
332
|
};
|
|
356
333
|
while (src.canReadInLine()) {
|
|
357
|
-
if (
|
|
334
|
+
if (EntitySelectorAtVariable.is(src.peek(2))) {
|
|
358
335
|
ans.children.push(selector()(src, ctx));
|
|
359
336
|
}
|
|
360
337
|
else {
|
|
361
|
-
ans.children.push(core.stopBefore(greedyString, ...
|
|
338
|
+
ans.children.push(core.stopBefore(greedyString, ...EntitySelectorAtVariables)(src, ctx));
|
|
362
339
|
}
|
|
363
340
|
}
|
|
364
341
|
return ans;
|
|
365
342
|
};
|
|
366
|
-
|
|
343
|
+
export const particle = (() => {
|
|
367
344
|
const sep = core.map(mcf.sep, () => []);
|
|
368
345
|
const vec = vector({ dimension: 3 });
|
|
369
346
|
const color = core.map(vec, res => ({
|
|
@@ -378,14 +355,14 @@ exports.particle = (() => {
|
|
|
378
355
|
const map = {
|
|
379
356
|
block: blockState,
|
|
380
357
|
block_marker: blockState,
|
|
381
|
-
dust:
|
|
382
|
-
dust_color_transition:
|
|
358
|
+
dust: sequence([color, float()], sep),
|
|
359
|
+
dust_color_transition: sequence([color, float(), color], sep),
|
|
383
360
|
falling_dust: blockState,
|
|
384
361
|
item: itemStack,
|
|
385
362
|
sculk_charge: float(),
|
|
386
|
-
vibration:
|
|
363
|
+
vibration: sequence([vec, vec, integer()], sep),
|
|
387
364
|
};
|
|
388
|
-
return core.map(
|
|
365
|
+
return core.map(sequence([
|
|
389
366
|
core.resourceLocation({ category: 'particle_type' }),
|
|
390
367
|
{
|
|
391
368
|
get: res => {
|
|
@@ -430,7 +407,7 @@ function range(type, min, max, cycleable) {
|
|
|
430
407
|
: [valueNodes[0].value, valueNodes[0].value],
|
|
431
408
|
};
|
|
432
409
|
if (!cycleable && ans.value[0] !== undefined && ans.value[1] !== undefined && ans.value[0] > ans.value[1]) {
|
|
433
|
-
ctx.err.report(
|
|
410
|
+
ctx.err.report(localize('mcfunction.parser.range.min>max', ans.value[0], ans.value[1]), res);
|
|
434
411
|
}
|
|
435
412
|
return ans;
|
|
436
413
|
});
|
|
@@ -447,7 +424,7 @@ function selector() {
|
|
|
447
424
|
let single;
|
|
448
425
|
let typeLimited;
|
|
449
426
|
return core.map(core.sequence([
|
|
450
|
-
core.failOnEmpty(core.literal({ pool:
|
|
427
|
+
core.failOnEmpty(core.literal({ pool: EntitySelectorAtVariables, colorTokenType: 'keyword' })),
|
|
451
428
|
{
|
|
452
429
|
get: res => {
|
|
453
430
|
const variable = core.LiteralNode.is(res.children?.[0]) ? res.children[0].value : undefined;
|
|
@@ -478,7 +455,7 @@ function selector() {
|
|
|
478
455
|
key: core.string({
|
|
479
456
|
...core.BrigadierStringOptions,
|
|
480
457
|
value: {
|
|
481
|
-
parser: core.literal({ pool: [...
|
|
458
|
+
parser: core.literal({ pool: [...EntitySelectorNode.ArgumentKeys], colorTokenType: 'property' }),
|
|
482
459
|
type: 'literal',
|
|
483
460
|
},
|
|
484
461
|
}),
|
|
@@ -525,7 +502,7 @@ function selector() {
|
|
|
525
502
|
end: '}',
|
|
526
503
|
}), (res, _, ctx) => {
|
|
527
504
|
if (hasKey(key.value)) {
|
|
528
|
-
ctx.err.report(
|
|
505
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
529
506
|
}
|
|
530
507
|
const ans = {
|
|
531
508
|
...res,
|
|
@@ -537,9 +514,9 @@ function selector() {
|
|
|
537
514
|
return core.map(range('float', 0), (res, _, ctx) => {
|
|
538
515
|
dimensionLimited = true;
|
|
539
516
|
// x, y, z, dx, dy, dz take precedence over distance, so we use ??= instead of = to ensure it won't override the result.
|
|
540
|
-
chunkLimited
|
|
517
|
+
chunkLimited ??= !playersOnly && res.value[1] !== undefined;
|
|
541
518
|
if (hasKey(key.value)) {
|
|
542
|
-
ctx.err.report(
|
|
519
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
543
520
|
}
|
|
544
521
|
return res;
|
|
545
522
|
});
|
|
@@ -553,7 +530,7 @@ function selector() {
|
|
|
553
530
|
})), (res, _, ctx) => {
|
|
554
531
|
playersOnly = true;
|
|
555
532
|
if (res.inverted ? hasNonInvertedKey(key.value) : hasKey(key.value)) {
|
|
556
|
-
ctx.err.report(
|
|
533
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
557
534
|
}
|
|
558
535
|
return res;
|
|
559
536
|
});
|
|
@@ -561,10 +538,10 @@ function selector() {
|
|
|
561
538
|
return core.map(integer(0), (res, _, ctx) => {
|
|
562
539
|
single = res.value <= 1;
|
|
563
540
|
if (hasKey(key.value)) {
|
|
564
|
-
ctx.err.report(
|
|
541
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
565
542
|
}
|
|
566
543
|
if (currentEntity) {
|
|
567
|
-
ctx.err.report(
|
|
544
|
+
ctx.err.report(localize('mcfunction.parser.entity-selector.arguments.not-applicable', localeQuote(key.value)), key);
|
|
568
545
|
}
|
|
569
546
|
return res;
|
|
570
547
|
});
|
|
@@ -572,14 +549,14 @@ function selector() {
|
|
|
572
549
|
return core.map(range('integer', 0), (res, _, ctx) => {
|
|
573
550
|
playersOnly = true;
|
|
574
551
|
if (hasKey(key.value)) {
|
|
575
|
-
ctx.err.report(
|
|
552
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
576
553
|
}
|
|
577
554
|
return res;
|
|
578
555
|
});
|
|
579
556
|
case 'name':
|
|
580
557
|
return core.map(invertable(core.brigadierString), (res, _, ctx) => {
|
|
581
558
|
if (res.inverted ? hasNonInvertedKey(key.value) : hasKey(key.value)) {
|
|
582
|
-
ctx.err.report(
|
|
559
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
583
560
|
}
|
|
584
561
|
return res;
|
|
585
562
|
});
|
|
@@ -600,7 +577,7 @@ function selector() {
|
|
|
600
577
|
end: '}',
|
|
601
578
|
}), (res, _, ctx) => {
|
|
602
579
|
if (hasKey(key.value)) {
|
|
603
|
-
ctx.err.report(
|
|
580
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
604
581
|
}
|
|
605
582
|
const ans = {
|
|
606
583
|
...res,
|
|
@@ -617,10 +594,10 @@ function selector() {
|
|
|
617
594
|
},
|
|
618
595
|
}), (res, _, ctx) => {
|
|
619
596
|
if (hasKey(key.value)) {
|
|
620
|
-
ctx.err.report(
|
|
597
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
621
598
|
}
|
|
622
599
|
if (currentEntity) {
|
|
623
|
-
ctx.err.report(
|
|
600
|
+
ctx.err.report(localize('mcfunction.parser.entity-selector.arguments.not-applicable', localeQuote(key.value)), key);
|
|
624
601
|
}
|
|
625
602
|
return res;
|
|
626
603
|
});
|
|
@@ -629,7 +606,7 @@ function selector() {
|
|
|
629
606
|
case 'team':
|
|
630
607
|
return core.map(invertable(team('reference', ['[', '=', ',', ']', '{', '}'])), (res, _, ctx) => {
|
|
631
608
|
if (res.inverted ? hasNonInvertedKey(key.value) : hasKey(key.value)) {
|
|
632
|
-
ctx.err.report(
|
|
609
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
633
610
|
}
|
|
634
611
|
return res;
|
|
635
612
|
});
|
|
@@ -637,10 +614,10 @@ function selector() {
|
|
|
637
614
|
return core.map(invertable(core.resourceLocation({ category: 'entity_type', allowTag: true })), (res, _, ctx) => {
|
|
638
615
|
if (typeLimited) {
|
|
639
616
|
if (hasKey(key.value)) {
|
|
640
|
-
ctx.err.report(
|
|
617
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
641
618
|
}
|
|
642
619
|
else {
|
|
643
|
-
ctx.err.report(
|
|
620
|
+
ctx.err.report(localize('mcfunction.parser.entity-selector.arguments.not-applicable', localeQuote(key.value)), key);
|
|
644
621
|
}
|
|
645
622
|
}
|
|
646
623
|
else if (!res.inverted && !res.value.isTag) {
|
|
@@ -657,7 +634,7 @@ function selector() {
|
|
|
657
634
|
return core.map(double(), (res, _, ctx) => {
|
|
658
635
|
dimensionLimited = true;
|
|
659
636
|
if (hasKey(key.value)) {
|
|
660
|
-
ctx.err.report(
|
|
637
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
661
638
|
}
|
|
662
639
|
return res;
|
|
663
640
|
});
|
|
@@ -668,7 +645,7 @@ function selector() {
|
|
|
668
645
|
dimensionLimited = true;
|
|
669
646
|
chunkLimited = !playersOnly;
|
|
670
647
|
if (hasKey(key.value)) {
|
|
671
|
-
ctx.err.report(
|
|
648
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
672
649
|
}
|
|
673
650
|
return res;
|
|
674
651
|
});
|
|
@@ -676,7 +653,7 @@ function selector() {
|
|
|
676
653
|
case 'y_rotation':
|
|
677
654
|
return core.map(range('float', undefined, undefined, true), (res, _, ctx) => {
|
|
678
655
|
if (hasKey(key.value)) {
|
|
679
|
-
ctx.err.report(
|
|
656
|
+
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
680
657
|
}
|
|
681
658
|
return res;
|
|
682
659
|
});
|
|
@@ -686,7 +663,7 @@ function selector() {
|
|
|
686
663
|
default:
|
|
687
664
|
// The key is unknown.
|
|
688
665
|
return (_src, ctx) => {
|
|
689
|
-
ctx.err.report(
|
|
666
|
+
ctx.err.report(localize('mcfunction.parser.entity-selector.arguments.unknown', localeQuote(key.value)), key);
|
|
690
667
|
return core.Failure;
|
|
691
668
|
};
|
|
692
669
|
}
|
|
@@ -711,7 +688,7 @@ function selector() {
|
|
|
711
688
|
range: res.range,
|
|
712
689
|
children: res.children,
|
|
713
690
|
variable: res.children.find(core.LiteralNode.is).value.slice(1),
|
|
714
|
-
arguments: res.children.find(
|
|
691
|
+
arguments: res.children.find(EntitySelectorArgumentsNode.is),
|
|
715
692
|
chunkLimited,
|
|
716
693
|
currentEntity,
|
|
717
694
|
dimensionLimited,
|
|
@@ -756,15 +733,15 @@ ${node.predicates.map(p => `- \`${p}\``).join('\n')}`;
|
|
|
756
733
|
}
|
|
757
734
|
return ans;
|
|
758
735
|
}
|
|
759
|
-
|
|
736
|
+
export const scoreHolderFakeName = validateLength(symbol('score_holder'), FakeNameMaxLength, 'mcfunction.parser.score_holder.fake-name.too-long');
|
|
760
737
|
function scoreHolder(amount) {
|
|
761
738
|
return core.map(core.select([
|
|
762
739
|
{
|
|
763
|
-
predicate: src =>
|
|
740
|
+
predicate: src => EntitySelectorAtVariable.is(src.peek(2)),
|
|
764
741
|
parser: selector(),
|
|
765
742
|
},
|
|
766
743
|
{
|
|
767
|
-
parser:
|
|
744
|
+
parser: scoreHolderFakeName,
|
|
768
745
|
},
|
|
769
746
|
]), (res, _src, ctx) => {
|
|
770
747
|
const ans = {
|
|
@@ -779,7 +756,7 @@ function scoreHolder(amount) {
|
|
|
779
756
|
ans.selector = res;
|
|
780
757
|
}
|
|
781
758
|
if (amount === 'single' && ans.selector && !ans.selector.single) {
|
|
782
|
-
ctx.err.report(
|
|
759
|
+
ctx.err.report(localize('mcfunction.parser.entity-selector.multiple-disallowed'), ans);
|
|
783
760
|
}
|
|
784
761
|
return ans;
|
|
785
762
|
});
|
|
@@ -797,7 +774,7 @@ const objectiveCriteria = core.map(core.any([
|
|
|
797
774
|
{
|
|
798
775
|
get: res => {
|
|
799
776
|
if (core.ResourceLocationNode.is(res.children[0])) {
|
|
800
|
-
const category =
|
|
777
|
+
const category = ObjectiveCriteriaNode.ComplexCategories.get(core.ResourceLocationNode.toString(res.children[0], 'short'));
|
|
801
778
|
if (category) {
|
|
802
779
|
return core.resourceLocation({ category, namespacePathSep: '.' });
|
|
803
780
|
}
|
|
@@ -806,7 +783,7 @@ const objectiveCriteria = core.map(core.any([
|
|
|
806
783
|
},
|
|
807
784
|
},
|
|
808
785
|
]),
|
|
809
|
-
core.literal(...
|
|
786
|
+
core.literal(...ObjectiveCriteriaNode.SimpleValues),
|
|
810
787
|
]), res => {
|
|
811
788
|
const ans = {
|
|
812
789
|
type: 'mcfunction:objective_criteria',
|
|
@@ -820,18 +797,16 @@ const objectiveCriteria = core.map(core.any([
|
|
|
820
797
|
}
|
|
821
798
|
return ans;
|
|
822
799
|
});
|
|
823
|
-
function tag(terminators = []) {
|
|
800
|
+
export function tag(terminators = []) {
|
|
824
801
|
return unquotableSymbol('tag', terminators);
|
|
825
802
|
}
|
|
826
|
-
|
|
827
|
-
function team(usageType, terminators = []) {
|
|
803
|
+
export function team(usageType, terminators = []) {
|
|
828
804
|
return unquotableSymbol({ category: 'team', usageType }, terminators);
|
|
829
805
|
}
|
|
830
|
-
exports.team = team;
|
|
831
806
|
function unquotableSymbol(options, terminators) {
|
|
832
807
|
return validateUnquotable(symbol(options, terminators));
|
|
833
808
|
}
|
|
834
|
-
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 => {
|
|
835
810
|
const valueNode = res.children.find(core.FloatNode.is);
|
|
836
811
|
const unitNode = res.children.find(core.LiteralNode.is);
|
|
837
812
|
const ans = {
|
|
@@ -877,7 +852,7 @@ const uuid = (src, ctx) => {
|
|
|
877
852
|
}
|
|
878
853
|
ans.range.end = src.cursor;
|
|
879
854
|
if (!isLegal) {
|
|
880
|
-
ctx.err.report(
|
|
855
|
+
ctx.err.report(localize('mcfunction.parser.uuid.invalid'), ans);
|
|
881
856
|
}
|
|
882
857
|
return ans;
|
|
883
858
|
};
|
|
@@ -888,7 +863,7 @@ function validateLength(parser, maxLength, localeKey) {
|
|
|
888
863
|
}
|
|
889
864
|
return core.map(parser, (res, _src, ctx) => {
|
|
890
865
|
if (res.value.length > maxLength) {
|
|
891
|
-
ctx.err.report(
|
|
866
|
+
ctx.err.report(localize(localeKey, maxLength), res);
|
|
892
867
|
}
|
|
893
868
|
return res;
|
|
894
869
|
})(src, ctx);
|
|
@@ -897,7 +872,7 @@ function validateLength(parser, maxLength, localeKey) {
|
|
|
897
872
|
function validateUnquotable(parser) {
|
|
898
873
|
return core.map(parser, (res, _src, ctx) => {
|
|
899
874
|
if (!res.value.match(core.BrigadierUnquotablePattern)) {
|
|
900
|
-
ctx.err.report(
|
|
875
|
+
ctx.err.report(localize('parser.string.illegal-brigadier', localeQuote(res.value)), res);
|
|
901
876
|
}
|
|
902
877
|
return res;
|
|
903
878
|
});
|
|
@@ -909,10 +884,10 @@ function vector(options) {
|
|
|
909
884
|
range: core.Range.create(src),
|
|
910
885
|
children: [],
|
|
911
886
|
options,
|
|
912
|
-
system: 0 /* World */,
|
|
887
|
+
system: 0 /* CoordinateSystem.World */,
|
|
913
888
|
};
|
|
914
889
|
if (src.peek() === '^') {
|
|
915
|
-
ans.system = 1 /* Local */;
|
|
890
|
+
ans.system = 1 /* CoordinateSystem.Local */;
|
|
916
891
|
}
|
|
917
892
|
for (let i = 0; i < options.dimension; i++) {
|
|
918
893
|
if (i > 0) {
|
|
@@ -920,12 +895,12 @@ function vector(options) {
|
|
|
920
895
|
}
|
|
921
896
|
const coord = options.integersOnly ? coordinate(options.integersOnly)(src, ctx) : coordinate(options.integersOnly)(src, ctx);
|
|
922
897
|
ans.children.push(coord);
|
|
923
|
-
if ((ans.system === 1 /* Local */) !== (coord.notation === '^')) {
|
|
924
|
-
ctx.err.report(
|
|
898
|
+
if ((ans.system === 1 /* CoordinateSystem.Local */) !== (coord.notation === '^')) {
|
|
899
|
+
ctx.err.report(localize('mcfunction.parser.vector.mixed'), coord);
|
|
925
900
|
}
|
|
926
901
|
}
|
|
927
|
-
if (options.noLocal && ans.system === 1 /* Local */) {
|
|
928
|
-
ctx.err.report(
|
|
902
|
+
if (options.noLocal && ans.system === 1 /* CoordinateSystem.Local */) {
|
|
903
|
+
ctx.err.report(localize('mcfunction.parser.vector.local-disallowed'), ans);
|
|
929
904
|
}
|
|
930
905
|
ans.range.end = src.cursor;
|
|
931
906
|
return ans;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './argument';
|
|
1
|
+
export * from './argument.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./argument"), exports);
|
|
1
|
+
export * from './argument.js';
|
|
14
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,32 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.signatureHelpProvider = void 0;
|
|
23
|
-
const core = __importStar(require("@spyglassmc/core"));
|
|
24
|
-
const mcf = __importStar(require("@spyglassmc/mcfunction"));
|
|
1
|
+
import * as core from '@spyglassmc/core';
|
|
2
|
+
import * as mcf from '@spyglassmc/mcfunction';
|
|
25
3
|
/**
|
|
26
4
|
* Only command options that can be satisfied by the current command node will be listed in `signatures`.
|
|
27
5
|
* Only parameters at and immediately after the `offset` will be listed in `parameters`.
|
|
28
6
|
*/
|
|
29
|
-
function signatureHelpProvider(commandTreeName) {
|
|
7
|
+
export function signatureHelpProvider(commandTreeName) {
|
|
30
8
|
const rootTreeNode = mcf.CommandTreeRegistry.instance.get(commandTreeName);
|
|
31
9
|
return (fileNode, ctx) => {
|
|
32
10
|
if (fileNode.children[0]?.type !== 'mcfunction:entry') {
|
|
@@ -74,7 +52,6 @@ function signatureHelpProvider(commandTreeName) {
|
|
|
74
52
|
return ans;
|
|
75
53
|
};
|
|
76
54
|
}
|
|
77
|
-
exports.signatureHelpProvider = signatureHelpProvider;
|
|
78
55
|
function getSelectedCommandNode(fileNode, offset) {
|
|
79
56
|
return core.AstNode.findChild(fileNode.children[0], offset, true);
|
|
80
57
|
}
|
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./1.15"), exports);
|
|
14
|
-
__exportStar(require("./1.16"), exports);
|
|
15
|
-
__exportStar(require("./1.17"), exports);
|
|
16
|
-
__exportStar(require("./1.18"), exports);
|
|
17
|
-
__exportStar(require("./1.19"), exports);
|
|
18
|
-
__exportStar(require("./argument"), exports);
|
|
1
|
+
export * from './argument.js';
|
|
19
2
|
//# sourceMappingURL=index.js.map
|