@spyglassmc/java-edition 0.3.1 → 0.3.3
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 +110 -19
- package/lib/common/index.js +10 -7
- package/lib/dependency/common.d.ts +1 -1
- package/lib/dependency/index.js +11 -9
- package/lib/dependency/mcmeta.d.ts +4 -4
- package/lib/dependency/mcmeta.js +32 -15
- package/lib/index.js +18 -6
- package/lib/json/checker/data/advancement.js +24 -13
- package/lib/json/checker/data/biome.js +3 -3
- package/lib/json/checker/data/common.js +29 -30
- package/lib/json/checker/data/dimension.js +7 -18
- package/lib/json/checker/data/feature.js +45 -27
- package/lib/json/checker/data/index.d.ts +1 -1
- package/lib/json/checker/data/index.js +3 -3
- package/lib/json/checker/data/loot_table.js +40 -21
- package/lib/json/checker/data/recipe.js +1 -1
- package/lib/json/checker/data/structure.js +24 -14
- package/lib/json/checker/data/tag.js +2 -2
- package/lib/json/checker/data/text_component.js +24 -8
- package/lib/json/checker/index.d.ts +10 -3
- package/lib/json/checker/index.js +231 -3
- package/lib/json/checker/util/advancement.js +3 -2
- package/lib/json/checker/util/block_states.d.ts +2 -2
- package/lib/json/checker/util/block_states.js +7 -5
- package/lib/json/checker/util/color.js +8 -2
- package/lib/json/checker/util/nbt.d.ts +1 -1
- package/lib/json/checker/util/nbt.js +4 -2
- package/lib/json/checker/util/recipe.js +7 -6
- package/lib/json/checker/util/version.d.ts +1 -1
- package/lib/json/checker/util/version.js +2 -2
- package/lib/mcfunction/checker/index.js +14 -11
- package/lib/mcfunction/colorizer/index.js +2 -4
- package/lib/mcfunction/common/index.js +46 -15
- package/lib/mcfunction/completer/argument.js +53 -24
- package/lib/mcfunction/index.js +13 -1
- package/lib/mcfunction/inlayHintProvider.js +8 -3
- package/lib/mcfunction/node/argument.d.ts +6 -6
- package/lib/mcfunction/node/argument.js +57 -17
- package/lib/mcfunction/parser/argument.js +158 -63
- package/lib/mcfunction/signatureHelpProvider.js +9 -4
- package/lib/mcfunction/tree/argument.d.ts +1 -1
- package/lib/mcfunction/tree/patch.js +132 -126
- package/package.json +7 -7
|
@@ -5,8 +5,8 @@ import { localeQuote, localize } from '@spyglassmc/locales';
|
|
|
5
5
|
import * as mcf from '@spyglassmc/mcfunction';
|
|
6
6
|
import * as nbt from '@spyglassmc/nbt';
|
|
7
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';
|
|
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';
|
|
10
10
|
const IntegerPattern = /^-?\d+$/;
|
|
11
11
|
/**
|
|
12
12
|
* A combination of:
|
|
@@ -24,7 +24,7 @@ const IntegerPattern = /^-?\d+$/;
|
|
|
24
24
|
const FloatPattern = /^-?(?:\d+\.?\d*|\.\d+)$/;
|
|
25
25
|
const DoubleMax = Number.MAX_VALUE;
|
|
26
26
|
const DoubleMin = -DoubleMax;
|
|
27
|
-
const FloatMax = (2 -
|
|
27
|
+
const FloatMax = (2 - 2 ** -23) * 2 ** 127;
|
|
28
28
|
const FloatMin = -FloatMax;
|
|
29
29
|
const IntegerMax = 2 ** 31 - 1;
|
|
30
30
|
const IntegerMin = -(2 ** 31);
|
|
@@ -66,7 +66,7 @@ export const argument = (rawTreeNode) => {
|
|
|
66
66
|
return wrap(greedyString);
|
|
67
67
|
}
|
|
68
68
|
case 'minecraft:angle':
|
|
69
|
-
return wrap(core.validate(coordinate(), res => res.notation !== '^', localize('mcfunction.parser.vector.local-disallowed')));
|
|
69
|
+
return wrap(core.validate(coordinate(), (res) => res.notation !== '^', localize('mcfunction.parser.vector.local-disallowed')));
|
|
70
70
|
case 'minecraft:block_pos':
|
|
71
71
|
return wrap(vector({ dimension: 3, integersOnly: true }));
|
|
72
72
|
case 'minecraft:block_predicate':
|
|
@@ -74,7 +74,7 @@ export const argument = (rawTreeNode) => {
|
|
|
74
74
|
case 'minecraft:block_state':
|
|
75
75
|
return wrap(blockState);
|
|
76
76
|
case 'minecraft:color':
|
|
77
|
-
return wrap(core.map(core.literal(...ColorArgumentValues), res => ({
|
|
77
|
+
return wrap(core.map(core.literal(...ColorArgumentValues), (res) => ({
|
|
78
78
|
...res,
|
|
79
79
|
color: core.Color.NamedColors.has(res.value)
|
|
80
80
|
? core.Color.fromCompositeInt(core.Color.NamedColors.get(res.value))
|
|
@@ -198,12 +198,12 @@ function block(isPredicate) {
|
|
|
198
198
|
trailingEnd: true,
|
|
199
199
|
},
|
|
200
200
|
end: ']',
|
|
201
|
-
})), res => ({
|
|
201
|
+
})), (res) => ({
|
|
202
202
|
...res,
|
|
203
203
|
type: 'mcfunction:block/states',
|
|
204
204
|
}))),
|
|
205
205
|
core.optional(core.failOnEmpty(nbt.parser.compound)),
|
|
206
|
-
]), res => {
|
|
206
|
+
]), (res) => {
|
|
207
207
|
const ans = {
|
|
208
208
|
type: 'mcfunction:block',
|
|
209
209
|
range: res.range,
|
|
@@ -271,7 +271,7 @@ function coordinate(integerOnly = false) {
|
|
|
271
271
|
function entity(amount, type) {
|
|
272
272
|
return core.map(core.select([
|
|
273
273
|
{
|
|
274
|
-
predicate: src => EntitySelectorAtVariable.is(src.peek(2)),
|
|
274
|
+
predicate: (src) => EntitySelectorAtVariable.is(src.peek(2)),
|
|
275
275
|
parser: selector(),
|
|
276
276
|
},
|
|
277
277
|
{
|
|
@@ -298,7 +298,11 @@ function entity(amount, type) {
|
|
|
298
298
|
if (amount === 'single' && ans.selector && !ans.selector.single) {
|
|
299
299
|
ctx.err.report(localize('mcfunction.parser.entity-selector.multiple-disallowed'), ans);
|
|
300
300
|
}
|
|
301
|
-
if (type === 'players' &&
|
|
301
|
+
if (type === 'players' &&
|
|
302
|
+
(ans.uuid ||
|
|
303
|
+
(ans.selector &&
|
|
304
|
+
!ans.selector.playersOnly &&
|
|
305
|
+
!ans.selector.currentEntity))) {
|
|
302
306
|
ctx.err.report(localize('mcfunction.parser.entity-selector.entities-disallowed'), ans);
|
|
303
307
|
}
|
|
304
308
|
return ans;
|
|
@@ -311,7 +315,7 @@ function item(isPredicate) {
|
|
|
311
315
|
return core.map(core.sequence([
|
|
312
316
|
core.resourceLocation({ category: 'item', allowTag: isPredicate }),
|
|
313
317
|
core.optional(core.failOnEmpty(nbt.parser.compound)),
|
|
314
|
-
]), res => {
|
|
318
|
+
]), (res) => {
|
|
315
319
|
const ans = {
|
|
316
320
|
type: 'mcfunction:item',
|
|
317
321
|
range: res.range,
|
|
@@ -343,7 +347,7 @@ const message = (src, ctx) => {
|
|
|
343
347
|
export const particle = (() => {
|
|
344
348
|
const sep = core.map(mcf.sep, () => []);
|
|
345
349
|
const vec = vector({ dimension: 3 });
|
|
346
|
-
const color = core.map(vec, res => ({
|
|
350
|
+
const color = core.map(vec, (res) => ({
|
|
347
351
|
...res,
|
|
348
352
|
color: res.children.length === 3
|
|
349
353
|
? {
|
|
@@ -366,11 +370,11 @@ export const particle = (() => {
|
|
|
366
370
|
return core.map(sequence([
|
|
367
371
|
core.resourceLocation({ category: 'particle_type' }),
|
|
368
372
|
{
|
|
369
|
-
get: res => {
|
|
373
|
+
get: (res) => {
|
|
370
374
|
return map[core.ResourceLocationNode.toString(res.children[0], 'short')];
|
|
371
375
|
},
|
|
372
376
|
},
|
|
373
|
-
], sep), res => {
|
|
377
|
+
], sep), (res) => {
|
|
374
378
|
const ans = {
|
|
375
379
|
type: 'mcfunction:particle',
|
|
376
380
|
range: res.range,
|
|
@@ -396,7 +400,9 @@ function range(type, min, max, cycleable) {
|
|
|
396
400
|
: res.children.filter(core.IntegerNode.is);
|
|
397
401
|
const sepNode = res.children.find(core.LiteralNode.is);
|
|
398
402
|
const ans = {
|
|
399
|
-
type: type === 'float'
|
|
403
|
+
type: type === 'float'
|
|
404
|
+
? 'mcfunction:float_range'
|
|
405
|
+
: 'mcfunction:int_range',
|
|
400
406
|
range: res.range,
|
|
401
407
|
children: res.children,
|
|
402
408
|
value: sepNode
|
|
@@ -407,7 +413,10 @@ function range(type, min, max, cycleable) {
|
|
|
407
413
|
: [undefined, valueNodes[0].value]
|
|
408
414
|
: [valueNodes[0].value, valueNodes[0].value],
|
|
409
415
|
};
|
|
410
|
-
if (!cycleable &&
|
|
416
|
+
if (!cycleable &&
|
|
417
|
+
ans.value[0] !== undefined &&
|
|
418
|
+
ans.value[1] !== undefined &&
|
|
419
|
+
ans.value[0] > ans.value[1]) {
|
|
411
420
|
ctx.err.report(localize('mcfunction.parser.range.min>max', ans.value[0], ans.value[1]), res);
|
|
412
421
|
}
|
|
413
422
|
return ans;
|
|
@@ -425,27 +434,42 @@ function selector() {
|
|
|
425
434
|
let single;
|
|
426
435
|
let typeLimited;
|
|
427
436
|
return core.map(core.sequence([
|
|
428
|
-
core.failOnEmpty(core.literal({
|
|
437
|
+
core.failOnEmpty(core.literal({
|
|
438
|
+
pool: EntitySelectorAtVariables,
|
|
439
|
+
colorTokenType: 'keyword',
|
|
440
|
+
})),
|
|
429
441
|
{
|
|
430
|
-
get: res => {
|
|
431
|
-
const variable = core.LiteralNode.is(res.children?.[0])
|
|
442
|
+
get: (res) => {
|
|
443
|
+
const variable = core.LiteralNode.is(res.children?.[0])
|
|
444
|
+
? res.children[0].value
|
|
445
|
+
: undefined;
|
|
432
446
|
currentEntity = variable ? variable === '@s' : undefined;
|
|
433
|
-
playersOnly = variable
|
|
447
|
+
playersOnly = variable
|
|
448
|
+
? variable === '@p' || variable === '@a' || variable === '@r'
|
|
449
|
+
: undefined;
|
|
434
450
|
predicates = variable === '@e' ? ['Entity::isAlive'] : undefined;
|
|
435
|
-
single = variable
|
|
451
|
+
single = variable
|
|
452
|
+
? variable === '@p' || variable === '@r' || variable === '@s'
|
|
453
|
+
: undefined;
|
|
436
454
|
typeLimited = playersOnly;
|
|
437
455
|
function invertable(parser) {
|
|
438
456
|
return core.map(core.sequence([
|
|
439
|
-
core.optional(core.failOnEmpty(core.literal({
|
|
440
|
-
|
|
457
|
+
core.optional(core.failOnEmpty(core.literal({
|
|
458
|
+
pool: ['!'],
|
|
459
|
+
colorTokenType: 'keyword',
|
|
460
|
+
}))),
|
|
461
|
+
(src) => {
|
|
462
|
+
src.skipSpace();
|
|
463
|
+
return undefined;
|
|
464
|
+
},
|
|
441
465
|
parser,
|
|
442
|
-
]), res => {
|
|
466
|
+
]), (res) => {
|
|
443
467
|
const ans = {
|
|
444
468
|
type: 'mcfunction:entity_selector/arguments/value/invertable',
|
|
445
469
|
range: res.range,
|
|
446
470
|
children: res.children,
|
|
447
|
-
inverted: !!res.children.find(n => core.LiteralNode.is(n) && n.value === '!'),
|
|
448
|
-
value: res.children.find(n => !core.LiteralNode.is(n) || n.value !== '!'),
|
|
471
|
+
inverted: !!res.children.find((n) => core.LiteralNode.is(n) && n.value === '!'),
|
|
472
|
+
value: res.children.find((n) => !core.LiteralNode.is(n) || n.value !== '!'),
|
|
449
473
|
};
|
|
450
474
|
return ans;
|
|
451
475
|
});
|
|
@@ -456,36 +480,45 @@ function selector() {
|
|
|
456
480
|
key: core.string({
|
|
457
481
|
...core.BrigadierStringOptions,
|
|
458
482
|
value: {
|
|
459
|
-
parser: core.literal({
|
|
483
|
+
parser: core.literal({
|
|
484
|
+
pool: [
|
|
485
|
+
...EntitySelectorNode.ArgumentKeys,
|
|
486
|
+
],
|
|
487
|
+
colorTokenType: 'property',
|
|
488
|
+
}),
|
|
460
489
|
type: 'literal',
|
|
461
490
|
},
|
|
462
491
|
}),
|
|
463
492
|
sep: '=',
|
|
464
493
|
value: {
|
|
465
494
|
get: (record, key) => {
|
|
466
|
-
const hasKey = (key) => !!record.children.find(p => p.key?.value === key);
|
|
467
|
-
const hasNonInvertedKey = (key) => !!record.children.find(p => p.key?.value === key &&
|
|
495
|
+
const hasKey = (key) => !!record.children.find((p) => p.key?.value === key);
|
|
496
|
+
const hasNonInvertedKey = (key) => !!record.children.find((p) => p.key?.value === key &&
|
|
497
|
+
!p.value?.inverted);
|
|
468
498
|
switch (key?.value) {
|
|
469
499
|
case 'advancements':
|
|
470
500
|
return core.map(core.record({
|
|
471
501
|
start: '{',
|
|
472
502
|
pair: {
|
|
473
|
-
key: core.resourceLocation({
|
|
503
|
+
key: core.resourceLocation({
|
|
504
|
+
category: 'advancement',
|
|
505
|
+
}),
|
|
474
506
|
sep: '=',
|
|
475
507
|
value: core.select([
|
|
476
508
|
{
|
|
477
|
-
predicate: src => src.peek() === '{',
|
|
509
|
+
predicate: (src) => src.peek() === '{',
|
|
478
510
|
parser: core.map(core.record({
|
|
479
511
|
start: '{',
|
|
480
512
|
pair: {
|
|
481
513
|
key: unquotedString,
|
|
482
514
|
sep: '=',
|
|
483
|
-
value: core
|
|
515
|
+
value: core
|
|
516
|
+
.boolean,
|
|
484
517
|
end: ',',
|
|
485
518
|
trailingEnd: true,
|
|
486
519
|
},
|
|
487
520
|
end: '}',
|
|
488
|
-
}), res => {
|
|
521
|
+
}), (res) => {
|
|
489
522
|
const ans = {
|
|
490
523
|
...res,
|
|
491
524
|
type: 'mcfunction:entity_selector/arguments/advancements/criteria',
|
|
@@ -515,7 +548,8 @@ function selector() {
|
|
|
515
548
|
return core.map(range('float', 0), (res, _, ctx) => {
|
|
516
549
|
dimensionLimited = true;
|
|
517
550
|
// x, y, z, dx, dy, dz take precedence over distance, so we use ??= instead of = to ensure it won't override the result.
|
|
518
|
-
chunkLimited ??= !playersOnly &&
|
|
551
|
+
chunkLimited ??= !playersOnly &&
|
|
552
|
+
res.value[1] !== undefined;
|
|
519
553
|
if (hasKey(key.value)) {
|
|
520
554
|
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
521
555
|
}
|
|
@@ -523,14 +557,17 @@ function selector() {
|
|
|
523
557
|
});
|
|
524
558
|
case 'gamemode':
|
|
525
559
|
return core.map(invertable(core.string({
|
|
526
|
-
unquotable: core
|
|
560
|
+
unquotable: core
|
|
561
|
+
.BrigadierUnquotableOption,
|
|
527
562
|
value: {
|
|
528
563
|
type: 'literal',
|
|
529
564
|
parser: core.literal('adventure', 'creative', 'spectator', 'survival'),
|
|
530
565
|
},
|
|
531
566
|
})), (res, _, ctx) => {
|
|
532
567
|
playersOnly = true;
|
|
533
|
-
if (res.inverted
|
|
568
|
+
if (res.inverted
|
|
569
|
+
? hasNonInvertedKey(key.value)
|
|
570
|
+
: hasKey(key.value)) {
|
|
534
571
|
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
535
572
|
}
|
|
536
573
|
return res;
|
|
@@ -556,7 +593,9 @@ function selector() {
|
|
|
556
593
|
});
|
|
557
594
|
case 'name':
|
|
558
595
|
return core.map(invertable(core.brigadierString), (res, _, ctx) => {
|
|
559
|
-
if (res.inverted
|
|
596
|
+
if (res.inverted
|
|
597
|
+
? hasNonInvertedKey(key.value)
|
|
598
|
+
: hasKey(key.value)) {
|
|
560
599
|
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
561
600
|
}
|
|
562
601
|
return res;
|
|
@@ -564,12 +603,21 @@ function selector() {
|
|
|
564
603
|
case 'nbt':
|
|
565
604
|
return invertable(nbt.parser.compound);
|
|
566
605
|
case 'predicate':
|
|
567
|
-
return invertable(core.resourceLocation({
|
|
606
|
+
return invertable(core.resourceLocation({
|
|
607
|
+
category: 'predicate',
|
|
608
|
+
}));
|
|
568
609
|
case 'scores':
|
|
569
610
|
return core.map(core.record({
|
|
570
611
|
start: '{',
|
|
571
612
|
pair: {
|
|
572
|
-
key: objective('reference', [
|
|
613
|
+
key: objective('reference', [
|
|
614
|
+
'[',
|
|
615
|
+
'=',
|
|
616
|
+
',',
|
|
617
|
+
']',
|
|
618
|
+
'{',
|
|
619
|
+
'}',
|
|
620
|
+
]),
|
|
573
621
|
sep: '=',
|
|
574
622
|
value: range('integer'),
|
|
575
623
|
end: ',',
|
|
@@ -588,7 +636,8 @@ function selector() {
|
|
|
588
636
|
});
|
|
589
637
|
case 'sort':
|
|
590
638
|
return core.map(core.string({
|
|
591
|
-
unquotable: core
|
|
639
|
+
unquotable: core
|
|
640
|
+
.BrigadierUnquotableOption,
|
|
592
641
|
value: {
|
|
593
642
|
type: 'literal',
|
|
594
643
|
parser: core.literal('arbitrary', 'furthest', 'nearest', 'random'),
|
|
@@ -603,16 +652,35 @@ function selector() {
|
|
|
603
652
|
return res;
|
|
604
653
|
});
|
|
605
654
|
case 'tag':
|
|
606
|
-
return invertable(tag([
|
|
655
|
+
return invertable(tag([
|
|
656
|
+
'[',
|
|
657
|
+
'=',
|
|
658
|
+
',',
|
|
659
|
+
']',
|
|
660
|
+
'{',
|
|
661
|
+
'}',
|
|
662
|
+
]));
|
|
607
663
|
case 'team':
|
|
608
|
-
return core.map(invertable(team('reference', [
|
|
609
|
-
|
|
664
|
+
return core.map(invertable(team('reference', [
|
|
665
|
+
'[',
|
|
666
|
+
'=',
|
|
667
|
+
',',
|
|
668
|
+
']',
|
|
669
|
+
'{',
|
|
670
|
+
'}',
|
|
671
|
+
])), (res, _, ctx) => {
|
|
672
|
+
if (res.inverted
|
|
673
|
+
? hasNonInvertedKey(key.value)
|
|
674
|
+
: hasKey(key.value)) {
|
|
610
675
|
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
611
676
|
}
|
|
612
677
|
return res;
|
|
613
678
|
});
|
|
614
679
|
case 'type':
|
|
615
|
-
return core.map(invertable(core.resourceLocation({
|
|
680
|
+
return core.map(invertable(core.resourceLocation({
|
|
681
|
+
category: 'entity_type',
|
|
682
|
+
allowTag: true,
|
|
683
|
+
})), (res, _, ctx) => {
|
|
616
684
|
if (typeLimited) {
|
|
617
685
|
if (hasKey(key.value)) {
|
|
618
686
|
ctx.err.report(localize('duplicate-key', localeQuote(key.value)), key);
|
|
@@ -621,9 +689,11 @@ function selector() {
|
|
|
621
689
|
ctx.err.report(localize('mcfunction.parser.entity-selector.arguments.not-applicable', localeQuote(key.value)), key);
|
|
622
690
|
}
|
|
623
691
|
}
|
|
624
|
-
else if (!res.inverted &&
|
|
692
|
+
else if (!res.inverted &&
|
|
693
|
+
!res.value.isTag) {
|
|
625
694
|
typeLimited = true;
|
|
626
|
-
if (core.ResourceLocationNode
|
|
695
|
+
if (core.ResourceLocationNode
|
|
696
|
+
.toString(res.value, 'short') === 'player') {
|
|
627
697
|
playersOnly = true;
|
|
628
698
|
}
|
|
629
699
|
}
|
|
@@ -674,7 +744,7 @@ function selector() {
|
|
|
674
744
|
trailingEnd: true,
|
|
675
745
|
},
|
|
676
746
|
end: ']',
|
|
677
|
-
})), res => {
|
|
747
|
+
})), (res) => {
|
|
678
748
|
const ans = {
|
|
679
749
|
...res,
|
|
680
750
|
type: 'mcfunction:entity_selector/arguments',
|
|
@@ -683,12 +753,14 @@ function selector() {
|
|
|
683
753
|
}));
|
|
684
754
|
},
|
|
685
755
|
},
|
|
686
|
-
]), res => {
|
|
756
|
+
]), (res) => {
|
|
687
757
|
const ans = {
|
|
688
758
|
type: 'mcfunction:entity_selector',
|
|
689
759
|
range: res.range,
|
|
690
760
|
children: res.children,
|
|
691
|
-
variable: res.children
|
|
761
|
+
variable: res.children
|
|
762
|
+
.find(core.LiteralNode.is)
|
|
763
|
+
.value.slice(1),
|
|
692
764
|
arguments: res.children.find(EntitySelectorArgumentsNode.is),
|
|
693
765
|
chunkLimited,
|
|
694
766
|
currentEntity,
|
|
@@ -718,7 +790,12 @@ function getEntitySelectorHover(node) {
|
|
|
718
790
|
- \`currentEntity\`: \`${node.currentEntity}\``;
|
|
719
791
|
}
|
|
720
792
|
else {
|
|
721
|
-
const amountOfTrue = [
|
|
793
|
+
const amountOfTrue = [
|
|
794
|
+
node.chunkLimited,
|
|
795
|
+
node.dimensionLimited,
|
|
796
|
+
node.playersOnly,
|
|
797
|
+
node.typeLimited,
|
|
798
|
+
].filter((v) => v).length;
|
|
722
799
|
ans = `**Performance**: ${grades.get(amountOfTrue)}
|
|
723
800
|
- \`chunkLimited\`: \`${!!node.chunkLimited}\`
|
|
724
801
|
- \`dimensionLimited\`: \`${!!node.dimensionLimited}\`
|
|
@@ -730,7 +807,7 @@ function getEntitySelectorHover(node) {
|
|
|
730
807
|
|
|
731
808
|
------
|
|
732
809
|
**Predicates**:
|
|
733
|
-
${node.predicates.map(p => `- \`${p}\``).join('\n')}`;
|
|
810
|
+
${node.predicates.map((p) => `- \`${p}\``).join('\n')}`;
|
|
734
811
|
}
|
|
735
812
|
return ans;
|
|
736
813
|
}
|
|
@@ -738,7 +815,7 @@ export const scoreHolderFakeName = validateLength(symbol('score_holder'), FakeNa
|
|
|
738
815
|
function scoreHolder(amount) {
|
|
739
816
|
return core.map(core.select([
|
|
740
817
|
{
|
|
741
|
-
predicate: src => EntitySelectorAtVariable.is(src.peek(2)),
|
|
818
|
+
predicate: (src) => EntitySelectorAtVariable.is(src.peek(2)),
|
|
742
819
|
parser: selector(),
|
|
743
820
|
},
|
|
744
821
|
{
|
|
@@ -768,24 +845,36 @@ function symbol(options, terminators = []) {
|
|
|
768
845
|
function objective(usageType, terminators = []) {
|
|
769
846
|
return validateLength(unquotableSymbol({ category: 'objective', usageType }, terminators), ObjectiveMaxLength, 'mcfunction.parser.objective.too-long');
|
|
770
847
|
}
|
|
771
|
-
const objectiveCriteria = core
|
|
848
|
+
const objectiveCriteria = core
|
|
849
|
+
.map(core.any([
|
|
772
850
|
core.sequence([
|
|
773
|
-
core.stopBefore(core.resourceLocation({
|
|
851
|
+
core.stopBefore(core.resourceLocation({
|
|
852
|
+
category: 'stat_type',
|
|
853
|
+
namespacePathSep: '.',
|
|
854
|
+
}), ':'),
|
|
774
855
|
core.failOnEmpty(core.literal(':')),
|
|
775
856
|
{
|
|
776
|
-
get: res => {
|
|
857
|
+
get: (res) => {
|
|
777
858
|
if (core.ResourceLocationNode.is(res.children[0])) {
|
|
778
|
-
const category = ObjectiveCriteriaNode.ComplexCategories
|
|
859
|
+
const category = ObjectiveCriteriaNode.ComplexCategories
|
|
860
|
+
.get(core.ResourceLocationNode.toString(res.children[0], 'short'));
|
|
779
861
|
if (category) {
|
|
780
|
-
return core.resourceLocation({
|
|
862
|
+
return core.resourceLocation({
|
|
863
|
+
category,
|
|
864
|
+
namespacePathSep: '.',
|
|
865
|
+
});
|
|
781
866
|
}
|
|
782
867
|
}
|
|
783
|
-
return core.resourceLocation({
|
|
868
|
+
return core.resourceLocation({
|
|
869
|
+
pool: [],
|
|
870
|
+
allowUnknown: true,
|
|
871
|
+
namespacePathSep: '.',
|
|
872
|
+
});
|
|
784
873
|
},
|
|
785
874
|
},
|
|
786
875
|
]),
|
|
787
876
|
core.literal(...ObjectiveCriteriaNode.SimpleValues),
|
|
788
|
-
]), res => {
|
|
877
|
+
]), (res) => {
|
|
789
878
|
const ans = {
|
|
790
879
|
type: 'mcfunction:objective_criteria',
|
|
791
880
|
range: res.range,
|
|
@@ -807,7 +896,10 @@ export function team(usageType, terminators = []) {
|
|
|
807
896
|
function unquotableSymbol(options, terminators) {
|
|
808
897
|
return validateUnquotable(symbol(options, terminators));
|
|
809
898
|
}
|
|
810
|
-
const time = core.map(core.sequence([
|
|
899
|
+
const time = core.map(core.sequence([
|
|
900
|
+
float(0, undefined),
|
|
901
|
+
core.optional(core.failOnEmpty(core.literal(...TimeNode.Units))),
|
|
902
|
+
]), (res) => {
|
|
811
903
|
const valueNode = res.children.find(core.FloatNode.is);
|
|
812
904
|
const unitNode = res.children.find(core.LiteralNode.is);
|
|
813
905
|
const ans = {
|
|
@@ -840,8 +932,8 @@ const uuid = (src, ctx) => {
|
|
|
840
932
|
let isLegal = false;
|
|
841
933
|
if (raw.match(UuidPattern)) {
|
|
842
934
|
try {
|
|
843
|
-
const parts = raw.split('-').map(p => BigInt(`0x${p}`));
|
|
844
|
-
if (parts.every(p => p <= LongMax)) {
|
|
935
|
+
const parts = raw.split('-').map((p) => BigInt(`0x${p}`));
|
|
936
|
+
if (parts.every((p) => p <= LongMax)) {
|
|
845
937
|
isLegal = true;
|
|
846
938
|
ans.bits[0] = BigInt.asIntN(64, (parts[0] << 32n) | (parts[1] << 16n) | parts[2]);
|
|
847
939
|
ans.bits[1] = BigInt.asIntN(64, (parts[3] << 48n) | parts[4]);
|
|
@@ -894,9 +986,12 @@ function vector(options) {
|
|
|
894
986
|
if (i > 0) {
|
|
895
987
|
mcf.sep(src, ctx);
|
|
896
988
|
}
|
|
897
|
-
const coord = options.integersOnly
|
|
989
|
+
const coord = options.integersOnly
|
|
990
|
+
? coordinate(options.integersOnly)(src, ctx)
|
|
991
|
+
: coordinate(options.integersOnly)(src, ctx);
|
|
898
992
|
ans.children.push(coord);
|
|
899
|
-
if ((ans.system === 1 /* CoordinateSystem.Local */) !==
|
|
993
|
+
if ((ans.system === 1 /* CoordinateSystem.Local */) !==
|
|
994
|
+
(coord.notation === '^')) {
|
|
900
995
|
ctx.err.report(localize('mcfunction.parser.vector.mixed'), coord);
|
|
901
996
|
}
|
|
902
997
|
}
|
|
@@ -35,9 +35,11 @@ export function signatureHelpProvider(commandTreeName) {
|
|
|
35
35
|
activeSignature: 0,
|
|
36
36
|
signatures: [],
|
|
37
37
|
};
|
|
38
|
-
ans.signatures = options.map(v => {
|
|
38
|
+
ans.signatures = options.map((v) => {
|
|
39
39
|
const part1 = v[selectedIndex];
|
|
40
|
-
const part2 = selectedIndex + 1 < v.length
|
|
40
|
+
const part2 = selectedIndex + 1 < v.length
|
|
41
|
+
? ` ${v[selectedIndex + 1]}`
|
|
42
|
+
: '';
|
|
41
43
|
const label = `${part1}${part2}`;
|
|
42
44
|
return {
|
|
43
45
|
label,
|
|
@@ -63,7 +65,8 @@ function getOptions(rootTreeNode, argumentNodes) {
|
|
|
63
65
|
if (!name) {
|
|
64
66
|
break;
|
|
65
67
|
}
|
|
66
|
-
treeNode = mcf.resolveParentTreeNode(treeNode, rootTreeNode).treeNode
|
|
68
|
+
treeNode = mcf.resolveParentTreeNode(treeNode, rootTreeNode).treeNode
|
|
69
|
+
?.children?.[name];
|
|
67
70
|
if (!treeNode) {
|
|
68
71
|
break;
|
|
69
72
|
}
|
|
@@ -72,7 +75,9 @@ function getOptions(rootTreeNode, argumentNodes) {
|
|
|
72
75
|
if (treeNode) {
|
|
73
76
|
treeNode = mcf.resolveParentTreeNode(treeNode, rootTreeNode).treeNode;
|
|
74
77
|
if (treeNode?.children) {
|
|
75
|
-
return mcf
|
|
78
|
+
return mcf
|
|
79
|
+
.treeNodeChildrenToStringArray(treeNode.children, treeNode.executable)
|
|
80
|
+
.map((v) => [...current, v]);
|
|
76
81
|
}
|
|
77
82
|
}
|
|
78
83
|
return current.length ? [current] : [];
|
|
@@ -175,5 +175,5 @@ export interface MinecraftVec3ArgumentTreeNode extends mcf.ArgumentTreeNode {
|
|
|
175
175
|
export interface SpyglassmcTagArgumentTreeNode extends mcf.ArgumentTreeNode {
|
|
176
176
|
parser: 'spyglassmc:tag';
|
|
177
177
|
}
|
|
178
|
-
export
|
|
178
|
+
export type ArgumentTreeNode = BrigadierBoolArgumentTreeNode | BrigadierDoubleArgumentTreeNode | BrigadierFloatArgumentTreeNode | BrigadierIntegerArgumentTreeNode | BrigadierLongArgumentTreeNode | BrigadierStringArgumentTreeNode | MinecraftAngleArgumentTreeNode | MinecraftBlockPosArgumentTreeNode | MinecraftBlockPredicateArgumentTreeNode | MinecraftBlockStateArgumentTreeNode | MinecraftColorArgumentTreeNode | MinecraftColumnPosArgumentTreeNode | MinecraftComponentArgumentTreeNode | MinecraftDimensionArgumentTreeNode | MinecraftEntityArgumentTreeNode | MinecraftEntityAnchorArgumentTreeNode | MinecraftEntitySummonArgumentTreeNode | MinecraftFloatRangeArgumentTreeNode | MinecraftFunctionArgumentTreeNode | MinecraftGameProfileArgumentTreeNode | MinecraftIntRangeArgumentTreeNode | MinecraftItemEnchantmentArgumentTreeNode | MinecraftItemPredicateArgumentTreeNode | MinecraftItemSlotArgumentTreeNode | MinecraftItemStackArgumentTreeNode | MinecraftMessageArgumentTreeNode | MinecraftMobEffectArgumentTreeNode | MinecraftNbtCompoundTagArgumentTreeNode | MinecraftNbtPathArgumentTreeNode | MinecraftNbtTagArgumentTreeNode | MinecraftObjectiveArgumentTreeNode | MinecraftObjectiveCriteriaArgumentTreeNode | MinecraftOperationArgumentTreeNode | MinecraftParticleArgumentTreeNode | MinecraftResourceArgumentTreeNode | MinecraftResourceLocationArgumentTreeNode | MinecraftResourceOrTagArgumentTreeNode | MinecraftRotationArgumentTreeNode | MinecraftScoreHolderArgumentTreeNode | MinecraftScoreboardSlotArgumentTreeNode | MinecraftSwizzleArgumentTreeNode | MinecraftTeamArgumentTreeNode | MinecraftTimeArgumentTreeNode | MinecraftUuidArgumentTreeNode | MinecraftVec2ArgumentTreeNode | MinecraftVec3ArgumentTreeNode | SpyglassmcTagArgumentTreeNode;
|
|
179
179
|
//# sourceMappingURL=argument.d.ts.map
|