@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,44 +1,17 @@
|
|
|
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.register = exports.getTypesFromEntity = exports.command = void 0;
|
|
27
|
-
const core = __importStar(require("@spyglassmc/core"));
|
|
28
|
-
const json = __importStar(require("@spyglassmc/json"));
|
|
29
|
-
const lib_1 = require("@spyglassmc/locales/lib");
|
|
30
|
-
const mcf = __importStar(require("@spyglassmc/mcfunction"));
|
|
31
|
-
const nbt = __importStar(require("@spyglassmc/nbt"));
|
|
32
|
-
const common_1 = require("../../common");
|
|
33
|
-
const text_component_1 = require("../../json/checker/data/text_component");
|
|
34
|
-
const node_1 = require("../node");
|
|
35
|
-
const command = (node, ctx) => {
|
|
1
|
+
import * as core from '@spyglassmc/core';
|
|
2
|
+
import * as json from '@spyglassmc/json';
|
|
3
|
+
import { localize } from '@spyglassmc/locales';
|
|
4
|
+
import * as mcf from '@spyglassmc/mcfunction';
|
|
5
|
+
import * as nbt from '@spyglassmc/nbt';
|
|
6
|
+
import { getTagValues } from '../../common/index.js';
|
|
7
|
+
import { text_component } from '../../json/checker/data/text_component.js';
|
|
8
|
+
import { BlockNode, EntityNode, ItemNode, ParticleNode } from '../node/index.js';
|
|
9
|
+
export const command = (node, ctx) => {
|
|
36
10
|
if (node.slash && node.parent && mcf.McfunctionNode.is(node.parent)) {
|
|
37
|
-
ctx.err.report(
|
|
11
|
+
ctx.err.report(localize('unexpected-leading-slash'), node.slash);
|
|
38
12
|
}
|
|
39
13
|
rootCommand(node.children, 0, ctx);
|
|
40
14
|
};
|
|
41
|
-
exports.command = command;
|
|
42
15
|
const getName = (nodes, index) => {
|
|
43
16
|
return nodes[index]?.path[nodes[index].path.length - 1];
|
|
44
17
|
};
|
|
@@ -47,20 +20,20 @@ const getNode = (nodes, index) => {
|
|
|
47
20
|
};
|
|
48
21
|
const rootCommand = (nodes, index, ctx) => {
|
|
49
22
|
for (const { children: [node] } of nodes) {
|
|
50
|
-
if (
|
|
23
|
+
if (BlockNode.is(node)) {
|
|
51
24
|
block(node, ctx);
|
|
52
25
|
}
|
|
53
|
-
else if (
|
|
26
|
+
else if (EntityNode.is(node)) {
|
|
54
27
|
entity(node, ctx);
|
|
55
28
|
}
|
|
56
|
-
else if (
|
|
29
|
+
else if (ItemNode.is(node)) {
|
|
57
30
|
item(node, ctx);
|
|
58
31
|
}
|
|
59
|
-
else if (
|
|
32
|
+
else if (ParticleNode.is(node)) {
|
|
60
33
|
particle(node, ctx);
|
|
61
34
|
}
|
|
62
35
|
else if (json.JsonNode.is(node)) {
|
|
63
|
-
|
|
36
|
+
text_component(node, { ...ctx, context: '' });
|
|
64
37
|
}
|
|
65
38
|
}
|
|
66
39
|
if (getName(nodes, index) === 'data') {
|
|
@@ -162,7 +135,7 @@ const entity = (node, ctx) => {
|
|
|
162
135
|
if (!nbtPair) {
|
|
163
136
|
return;
|
|
164
137
|
}
|
|
165
|
-
const types =
|
|
138
|
+
const types = getTypesFromEntity(node, ctx);
|
|
166
139
|
const nbtValue = nbtPair.value;
|
|
167
140
|
nbt.checker.index('entity_type', types)(nbtValue, ctx);
|
|
168
141
|
};
|
|
@@ -195,8 +168,8 @@ const dataMergeTarget = (nodes, index, ctx) => {
|
|
|
195
168
|
case 'entity': {
|
|
196
169
|
const entityNode = getNode(nodes, index + 1);
|
|
197
170
|
const nbtNode = getNode(nodes, index + 2);
|
|
198
|
-
if (
|
|
199
|
-
const types =
|
|
171
|
+
if (EntityNode.is(entityNode) && nbt.NbtCompoundNode.is(nbtNode)) {
|
|
172
|
+
const types = getTypesFromEntity(entityNode, ctx);
|
|
200
173
|
nbt.checker.index('entity_type', types)(nbtNode, ctx);
|
|
201
174
|
}
|
|
202
175
|
break;
|
|
@@ -229,8 +202,8 @@ const nbtPath = (nodes, index, ctx) => {
|
|
|
229
202
|
case 'entity': {
|
|
230
203
|
const entityNode = getNode(nodes, index + 1);
|
|
231
204
|
const nbtNode = getNode(nodes, index + 2);
|
|
232
|
-
if (
|
|
233
|
-
const types =
|
|
205
|
+
if (EntityNode.is(entityNode) && nbt.NbtPathNode.is(nbtNode)) {
|
|
206
|
+
const types = getTypesFromEntity(entityNode, ctx);
|
|
234
207
|
nbt.checker.path('entity_type', types)(nbtNode, ctx);
|
|
235
208
|
}
|
|
236
209
|
break;
|
|
@@ -256,7 +229,7 @@ const summonNbt = (nodes, index, ctx) => {
|
|
|
256
229
|
}
|
|
257
230
|
};
|
|
258
231
|
//#endregion
|
|
259
|
-
const getTypesFromEntity = (entity, ctx) => {
|
|
232
|
+
export const getTypesFromEntity = (entity, ctx) => {
|
|
260
233
|
if (entity.playerName !== undefined || entity.selector?.playersOnly) {
|
|
261
234
|
return ['minecraft:player'];
|
|
262
235
|
}
|
|
@@ -276,7 +249,7 @@ const getTypesFromEntity = (entity, ctx) => {
|
|
|
276
249
|
}
|
|
277
250
|
const value = core.ResourceLocationNode.toString(valueNode.value, 'full');
|
|
278
251
|
if (value.startsWith(core.ResourceLocation.TagPrefix)) {
|
|
279
|
-
const tagValues =
|
|
252
|
+
const tagValues = getTagValues('tag/entity_type', value.slice(1), ctx);
|
|
280
253
|
types = types.filter(t => tagValues.includes(t));
|
|
281
254
|
}
|
|
282
255
|
else {
|
|
@@ -287,13 +260,11 @@ const getTypesFromEntity = (entity, ctx) => {
|
|
|
287
260
|
}
|
|
288
261
|
return undefined;
|
|
289
262
|
};
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
meta.registerChecker('mcfunction:command', exports.command);
|
|
263
|
+
export function register(meta) {
|
|
264
|
+
meta.registerChecker('mcfunction:command', command);
|
|
293
265
|
meta.registerChecker('mcfunction:block', block);
|
|
294
266
|
meta.registerChecker('mcfunction:entity', entity);
|
|
295
267
|
meta.registerChecker('mcfunction:item', item);
|
|
296
268
|
meta.registerChecker('mcfunction:particle', particle);
|
|
297
269
|
}
|
|
298
|
-
exports.register = register;
|
|
299
270
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as core from '@spyglassmc/core';
|
|
2
|
-
import type { ObjectiveCriteriaNode, VectorNode } from '../node';
|
|
2
|
+
import type { ObjectiveCriteriaNode, VectorNode } from '../node/index.js';
|
|
3
3
|
export declare const objectiveCriterion: core.Colorizer<ObjectiveCriteriaNode>;
|
|
4
4
|
export declare const vector: core.Colorizer<VectorNode>;
|
|
5
5
|
export declare function register(meta: core.MetaRegistry): void;
|
|
@@ -1,42 +1,13 @@
|
|
|
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.register = exports.vector = exports.objectiveCriterion = void 0;
|
|
27
|
-
const core = __importStar(require("@spyglassmc/core"));
|
|
28
|
-
const objectiveCriterion = node => [
|
|
1
|
+
import * as core from '@spyglassmc/core';
|
|
2
|
+
export const objectiveCriterion = node => [
|
|
29
3
|
core.ColorToken.create(node, 'type'),
|
|
30
4
|
];
|
|
31
|
-
|
|
32
|
-
const vector = node => {
|
|
5
|
+
export const vector = node => {
|
|
33
6
|
return [core.ColorToken.create(node, 'vector')];
|
|
34
7
|
};
|
|
35
|
-
|
|
36
|
-
function register(meta) {
|
|
8
|
+
export function register(meta) {
|
|
37
9
|
meta.registerColorizer('mcfunction:coordinate', core.colorizer.number);
|
|
38
|
-
meta.registerColorizer('mcfunction:vector',
|
|
39
|
-
meta.registerColorizer('mcfunction:objective_criteria',
|
|
10
|
+
meta.registerColorizer('mcfunction:vector', vector);
|
|
11
|
+
meta.registerColorizer('mcfunction:objective_criteria', objectiveCriterion);
|
|
40
12
|
}
|
|
41
|
-
exports.register = register;
|
|
42
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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.SwizzleArgumentValues = exports.ScoreboardSlotArgumentValues = exports.OperationArgumentValues = exports.ItemSlotArgumentValues = exports.EntityAnchorArgumentValues = exports.ColorArgumentValues = void 0;
|
|
27
|
-
const core = __importStar(require("@spyglassmc/core"));
|
|
28
|
-
exports.ColorArgumentValues = [...core.Color.ColorNames, 'reset'];
|
|
29
|
-
exports.EntityAnchorArgumentValues = ['feet', 'eyes'];
|
|
30
|
-
exports.ItemSlotArgumentValues = [
|
|
1
|
+
import * as core from '@spyglassmc/core';
|
|
2
|
+
export const ColorArgumentValues = [...core.Color.ColorNames, 'reset'];
|
|
3
|
+
export const EntityAnchorArgumentValues = ['feet', 'eyes'];
|
|
4
|
+
export const ItemSlotArgumentValues = [
|
|
31
5
|
...[...Array(54).keys()].map(n => `container.${n}`),
|
|
32
6
|
...[...Array(27).keys()].map(n => `enderchest.${n}`),
|
|
33
7
|
...[...Array(15).keys()].map(n => `horse.${n}`),
|
|
@@ -38,12 +12,12 @@ exports.ItemSlotArgumentValues = [
|
|
|
38
12
|
'horse.armor', 'horse.chest', 'horse.saddle',
|
|
39
13
|
'weapon', 'weapon.mainhand', 'weapon.offhand',
|
|
40
14
|
];
|
|
41
|
-
|
|
42
|
-
|
|
15
|
+
export const OperationArgumentValues = ['=', '+=', '-=', '*=', '/=', '%=', '<', '>', '><'];
|
|
16
|
+
export const ScoreboardSlotArgumentValues = [
|
|
43
17
|
'belowName', 'list', 'sidebar',
|
|
44
18
|
...core.Color.ColorNames.map(n => `sidebar.team.${n}`),
|
|
45
19
|
];
|
|
46
|
-
|
|
20
|
+
export const SwizzleArgumentValues = [
|
|
47
21
|
'x', 'xy', 'xz', 'xyz', 'xzy',
|
|
48
22
|
'y', 'yx', 'yz', 'yxz', 'yzx',
|
|
49
23
|
'z', 'zx', 'zy', 'zxy', 'zyx',
|
|
@@ -1,40 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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.register = exports.getMockNodes = void 0;
|
|
27
|
-
const core_1 = require("@spyglassmc/core");
|
|
28
|
-
const json = __importStar(require("@spyglassmc/json"));
|
|
29
|
-
const locales_1 = require("@spyglassmc/locales");
|
|
30
|
-
const common_1 = require("../../common");
|
|
31
|
-
const common_2 = require("../common");
|
|
32
|
-
const node_1 = require("../node");
|
|
33
|
-
const getMockNodes = (rawTreeNode, range) => {
|
|
1
|
+
import { AstNode, BooleanNode, BrigadierStringOptions, completer, CompletionItem, FloatNode, getStates, InsertTextBuilder, IntegerNode, LiteralNode, Range, ResourceLocation, ResourceLocationNode, StringNode, SymbolNode } from '@spyglassmc/core';
|
|
2
|
+
import * as json from '@spyglassmc/json';
|
|
3
|
+
import { localeQuote, localize } from '@spyglassmc/locales';
|
|
4
|
+
import { getTagValues } from '../../common/index.js';
|
|
5
|
+
import { ColorArgumentValues, EntityAnchorArgumentValues, ItemSlotArgumentValues, OperationArgumentValues, ScoreboardSlotArgumentValues, SwizzleArgumentValues } from '../common/index.js';
|
|
6
|
+
import { BlockNode, CoordinateNode, EntitySelectorNode, IntRangeNode, ItemNode, ObjectiveCriteriaNode, ParticleNode, ScoreHolderNode, VectorNode } from '../node/index.js';
|
|
7
|
+
export const getMockNodes = (rawTreeNode, range) => {
|
|
34
8
|
const treeNode = rawTreeNode;
|
|
35
9
|
switch (treeNode.parser) {
|
|
36
10
|
case 'brigadier:bool':
|
|
37
|
-
return
|
|
11
|
+
return BooleanNode.mock(range);
|
|
38
12
|
case 'brigadier:double':
|
|
39
13
|
case 'brigadier:float':
|
|
40
14
|
case 'brigadier:integer':
|
|
@@ -46,20 +20,20 @@ const getMockNodes = (rawTreeNode, range) => {
|
|
|
46
20
|
return [];
|
|
47
21
|
case 'brigadier:string':
|
|
48
22
|
return treeNode.properties.type === 'phrase'
|
|
49
|
-
?
|
|
23
|
+
? StringNode.mock(range, BrigadierStringOptions)
|
|
50
24
|
: [];
|
|
51
25
|
case 'minecraft:angle':
|
|
52
|
-
return
|
|
26
|
+
return CoordinateNode.mock(range);
|
|
53
27
|
case 'minecraft:block_pos':
|
|
54
|
-
return
|
|
28
|
+
return VectorNode.mock(range, { dimension: 3, integersOnly: true });
|
|
55
29
|
case 'minecraft:block_predicate':
|
|
56
|
-
return
|
|
30
|
+
return BlockNode.mock(range, true);
|
|
57
31
|
case 'minecraft:block_state':
|
|
58
|
-
return
|
|
32
|
+
return BlockNode.mock(range, false);
|
|
59
33
|
case 'minecraft:color':
|
|
60
|
-
return
|
|
34
|
+
return LiteralNode.mock(range, { pool: ColorArgumentValues });
|
|
61
35
|
case 'minecraft:column_pos':
|
|
62
|
-
return
|
|
36
|
+
return VectorNode.mock(range, { dimension: 2, integersOnly: true });
|
|
63
37
|
case 'minecraft:component':
|
|
64
38
|
return [
|
|
65
39
|
json.JsonArrayNode.mock(range),
|
|
@@ -67,60 +41,60 @@ const getMockNodes = (rawTreeNode, range) => {
|
|
|
67
41
|
json.JsonStringNode.mock(range),
|
|
68
42
|
];
|
|
69
43
|
case 'minecraft:dimension':
|
|
70
|
-
return
|
|
44
|
+
return ResourceLocationNode.mock(range, { category: 'dimension' });
|
|
71
45
|
case 'minecraft:entity':
|
|
72
46
|
case 'minecraft:game_profile':
|
|
73
|
-
return
|
|
47
|
+
return EntitySelectorNode.mock(range);
|
|
74
48
|
case 'minecraft:entity_anchor':
|
|
75
|
-
return
|
|
49
|
+
return LiteralNode.mock(range, { pool: EntityAnchorArgumentValues });
|
|
76
50
|
case 'minecraft:entity_summon':
|
|
77
|
-
return
|
|
51
|
+
return ResourceLocationNode.mock(range, { category: 'entity_type' });
|
|
78
52
|
case 'minecraft:function':
|
|
79
|
-
return
|
|
53
|
+
return ResourceLocationNode.mock(range, { category: 'function' });
|
|
80
54
|
case 'minecraft:int_range':
|
|
81
|
-
return
|
|
55
|
+
return IntRangeNode.mock(range);
|
|
82
56
|
case 'minecraft:item_enchantment':
|
|
83
|
-
return
|
|
57
|
+
return ResourceLocationNode.mock(range, { category: 'enchantment' });
|
|
84
58
|
case 'minecraft:item_predicate':
|
|
85
|
-
return
|
|
59
|
+
return ItemNode.mock(range, true);
|
|
86
60
|
case 'minecraft:item_slot':
|
|
87
|
-
return
|
|
61
|
+
return LiteralNode.mock(range, { pool: ItemSlotArgumentValues });
|
|
88
62
|
case 'minecraft:item_stack':
|
|
89
|
-
return
|
|
63
|
+
return ItemNode.mock(range, false);
|
|
90
64
|
case 'minecraft:mob_effect':
|
|
91
|
-
return
|
|
65
|
+
return ResourceLocationNode.mock(range, { category: 'mob_effect' });
|
|
92
66
|
case 'minecraft:objective':
|
|
93
|
-
return
|
|
67
|
+
return SymbolNode.mock(range, { category: 'objective' });
|
|
94
68
|
case 'minecraft:objective_criteria':
|
|
95
|
-
return
|
|
69
|
+
return ObjectiveCriteriaNode.mock(range);
|
|
96
70
|
case 'minecraft:operation':
|
|
97
|
-
return
|
|
71
|
+
return LiteralNode.mock(range, { pool: OperationArgumentValues, colorTokenType: 'operator' });
|
|
98
72
|
case 'minecraft:particle':
|
|
99
|
-
return
|
|
73
|
+
return ParticleNode.mock(range);
|
|
100
74
|
case 'minecraft:resource':
|
|
101
75
|
case 'minecraft:resource_or_tag':
|
|
102
|
-
return
|
|
103
|
-
category:
|
|
76
|
+
return ResourceLocationNode.mock(range, {
|
|
77
|
+
category: ResourceLocation.shorten(treeNode.properties.registry),
|
|
104
78
|
allowTag: treeNode.parser === 'minecraft:resource_or_tag',
|
|
105
79
|
});
|
|
106
80
|
case 'minecraft:resource_location':
|
|
107
|
-
return
|
|
81
|
+
return ResourceLocationNode.mock(range, treeNode.properties ?? { pool: [], allowUnknown: true });
|
|
108
82
|
case 'minecraft:rotation':
|
|
109
|
-
return
|
|
83
|
+
return VectorNode.mock(range, { dimension: 2, noLocal: true });
|
|
110
84
|
case 'minecraft:scoreboard_slot':
|
|
111
|
-
return
|
|
85
|
+
return LiteralNode.mock(range, { pool: ScoreboardSlotArgumentValues });
|
|
112
86
|
case 'minecraft:score_holder':
|
|
113
|
-
return
|
|
87
|
+
return ScoreHolderNode.mock(range);
|
|
114
88
|
case 'minecraft:swizzle':
|
|
115
|
-
return
|
|
89
|
+
return LiteralNode.mock(range, { pool: SwizzleArgumentValues });
|
|
116
90
|
case 'minecraft:team':
|
|
117
|
-
return
|
|
91
|
+
return SymbolNode.mock(range, { category: 'team' });
|
|
118
92
|
case 'minecraft:vec2':
|
|
119
|
-
return
|
|
93
|
+
return VectorNode.mock(range, { dimension: 2, integersOnly: true });
|
|
120
94
|
case 'minecraft:vec3':
|
|
121
|
-
return
|
|
95
|
+
return VectorNode.mock(range, { dimension: 3 });
|
|
122
96
|
case 'spyglassmc:tag':
|
|
123
|
-
return
|
|
97
|
+
return SymbolNode.mock(range, { category: 'tag' });
|
|
124
98
|
// ==== Unimplemented ====
|
|
125
99
|
case 'minecraft:nbt_compound_tag':
|
|
126
100
|
case 'minecraft:nbt_path':
|
|
@@ -130,33 +104,32 @@ const getMockNodes = (rawTreeNode, range) => {
|
|
|
130
104
|
return [];
|
|
131
105
|
}
|
|
132
106
|
};
|
|
133
|
-
exports.getMockNodes = getMockNodes;
|
|
134
107
|
const block = (node, ctx) => {
|
|
135
108
|
const ans = [];
|
|
136
|
-
if (
|
|
137
|
-
ans.push(...
|
|
109
|
+
if (Range.contains(node.id, ctx.offset, true)) {
|
|
110
|
+
ans.push(...completer.resourceLocation(node.id, ctx));
|
|
138
111
|
}
|
|
139
|
-
if (node.states &&
|
|
112
|
+
if (node.states && Range.contains(Range.translate(node.states, 1, -1), ctx.offset, true)) {
|
|
140
113
|
ans.push(...blockStates(node.states, ctx));
|
|
141
114
|
}
|
|
142
115
|
return ans;
|
|
143
116
|
};
|
|
144
117
|
const blockStates = (node, ctx) => {
|
|
145
|
-
if (!
|
|
118
|
+
if (!BlockNode.is(node.parent)) {
|
|
146
119
|
return [];
|
|
147
120
|
}
|
|
148
121
|
const idNode = node.parent.id;
|
|
149
|
-
const id =
|
|
150
|
-
const blocks = idNode.isTag ?
|
|
151
|
-
const states =
|
|
152
|
-
return
|
|
122
|
+
const id = ResourceLocationNode.toString(idNode, 'full');
|
|
123
|
+
const blocks = idNode.isTag ? getTagValues('tag/block', id, ctx) : [id];
|
|
124
|
+
const states = getStates('block', blocks, ctx);
|
|
125
|
+
return completer.record({
|
|
153
126
|
key: (_record, pair, _ctx, range, insertValue, insertComma, existingKeys) => {
|
|
154
127
|
return Object.keys(states)
|
|
155
128
|
.filter(k => pair?.key?.value === k || !existingKeys.some(ek => ek.value === k))
|
|
156
|
-
.map(k =>
|
|
129
|
+
.map(k => CompletionItem.create(k, range, {
|
|
157
130
|
kind: 10 /* CompletionKind.Property */,
|
|
158
|
-
detail:
|
|
159
|
-
insertText: new
|
|
131
|
+
detail: localize('mcfunction.completer.block.states.default-value', localeQuote(states[k][0])),
|
|
132
|
+
insertText: new InsertTextBuilder()
|
|
160
133
|
.literal(k)
|
|
161
134
|
.if(insertValue, b => b.literal('=').placeholder(...states[k]))
|
|
162
135
|
.if(insertComma, b => b.literal(','))
|
|
@@ -165,7 +138,7 @@ const blockStates = (node, ctx) => {
|
|
|
165
138
|
},
|
|
166
139
|
value: (_record, pair, ctx) => {
|
|
167
140
|
if (pair.key && states[pair.key.value]) {
|
|
168
|
-
return states[pair.key.value].map(v =>
|
|
141
|
+
return states[pair.key.value].map(v => CompletionItem.create(v, pair.value ?? ctx.offset, {
|
|
169
142
|
kind: 12 /* CompletionKind.Value */,
|
|
170
143
|
}));
|
|
171
144
|
}
|
|
@@ -174,85 +147,85 @@ const blockStates = (node, ctx) => {
|
|
|
174
147
|
})(node, ctx);
|
|
175
148
|
};
|
|
176
149
|
const coordinate = (node, _ctx) => {
|
|
177
|
-
return [
|
|
150
|
+
return [CompletionItem.create('~', node)];
|
|
178
151
|
};
|
|
179
152
|
const item = (node, ctx) => {
|
|
180
153
|
const ans = [];
|
|
181
|
-
if (
|
|
182
|
-
ans.push(...
|
|
154
|
+
if (Range.contains(node.id, ctx.offset, true)) {
|
|
155
|
+
ans.push(...completer.resourceLocation(node.id, ctx));
|
|
183
156
|
}
|
|
184
157
|
return ans;
|
|
185
158
|
};
|
|
186
159
|
const objectiveCriteria = (node, ctx) => {
|
|
187
|
-
const ans =
|
|
188
|
-
if (!node.children?.[0] ||
|
|
189
|
-
ans.push(...
|
|
160
|
+
const ans = ObjectiveCriteriaNode.SimpleValues.map(v => CompletionItem.create(v, node));
|
|
161
|
+
if (!node.children?.[0] || Range.contains(node.children[0], ctx.offset, true)) {
|
|
162
|
+
ans.push(...completer.resourceLocation(node.children?.[0] ?? ResourceLocationNode.mock(node, { category: 'stat_type', namespacePathSep: '.' }), ctx));
|
|
190
163
|
}
|
|
191
|
-
if (node.children?.[1] &&
|
|
192
|
-
ans.push(...
|
|
164
|
+
if (node.children?.[1] && Range.contains(node.children[1], ctx.offset, true)) {
|
|
165
|
+
ans.push(...completer.resourceLocation(node.children[1], ctx));
|
|
193
166
|
}
|
|
194
167
|
return ans;
|
|
195
168
|
};
|
|
196
169
|
const particle = (node, ctx) => {
|
|
197
|
-
const child =
|
|
170
|
+
const child = AstNode.findChild(node, ctx.offset, true);
|
|
198
171
|
if (child) {
|
|
199
|
-
return
|
|
172
|
+
return completer.dispatch(child, ctx);
|
|
200
173
|
}
|
|
201
|
-
const id =
|
|
174
|
+
const id = ResourceLocationNode.toString(node.id, 'short');
|
|
202
175
|
const map = {
|
|
203
|
-
block: [
|
|
204
|
-
block_marker: [
|
|
205
|
-
dust: [
|
|
206
|
-
dust_color_transition: [
|
|
207
|
-
falling_dust: [
|
|
208
|
-
item: [
|
|
209
|
-
sculk_charge: [
|
|
210
|
-
vibration: [
|
|
176
|
+
block: [BlockNode.mock(ctx.offset, false)],
|
|
177
|
+
block_marker: [BlockNode.mock(ctx.offset, false)],
|
|
178
|
+
dust: [VectorNode.mock(ctx.offset, { dimension: 3 }), FloatNode.mock(ctx.offset)],
|
|
179
|
+
dust_color_transition: [VectorNode.mock(ctx.offset, { dimension: 3 }), FloatNode.mock(ctx.offset), VectorNode.mock(ctx.offset, { dimension: 3 })],
|
|
180
|
+
falling_dust: [BlockNode.mock(ctx.offset, false)],
|
|
181
|
+
item: [ItemNode.mock(ctx.offset, false)],
|
|
182
|
+
sculk_charge: [FloatNode.mock(ctx.offset)],
|
|
183
|
+
vibration: [VectorNode.mock(ctx.offset, { dimension: 3 }), VectorNode.mock(ctx.offset, { dimension: 3 }), IntegerNode.mock(ctx.offset)],
|
|
211
184
|
};
|
|
212
|
-
if (
|
|
185
|
+
if (ParticleNode.isSpecialType(id)) {
|
|
213
186
|
const numParamsBefore = node.children?.slice(1).filter(n => n.range.end < ctx.offset).length ?? 0;
|
|
214
187
|
const mock = map[id][numParamsBefore];
|
|
215
188
|
if (mock) {
|
|
216
|
-
return
|
|
189
|
+
return completer.dispatch(mock, ctx);
|
|
217
190
|
}
|
|
218
191
|
}
|
|
219
192
|
return [];
|
|
220
193
|
};
|
|
221
194
|
const scoreHolder = (node, ctx) => {
|
|
222
195
|
let ans;
|
|
223
|
-
if (node.selector &&
|
|
196
|
+
if (node.selector && Range.contains(node.selector, ctx.offset, true)) {
|
|
224
197
|
ans = selector(node.selector, ctx);
|
|
225
|
-
if (
|
|
226
|
-
ans.push(...
|
|
198
|
+
if (Range.contains(node.children[0], ctx.offset, true)) {
|
|
199
|
+
ans.push(...completer.symbol(SymbolNode.mock(node, { category: 'score_holder' }), ctx));
|
|
227
200
|
}
|
|
228
201
|
}
|
|
229
202
|
else {
|
|
230
|
-
ans =
|
|
231
|
-
ans.push(...selector(
|
|
203
|
+
ans = completer.symbol(node.fakeName ?? SymbolNode.mock(node, { category: 'score_holder' }), ctx);
|
|
204
|
+
ans.push(...selector(EntitySelectorNode.mock(node), ctx));
|
|
232
205
|
}
|
|
233
206
|
return ans;
|
|
234
207
|
};
|
|
235
208
|
const selector = (node, ctx) => {
|
|
236
|
-
if (
|
|
237
|
-
return
|
|
209
|
+
if (Range.contains(node.children[0], ctx.offset, true)) {
|
|
210
|
+
return completer.literal(node.children[0], ctx);
|
|
238
211
|
}
|
|
239
|
-
if (node.arguments &&
|
|
212
|
+
if (node.arguments && Range.contains(Range.translate(node.arguments, 1, -1), ctx.offset, true)) {
|
|
240
213
|
return selectorArguments(node.arguments, ctx);
|
|
241
214
|
}
|
|
242
215
|
return [];
|
|
243
216
|
};
|
|
244
217
|
const selectorArguments = (node, ctx) => {
|
|
245
218
|
const selector = node.parent;
|
|
246
|
-
if (!
|
|
219
|
+
if (!EntitySelectorNode.is(selector)) {
|
|
247
220
|
return [];
|
|
248
221
|
}
|
|
249
|
-
return
|
|
222
|
+
return completer.record({
|
|
250
223
|
key: (record, pair, _ctx, range, insertValue, insertComma) => {
|
|
251
|
-
return [...
|
|
252
|
-
.filter(k =>
|
|
253
|
-
.map(k =>
|
|
224
|
+
return [...EntitySelectorNode.ArgumentKeys]
|
|
225
|
+
.filter(k => EntitySelectorNode.canKeyExist(selector, record, k) === 0 /* EntitySelectorNode.Result.Ok */)
|
|
226
|
+
.map(k => CompletionItem.create(k, range, {
|
|
254
227
|
kind: 10 /* CompletionKind.Property */,
|
|
255
|
-
insertText: new
|
|
228
|
+
insertText: new InsertTextBuilder()
|
|
256
229
|
.literal(k)
|
|
257
230
|
.if(insertValue, b => b.literal('=').placeholder()) // TODO
|
|
258
231
|
.if(insertComma, b => b.literal(','))
|
|
@@ -261,17 +234,17 @@ const selectorArguments = (node, ctx) => {
|
|
|
261
234
|
},
|
|
262
235
|
value: (_record, pair, ctx) => {
|
|
263
236
|
if (pair.value) {
|
|
264
|
-
return
|
|
237
|
+
return completer.dispatch(pair.value, ctx);
|
|
265
238
|
}
|
|
266
239
|
return [];
|
|
267
240
|
},
|
|
268
241
|
})(node, ctx);
|
|
269
242
|
};
|
|
270
243
|
const intRange = (node, _ctx) => {
|
|
271
|
-
return [
|
|
244
|
+
return [CompletionItem.create('-2147483648..2147483647', node, { kind: 21 /* CompletionKind.Constant */ })];
|
|
272
245
|
};
|
|
273
246
|
const vector = (node, _ctx) => {
|
|
274
|
-
const createCompletion = (coordinate, sortText) =>
|
|
247
|
+
const createCompletion = (coordinate, sortText) => CompletionItem.create(new Array(node.options.dimension).fill(coordinate).join(' '), node, { sortText });
|
|
275
248
|
const ans = [];
|
|
276
249
|
ans.push(createCompletion('~', 'a'));
|
|
277
250
|
if (!node.options.noLocal) {
|
|
@@ -280,7 +253,7 @@ const vector = (node, _ctx) => {
|
|
|
280
253
|
ans.push(createCompletion('0.0', 'c'));
|
|
281
254
|
return ans;
|
|
282
255
|
};
|
|
283
|
-
function register(meta) {
|
|
256
|
+
export function register(meta) {
|
|
284
257
|
meta.registerCompleter('mcfunction:block', block);
|
|
285
258
|
meta.registerCompleter('mcfunction:coordinate', coordinate);
|
|
286
259
|
meta.registerCompleter('mcfunction:entity_selector', selector);
|
|
@@ -292,5 +265,4 @@ function register(meta) {
|
|
|
292
265
|
meta.registerCompleter('mcfunction:score_holder', scoreHolder);
|
|
293
266
|
meta.registerCompleter('mcfunction:vector', vector);
|
|
294
267
|
}
|
|
295
|
-
exports.register = register;
|
|
296
268
|
//# sourceMappingURL=argument.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './argument';
|
|
1
|
+
export * from './argument.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|