@spyglassmc/java-edition 0.1.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/README.md +36 -0
- package/lib/binder/index.d.ts +15 -0
- package/lib/binder/index.js +102 -0
- package/lib/common/index.d.ts +7 -0
- package/lib/common/index.js +60 -0
- package/lib/dependency/common.d.ts +26 -0
- package/lib/dependency/common.js +39 -0
- package/lib/dependency/index.d.ts +30 -0
- package/lib/dependency/index.js +172 -0
- package/lib/dependency/mcmeta.d.ts +79 -0
- package/lib/dependency/mcmeta.js +205 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +76 -0
- package/lib/json/checker/data/advancement.d.ts +14 -0
- package/lib/json/checker/data/advancement.js +450 -0
- package/lib/json/checker/data/biome.d.ts +4 -0
- package/lib/json/checker/data/biome.js +151 -0
- package/lib/json/checker/data/common.d.ts +22 -0
- package/lib/json/checker/data/common.js +286 -0
- package/lib/json/checker/data/dimension.d.ts +4 -0
- package/lib/json/checker/data/dimension.js +238 -0
- package/lib/json/checker/data/feature.d.ts +9 -0
- package/lib/json/checker/data/feature.js +733 -0
- package/lib/json/checker/data/index.d.ts +4 -0
- package/lib/json/checker/data/index.js +43 -0
- package/lib/json/checker/data/loot_table.d.ts +8 -0
- package/lib/json/checker/data/loot_table.js +279 -0
- package/lib/json/checker/data/recipe.d.ts +2 -0
- package/lib/json/checker/data/recipe.js +53 -0
- package/lib/json/checker/data/structure.d.ts +8 -0
- package/lib/json/checker/data/structure.js +148 -0
- package/lib/json/checker/data/tag.d.ts +7 -0
- package/lib/json/checker/data/tag.js +38 -0
- package/lib/json/checker/data/text_component.d.ts +2 -0
- package/lib/json/checker/data/text_component.js +142 -0
- package/lib/json/checker/index.d.ts +5 -0
- package/lib/json/checker/index.js +28 -0
- package/lib/json/checker/util/advancement.d.ts +3 -0
- package/lib/json/checker/util/advancement.js +20 -0
- package/lib/json/checker/util/block_states.d.ts +13 -0
- package/lib/json/checker/util/block_states.js +85 -0
- package/lib/json/checker/util/color.d.ts +4 -0
- package/lib/json/checker/util/color.js +64 -0
- package/lib/json/checker/util/index.d.ts +8 -0
- package/lib/json/checker/util/index.js +20 -0
- package/lib/json/checker/util/nbt.d.ts +17 -0
- package/lib/json/checker/util/nbt.js +71 -0
- package/lib/json/checker/util/recipe.d.ts +6 -0
- package/lib/json/checker/util/recipe.js +16 -0
- package/lib/json/checker/util/uuid.d.ts +2 -0
- package/lib/json/checker/util/uuid.js +12 -0
- package/lib/json/checker/util/version.d.ts +46 -0
- package/lib/json/checker/util/version.js +54 -0
- package/lib/json/index.d.ts +4 -0
- package/lib/json/index.js +32 -0
- package/lib/mcfunction/checker/index.d.ts +7 -0
- package/lib/mcfunction/checker/index.js +217 -0
- package/lib/mcfunction/colorizer/index.d.ts +6 -0
- package/lib/mcfunction/colorizer/index.js +38 -0
- package/lib/mcfunction/common/index.d.ts +7 -0
- package/lib/mcfunction/common/index.js +47 -0
- package/lib/mcfunction/completer/argument.d.ts +5 -0
- package/lib/mcfunction/completer/argument.js +292 -0
- package/lib/mcfunction/completer/index.d.ts +2 -0
- package/lib/mcfunction/completer/index.js +14 -0
- package/lib/mcfunction/index.d.ts +8 -0
- package/lib/mcfunction/index.js +72 -0
- package/lib/mcfunction/inlayHintProvider.d.ts +4 -0
- package/lib/mcfunction/inlayHintProvider.js +40 -0
- package/lib/mcfunction/node/argument.d.ts +187 -0
- package/lib/mcfunction/node/argument.js +281 -0
- package/lib/mcfunction/node/index.d.ts +2 -0
- package/lib/mcfunction/node/index.js +14 -0
- package/lib/mcfunction/parser/argument.d.ts +15 -0
- package/lib/mcfunction/parser/argument.js +934 -0
- package/lib/mcfunction/parser/index.d.ts +2 -0
- package/lib/mcfunction/parser/index.js +14 -0
- package/lib/mcfunction/signatureHelpProvider.d.ts +8 -0
- package/lib/mcfunction/signatureHelpProvider.js +103 -0
- package/lib/mcfunction/tree/1.15.d.ts +9 -0
- package/lib/mcfunction/tree/1.15.js +542 -0
- package/lib/mcfunction/tree/1.16.d.ts +10 -0
- package/lib/mcfunction/tree/1.16.js +77 -0
- package/lib/mcfunction/tree/1.17.d.ts +12 -0
- package/lib/mcfunction/tree/1.17.js +166 -0
- package/lib/mcfunction/tree/1.18.d.ts +26 -0
- package/lib/mcfunction/tree/1.18.js +6 -0
- package/lib/mcfunction/tree/1.19.d.ts +26 -0
- package/lib/mcfunction/tree/1.19.js +6 -0
- package/lib/mcfunction/tree/argument.d.ts +179 -0
- package/lib/mcfunction/tree/argument.js +3 -0
- package/lib/mcfunction/tree/index.d.ts +7 -0
- package/lib/mcfunction/tree/index.js +19 -0
- package/package.json +41 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.text_component = void 0;
|
|
4
|
+
const core_1 = require("@spyglassmc/core");
|
|
5
|
+
const primitives_1 = require("@spyglassmc/json/lib/checker/primitives");
|
|
6
|
+
const util_1 = require("../util");
|
|
7
|
+
const Keybinds = [
|
|
8
|
+
'key.jump',
|
|
9
|
+
'key.sneak',
|
|
10
|
+
'key.sprint',
|
|
11
|
+
'key.left',
|
|
12
|
+
'key.right',
|
|
13
|
+
'key.back',
|
|
14
|
+
'key.forward',
|
|
15
|
+
'key.attack',
|
|
16
|
+
'key.pickItem',
|
|
17
|
+
'key.use',
|
|
18
|
+
'key.drop',
|
|
19
|
+
'key.hotbar.1',
|
|
20
|
+
'key.hotbar.2',
|
|
21
|
+
'key.hotbar.3',
|
|
22
|
+
'key.hotbar.4',
|
|
23
|
+
'key.hotbar.5',
|
|
24
|
+
'key.hotbar.6',
|
|
25
|
+
'key.hotbar.7',
|
|
26
|
+
'key.hotbar.8',
|
|
27
|
+
'key.hotbar.9',
|
|
28
|
+
'key.inventory',
|
|
29
|
+
'key.swapOffhand',
|
|
30
|
+
'key.loadToolbarActivator',
|
|
31
|
+
'key.saveToolbarActivator',
|
|
32
|
+
'key.playerlist',
|
|
33
|
+
'key.chat',
|
|
34
|
+
'key.command',
|
|
35
|
+
'key.socialInteractions',
|
|
36
|
+
'key.advancements',
|
|
37
|
+
'key.spectatorOutlines',
|
|
38
|
+
'key.screenshot',
|
|
39
|
+
'key.smoothCamera',
|
|
40
|
+
'key.fullscreen',
|
|
41
|
+
'key.togglePerspective',
|
|
42
|
+
];
|
|
43
|
+
const text_component_object = (0, primitives_1.as)('text_component', (node, ctx) => (0, primitives_1.record)({
|
|
44
|
+
...(0, primitives_1.having)(node, ctx, {
|
|
45
|
+
text: {
|
|
46
|
+
text: primitives_1.simpleString,
|
|
47
|
+
},
|
|
48
|
+
translate: {
|
|
49
|
+
translate: primitives_1.simpleString,
|
|
50
|
+
with: (0, primitives_1.opt)((0, primitives_1.listOf)(exports.text_component), []),
|
|
51
|
+
},
|
|
52
|
+
selector: {
|
|
53
|
+
selector: primitives_1.simpleString,
|
|
54
|
+
separator: (0, primitives_1.opt)((0, util_1.versioned)(ctx, '1.17', exports.text_component)),
|
|
55
|
+
},
|
|
56
|
+
score: {
|
|
57
|
+
score: (0, primitives_1.record)({
|
|
58
|
+
name: primitives_1.simpleString,
|
|
59
|
+
objective: primitives_1.simpleString,
|
|
60
|
+
value: (0, primitives_1.opt)(primitives_1.simpleString),
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
keybind: {
|
|
64
|
+
keybind: (0, primitives_1.literal)(Keybinds),
|
|
65
|
+
},
|
|
66
|
+
nbt: () => ({
|
|
67
|
+
nbt: primitives_1.simpleString,
|
|
68
|
+
...(0, primitives_1.having)(node, ctx, {
|
|
69
|
+
block: {
|
|
70
|
+
block: primitives_1.simpleString,
|
|
71
|
+
nbt: (0, util_1.nbtPath)({ registry: 'block' }),
|
|
72
|
+
},
|
|
73
|
+
entity: {
|
|
74
|
+
entity: primitives_1.simpleString,
|
|
75
|
+
nbt: (0, util_1.nbtPath)({ registry: 'entity_type' /* FIXME: import { getTypesFromEntity } from '../../../../mcfunction/checker'; ids: getTypesFromEntity(somehowGetTheNodeHere, ctx) */ }),
|
|
76
|
+
},
|
|
77
|
+
storage: {
|
|
78
|
+
storage: (0, primitives_1.resource)('storage'),
|
|
79
|
+
nbt: (0, util_1.nbtPath)({ registry: 'storage' /* FIXME:, id: extract('storage', props) */ }),
|
|
80
|
+
},
|
|
81
|
+
}),
|
|
82
|
+
interpret: (0, primitives_1.opt)(primitives_1.boolean, false),
|
|
83
|
+
separator: (0, primitives_1.opt)((0, util_1.versioned)(ctx, '1.17', exports.text_component)),
|
|
84
|
+
}),
|
|
85
|
+
}),
|
|
86
|
+
color: (0, primitives_1.opt)((0, util_1.stringColor)()),
|
|
87
|
+
font: (0, primitives_1.opt)(primitives_1.simpleString),
|
|
88
|
+
bold: (0, primitives_1.opt)(primitives_1.boolean),
|
|
89
|
+
italic: (0, primitives_1.opt)(primitives_1.boolean),
|
|
90
|
+
underlined: (0, primitives_1.opt)(primitives_1.boolean),
|
|
91
|
+
strikethrough: (0, primitives_1.opt)(primitives_1.boolean),
|
|
92
|
+
obfuscated: (0, primitives_1.opt)(primitives_1.boolean),
|
|
93
|
+
insertion: (0, primitives_1.opt)(primitives_1.simpleString),
|
|
94
|
+
clickEvent: (0, primitives_1.opt)((0, primitives_1.dispatch)('action', (action) => (0, primitives_1.record)({
|
|
95
|
+
action: (0, primitives_1.literal)(['open_url', 'open_file', 'run_command', 'suggest_command', 'change_page', 'copy_to_clipboard']),
|
|
96
|
+
value: primitives_1.simpleString,
|
|
97
|
+
...(0, primitives_1.pick)(action, {
|
|
98
|
+
run_command: {
|
|
99
|
+
value: (0, primitives_1.string)('command', ctx.meta.getParserLazily('mcfunction:command'), ctx.meta.getChecker('mcfunction:command')),
|
|
100
|
+
},
|
|
101
|
+
change_page: {
|
|
102
|
+
value: (0, primitives_1.string)('number', (0, core_1.integer)({ pattern: /\d+/, min: 0 })),
|
|
103
|
+
},
|
|
104
|
+
}),
|
|
105
|
+
}))),
|
|
106
|
+
hoverEvent: (0, primitives_1.opt)((0, primitives_1.dispatch)('action', (action, _, ctx) => (0, primitives_1.record)({
|
|
107
|
+
action: (0, primitives_1.literal)(['show_text', 'show_item', 'show_entity']),
|
|
108
|
+
...(0, primitives_1.pick)(action, {
|
|
109
|
+
show_text: {
|
|
110
|
+
value: (0, util_1.deprecated)(ctx, '1.16', exports.text_component),
|
|
111
|
+
contents: (0, primitives_1.opt)((0, util_1.versioned)(ctx, '1.16', exports.text_component)),
|
|
112
|
+
},
|
|
113
|
+
show_item: {
|
|
114
|
+
value: (0, util_1.deprecated)(ctx, '1.16', (0, util_1.nbt)({ definition: '::minecraft::util::invitem::InventoryItem' })),
|
|
115
|
+
contents: (0, primitives_1.opt)((0, util_1.versioned)(ctx, '1.16', (0, primitives_1.dispatch)(props => (0, primitives_1.record)({
|
|
116
|
+
id: (0, primitives_1.resource)('item'),
|
|
117
|
+
count: (0, primitives_1.opt)(primitives_1.int),
|
|
118
|
+
tag: (0, primitives_1.opt)((0, util_1.nbt)({ registry: 'item', id: (0, primitives_1.extract)('id', props) })),
|
|
119
|
+
})))),
|
|
120
|
+
},
|
|
121
|
+
show_entity: {
|
|
122
|
+
value: (0, util_1.deprecated)(ctx, '1.16', (0, primitives_1.record)({
|
|
123
|
+
name: (0, primitives_1.opt)(primitives_1.simpleString),
|
|
124
|
+
type: (0, primitives_1.opt)((0, primitives_1.resource)('entity_type')),
|
|
125
|
+
id: (0, primitives_1.opt)(util_1.uuid),
|
|
126
|
+
})),
|
|
127
|
+
contents: (0, primitives_1.opt)((0, util_1.versioned)(ctx, '1.16', (0, primitives_1.record)({
|
|
128
|
+
name: (0, primitives_1.opt)(exports.text_component),
|
|
129
|
+
type: (0, primitives_1.opt)((0, primitives_1.resource)('entity_type')),
|
|
130
|
+
id: (0, primitives_1.opt)(util_1.uuid),
|
|
131
|
+
}))),
|
|
132
|
+
},
|
|
133
|
+
}),
|
|
134
|
+
}))),
|
|
135
|
+
extra: (0, primitives_1.opt)((0, primitives_1.listOf)(exports.text_component)),
|
|
136
|
+
})(node, ctx));
|
|
137
|
+
exports.text_component = (0, primitives_1.as)('text_component', (0, primitives_1.any)([
|
|
138
|
+
primitives_1.simpleString,
|
|
139
|
+
text_component_object,
|
|
140
|
+
(0, primitives_1.listOf)((0, primitives_1.ref)(() => exports.text_component)),
|
|
141
|
+
]));
|
|
142
|
+
//# sourceMappingURL=text_component.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.register = exports.entry = void 0;
|
|
4
|
+
const binder_1 = require("../../binder");
|
|
5
|
+
const data_1 = require("./data");
|
|
6
|
+
const entry = (node, ctx) => {
|
|
7
|
+
const parts = (0, binder_1.dissectUri)(ctx.doc.uri, ctx);
|
|
8
|
+
if (parts && data_1.Checkers.has(parts.category)) {
|
|
9
|
+
data_1.Checkers.get(parts.category)(node, { ...ctx, context: '' });
|
|
10
|
+
}
|
|
11
|
+
else if (ctx.doc.uri.endsWith('/pack.mcmeta')) {
|
|
12
|
+
(0, data_1.pack_mcmeta)(node, { ...ctx, context: '' });
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.entry = entry;
|
|
19
|
+
function register(meta) {
|
|
20
|
+
meta.registerChecker('json:array', exports.entry);
|
|
21
|
+
meta.registerChecker('json:boolean', exports.entry);
|
|
22
|
+
meta.registerChecker('json:null', exports.entry);
|
|
23
|
+
meta.registerChecker('json:number', exports.entry);
|
|
24
|
+
meta.registerChecker('json:object', exports.entry);
|
|
25
|
+
meta.registerChecker('json:string', exports.entry);
|
|
26
|
+
}
|
|
27
|
+
exports.register = register;
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.criterionReference = void 0;
|
|
4
|
+
const checker_1 = require("@spyglassmc/json/lib/checker");
|
|
5
|
+
function criterionReference(advancement) {
|
|
6
|
+
return (node, ctx) => {
|
|
7
|
+
// FIXME: Temporary solution to make tests pass when ensureChecked is not given.
|
|
8
|
+
if (!ctx.ensureChecked) {
|
|
9
|
+
(0, checker_1.simpleString)(node, ctx);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const criteria = Object.values(ctx.symbols.query(ctx.doc, 'advancement', advancement).symbol
|
|
13
|
+
?.members ?? {})
|
|
14
|
+
.filter((m) => m?.subcategory === 'criterion')
|
|
15
|
+
.map(s => s.identifier);
|
|
16
|
+
(0, checker_1.literal)(criteria)(node, ctx);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.criterionReference = criterionReference;
|
|
20
|
+
//# sourceMappingURL=advancement.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JsonChecker } from '@spyglassmc/json/lib/checker/JsonChecker';
|
|
2
|
+
interface Options {
|
|
3
|
+
category?: 'block' | 'fluid';
|
|
4
|
+
id?: string | undefined;
|
|
5
|
+
ids?: readonly string[] | undefined;
|
|
6
|
+
tag?: string | undefined;
|
|
7
|
+
mixedTypes?: boolean;
|
|
8
|
+
requireAll?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function blockStateMap({ category, id, ids, tag, mixedTypes, requireAll }: Options): JsonChecker;
|
|
11
|
+
export declare function blockStateList({ category, id, ids, tag }: Options): JsonChecker;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=block_states.d.ts.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
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 __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.blockStateList = exports.blockStateMap = void 0;
|
|
23
|
+
const core = __importStar(require("@spyglassmc/core"));
|
|
24
|
+
const checker_1 = require("@spyglassmc/json/lib/checker");
|
|
25
|
+
const common_1 = require("../../../common");
|
|
26
|
+
function blockStateMap({ category, id, ids, tag, mixedTypes, requireAll }) {
|
|
27
|
+
return (node, ctx) => {
|
|
28
|
+
if (tag) {
|
|
29
|
+
ids = (0, common_1.getTagValues)(`tag/${category ?? 'block'}`, tag, ctx);
|
|
30
|
+
}
|
|
31
|
+
else if (id) {
|
|
32
|
+
ids = [id];
|
|
33
|
+
}
|
|
34
|
+
// FIXME: Temporary solution to make tests pass when ensureChecked is not given.
|
|
35
|
+
if (!ids?.length || !ctx.ensureChecked) {
|
|
36
|
+
const values = mixedTypes ? (0, checker_1.any)([checker_1.boolean, checker_1.simpleString, intBounds()]) : checker_1.simpleString;
|
|
37
|
+
(0, checker_1.object)(checker_1.simpleString, () => requireAll ? values : (0, checker_1.opt)(values))(node, ctx);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const states = core.getStates(category ?? 'block', ids, ctx);
|
|
41
|
+
(0, checker_1.object)(Object.keys(states), (state) => {
|
|
42
|
+
const values = states[state] ?? [];
|
|
43
|
+
const checkers = [(0, checker_1.literal)(values)];
|
|
44
|
+
if (mixedTypes && values.length) {
|
|
45
|
+
if (['true', 'false'].includes(values[0])) {
|
|
46
|
+
checkers.push(checker_1.boolean);
|
|
47
|
+
}
|
|
48
|
+
else if (values[0].match(/^\d+$/)) {
|
|
49
|
+
checkers.push(intBounds(parseInt(values[0]), parseInt(values[values.length - 1])));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const checker = checkers.length > 1 ? (0, checker_1.any)(checkers) : checkers[0];
|
|
53
|
+
return requireAll ? checker : (0, checker_1.opt)(checker);
|
|
54
|
+
})(node, ctx);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
exports.blockStateMap = blockStateMap;
|
|
58
|
+
function blockStateList({ category, id, ids, tag }) {
|
|
59
|
+
return (node, ctx) => {
|
|
60
|
+
if (tag) {
|
|
61
|
+
ids = (0, common_1.getTagValues)(`tag/${category ?? 'block'}`, tag, ctx);
|
|
62
|
+
}
|
|
63
|
+
else if (id) {
|
|
64
|
+
ids = [id];
|
|
65
|
+
}
|
|
66
|
+
// FIXME: Temporary solution to make tests pass when ensureChecked is not given.
|
|
67
|
+
if (!ids?.length || !ctx.ensureChecked) {
|
|
68
|
+
(0, checker_1.listOf)(checker_1.simpleString)(node, ctx);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const states = core.getStates(category ?? 'block', ids, ctx);
|
|
72
|
+
(0, checker_1.listOf)((0, checker_1.literal)(Object.keys(states)))(node, ctx);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
exports.blockStateList = blockStateList;
|
|
76
|
+
function intBounds(min = undefined, max = undefined) {
|
|
77
|
+
return (0, checker_1.any)([
|
|
78
|
+
(0, checker_1.intRange)(min, max),
|
|
79
|
+
(0, checker_1.record)({
|
|
80
|
+
min: (0, checker_1.opt)((0, checker_1.intRange)(min, max)),
|
|
81
|
+
max: (0, checker_1.opt)((0, checker_1.intRange)(min, max)),
|
|
82
|
+
}),
|
|
83
|
+
]);
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=block_states.js.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.intColor = exports.stringColor = void 0;
|
|
4
|
+
const core_1 = require("@spyglassmc/core");
|
|
5
|
+
const json_1 = require("@spyglassmc/json");
|
|
6
|
+
const locales_1 = require("@spyglassmc/locales");
|
|
7
|
+
function stringColor() {
|
|
8
|
+
const HexPattern = /^[0-9a-f]{1,6}$/i;
|
|
9
|
+
const parser = (src, ctx) => {
|
|
10
|
+
let value = 0;
|
|
11
|
+
const start = src.cursor;
|
|
12
|
+
if (src.trySkip('#')) {
|
|
13
|
+
const remaining = src.readRemaining();
|
|
14
|
+
if (remaining.match(HexPattern)) {
|
|
15
|
+
value = parseInt(remaining, 16);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localize)('json.checker.string.hex-color')), core_1.Range.create(start, src));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const remaining = src.readRemaining();
|
|
23
|
+
if (core_1.Color.NamedColors.has(remaining)) {
|
|
24
|
+
value = core_1.Color.NamedColors.get(remaining);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
ctx.err.report((0, locales_1.localize)('expected', core_1.Color.ColorNames), core_1.Range.create(start, src));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return core_1.Color.fromCompositeInt(value);
|
|
31
|
+
};
|
|
32
|
+
return (node, ctx) => {
|
|
33
|
+
ctx.ops.set(node, 'expectation', [{ type: 'json:string', typedoc: 'String("Color")', pool: core_1.Color.ColorNames }]);
|
|
34
|
+
if (!json_1.JsonStringNode.is(node)) {
|
|
35
|
+
ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localize)('string')), node);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const result = (0, core_1.parseStringValue)(parser, node.value, node.valueMap, ctx);
|
|
39
|
+
if (result !== core_1.Failure) {
|
|
40
|
+
ctx.ops.set(node, 'color', {
|
|
41
|
+
value: result,
|
|
42
|
+
format: [core_1.ColorFormat.HexRGB],
|
|
43
|
+
range: { start: node.range.start + 1, end: node.range.end - 1 },
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
exports.stringColor = stringColor;
|
|
50
|
+
function intColor() {
|
|
51
|
+
return (node, ctx) => {
|
|
52
|
+
if (!json_1.JsonNumberNode.is(node) || !Number.isInteger(node.value)) {
|
|
53
|
+
ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localize)('integer')), node);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
ctx.ops.set(node, 'color', {
|
|
57
|
+
value: core_1.Color.fromCompositeInt(node.value),
|
|
58
|
+
format: [core_1.ColorFormat.CompositeInt],
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
exports.intColor = intColor;
|
|
64
|
+
//# sourceMappingURL=color.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
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("./advancement"), exports);
|
|
14
|
+
__exportStar(require("./block_states"), exports);
|
|
15
|
+
__exportStar(require("./color"), exports);
|
|
16
|
+
__exportStar(require("./nbt"), exports);
|
|
17
|
+
__exportStar(require("./recipe"), exports);
|
|
18
|
+
__exportStar(require("./uuid"), exports);
|
|
19
|
+
__exportStar(require("./version"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { JsonChecker } from '@spyglassmc/json/lib/checker/JsonChecker';
|
|
2
|
+
import type { ExtendableRootRegistry } from '@spyglassmc/nbtdoc';
|
|
3
|
+
interface DefinitionOptions {
|
|
4
|
+
definition: `::${string}::${string}`;
|
|
5
|
+
}
|
|
6
|
+
interface RegistryOptions {
|
|
7
|
+
registry: ExtendableRootRegistry;
|
|
8
|
+
id?: string | undefined;
|
|
9
|
+
idOrTag?: string | undefined;
|
|
10
|
+
ids?: readonly string[] | undefined;
|
|
11
|
+
tag?: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
declare type Options = DefinitionOptions | RegistryOptions;
|
|
14
|
+
export declare function nbt(options: Options): JsonChecker;
|
|
15
|
+
export declare function nbtPath(options: RegistryOptions): JsonChecker;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=nbt.d.ts.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nbtPath = exports.nbt = void 0;
|
|
4
|
+
const core_1 = require("@spyglassmc/core");
|
|
5
|
+
const checker_1 = require("@spyglassmc/json/lib/checker");
|
|
6
|
+
const nbt_1 = require("@spyglassmc/nbt");
|
|
7
|
+
const common_1 = require("../../../common");
|
|
8
|
+
function nbt(options) {
|
|
9
|
+
if (isDefinitionOptions(options)) {
|
|
10
|
+
return definitionNbt(options);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return registryNbt(options);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.nbt = nbt;
|
|
17
|
+
function isDefinitionOptions(options) {
|
|
18
|
+
return typeof options.definition === 'string';
|
|
19
|
+
}
|
|
20
|
+
function definitionNbt({ definition }) {
|
|
21
|
+
return (node, ctx) => {
|
|
22
|
+
// FIXME: Temporary solution to make tests pass when ensureChecked is not given.
|
|
23
|
+
if (!ctx.ensureChecked) {
|
|
24
|
+
(0, checker_1.simpleString)(node, ctx);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const parser = ctx.meta.getParserLazily('nbt:compound');
|
|
28
|
+
const checker = nbt_1.checker.definition(definition);
|
|
29
|
+
(0, checker_1.string)('nbt', parser, checker)(node, ctx);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function registryNbt(options) {
|
|
33
|
+
return (node, ctx) => {
|
|
34
|
+
const ids = getIds(options, ctx);
|
|
35
|
+
// FIXME: Temporary solution to make tests pass when ensureChecked is not given.
|
|
36
|
+
if (!ctx.ensureChecked) {
|
|
37
|
+
(0, checker_1.simpleString)(node, ctx);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const parser = ctx.meta.getParser('nbt:compound');
|
|
41
|
+
const checker = nbt_1.checker.index(options.registry, ids);
|
|
42
|
+
(0, checker_1.string)('nbt', parser, checker)(node, ctx);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function nbtPath(options) {
|
|
46
|
+
return (node, ctx) => {
|
|
47
|
+
const ids = getIds(options, ctx);
|
|
48
|
+
// FIXME: Temporary solution to make tests pass when ensureChecked is not given.
|
|
49
|
+
if (!ctx.ensureChecked) {
|
|
50
|
+
(0, checker_1.simpleString)(node, ctx);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const parser = ctx.meta.getParser('nbt:path');
|
|
54
|
+
const checker = nbt_1.checker.path(options.registry, ids);
|
|
55
|
+
(0, checker_1.string)('nbt_path', parser, checker)(node, ctx);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
exports.nbtPath = nbtPath;
|
|
59
|
+
function getIds({ registry, id, idOrTag, ids, tag }, ctx) {
|
|
60
|
+
if (idOrTag) {
|
|
61
|
+
idOrTag.startsWith('#') ? tag = idOrTag.slice(1) : id = idOrTag;
|
|
62
|
+
}
|
|
63
|
+
if (tag && (registry === 'block' || registry === 'item' || registry === 'entity_type')) {
|
|
64
|
+
ids = (0, common_1.getTagValues)(`tag/${registry}`, tag, ctx);
|
|
65
|
+
}
|
|
66
|
+
else if (id) {
|
|
67
|
+
ids = [id];
|
|
68
|
+
}
|
|
69
|
+
return ids?.map(core_1.ResourceLocation.lengthen);
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=nbt.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PairNode } from '@spyglassmc/core';
|
|
2
|
+
import type { JsonNode, JsonStringNode } from '@spyglassmc/json';
|
|
3
|
+
import type { JsonChecker } from '@spyglassmc/json/lib/checker/JsonChecker';
|
|
4
|
+
export declare const recipeGroup: JsonChecker;
|
|
5
|
+
export declare function patternKeys(props: PairNode<JsonStringNode, JsonNode>[]): string[];
|
|
6
|
+
//# sourceMappingURL=recipe.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.patternKeys = exports.recipeGroup = void 0;
|
|
4
|
+
const core_1 = require("@spyglassmc/core");
|
|
5
|
+
const checker_1 = require("@spyglassmc/json/lib/checker");
|
|
6
|
+
exports.recipeGroup = (0, checker_1.string)('recipe_group', (0, core_1.symbol)('recipe_group'));
|
|
7
|
+
function patternKeys(props) {
|
|
8
|
+
return [...new Set((props
|
|
9
|
+
.find(p => p.key?.value === 'pattern' && p.value?.type === 'json:array')?.value?.children ?? [])
|
|
10
|
+
.map(n => n.value)
|
|
11
|
+
.filter(n => n && n.type === 'json:string')
|
|
12
|
+
.flatMap(n => [...n.value])
|
|
13
|
+
.filter(v => v !== ' '))];
|
|
14
|
+
}
|
|
15
|
+
exports.patternKeys = patternKeys;
|
|
16
|
+
//# sourceMappingURL=recipe.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uuid = void 0;
|
|
4
|
+
const locales_1 = require("@spyglassmc/locales");
|
|
5
|
+
const checker_1 = require("@spyglassmc/json/lib/checker");
|
|
6
|
+
const UuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
7
|
+
exports.uuid = (0, checker_1.string)(undefined, undefined, (node, ctx) => {
|
|
8
|
+
if (!node.value.match(UuidRegex)) {
|
|
9
|
+
ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localize)('uuid')), node);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=uuid.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { JsonChecker, JsonCheckerContext, record } from '@spyglassmc/json/lib/checker';
|
|
2
|
+
import { MajorVersion } from '../../../dependency';
|
|
3
|
+
declare type CheckerRecord = Parameters<typeof record>[0];
|
|
4
|
+
export declare function versioned(ctx: JsonCheckerContext, version: MajorVersion, checker: string[]): string[];
|
|
5
|
+
export declare function versioned(ctx: JsonCheckerContext, version: MajorVersion, checker: JsonChecker | undefined): JsonChecker | undefined;
|
|
6
|
+
export declare function versioned(ctx: JsonCheckerContext, version: MajorVersion, checker: CheckerRecord | undefined): CheckerRecord | undefined;
|
|
7
|
+
export declare function versioned(ctx: JsonCheckerContext, checker: string[], version: MajorVersion): string[];
|
|
8
|
+
export declare function versioned(ctx: JsonCheckerContext, checker: JsonChecker | undefined, version: MajorVersion): JsonChecker | undefined;
|
|
9
|
+
export declare function versioned(ctx: JsonCheckerContext, checker: CheckerRecord | undefined, version: MajorVersion): CheckerRecord | undefined;
|
|
10
|
+
export declare function versioned(ctx: JsonCheckerContext, checker: string[], version: MajorVersion, checker2: string[]): string[];
|
|
11
|
+
export declare function versioned(ctx: JsonCheckerContext, checker: JsonChecker, version: MajorVersion, checker2: JsonChecker): JsonChecker;
|
|
12
|
+
export declare function versioned(ctx: JsonCheckerContext, checker: CheckerRecord, version: MajorVersion, checker2: CheckerRecord): CheckerRecord;
|
|
13
|
+
export declare function renamed(ctx: JsonCheckerContext, from: string, version: MajorVersion, to: string, checker: JsonChecker): CheckerRecord | undefined;
|
|
14
|
+
export declare function deprecated(ctx: JsonCheckerContext, version: MajorVersion, checker: JsonChecker | undefined): JsonChecker | {
|
|
15
|
+
checker: JsonChecker;
|
|
16
|
+
opt?: boolean | undefined;
|
|
17
|
+
def?: (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any | {
|
|
18
|
+
[key: string]: string | number | boolean | any | any | null;
|
|
19
|
+
} | null)[] | {
|
|
20
|
+
[key: string]: string | number | boolean | any | any | null;
|
|
21
|
+
} | null)[] | {
|
|
22
|
+
[key: string]: string | number | boolean | any | any | null;
|
|
23
|
+
} | null)[] | {
|
|
24
|
+
[key: string]: string | number | boolean | any | any | null;
|
|
25
|
+
} | null)[] | {
|
|
26
|
+
[key: string]: string | number | boolean | any | any | null;
|
|
27
|
+
} | null)[] | {
|
|
28
|
+
[key: string]: string | number | boolean | any | any | null;
|
|
29
|
+
} | null)[] | {
|
|
30
|
+
[key: string]: string | number | boolean | any | any | null;
|
|
31
|
+
} | null)[] | {
|
|
32
|
+
[key: string]: string | number | boolean | any | any | null;
|
|
33
|
+
} | null)[] | {
|
|
34
|
+
[key: string]: string | number | boolean | any | any | null;
|
|
35
|
+
} | null)[] | {
|
|
36
|
+
[key: string]: string | number | boolean | any | any | null;
|
|
37
|
+
} | null)[] | {
|
|
38
|
+
[key: string]: string | number | boolean | any | any | null;
|
|
39
|
+
} | null)[] | {
|
|
40
|
+
[key: string]: string | number | boolean | any | any | null;
|
|
41
|
+
} | null) | undefined;
|
|
42
|
+
deprecated?: boolean | undefined;
|
|
43
|
+
context?: string | undefined;
|
|
44
|
+
} | undefined;
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deprecated = exports.renamed = exports.versioned = void 0;
|
|
4
|
+
const checker_1 = require("@spyglassmc/json/lib/checker");
|
|
5
|
+
const dependency_1 = require("../../../dependency");
|
|
6
|
+
function getVersion(ctx) {
|
|
7
|
+
return ctx.project['loadedVersion'];
|
|
8
|
+
}
|
|
9
|
+
function cmpVersion(ctx, target) {
|
|
10
|
+
return dependency_1.MajorVersion.cmp(getVersion(ctx), target);
|
|
11
|
+
}
|
|
12
|
+
function versioned(ctx, arg1, arg2, arg3) {
|
|
13
|
+
if (typeof arg1 === 'string') {
|
|
14
|
+
const check = cmpVersion(ctx, arg1) >= 0;
|
|
15
|
+
if (arg2 === undefined) {
|
|
16
|
+
return arg2;
|
|
17
|
+
}
|
|
18
|
+
else if (Array.isArray(arg2)) {
|
|
19
|
+
return check ? arg2 : [];
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return check ? arg2 : undefined;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const check = cmpVersion(ctx, arg2) < 0;
|
|
27
|
+
if (arg1 === undefined) {
|
|
28
|
+
return arg1;
|
|
29
|
+
}
|
|
30
|
+
else if (Array.isArray(arg1)) {
|
|
31
|
+
return check ? arg1 : (arg3 ?? []);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return check ? arg1 : (arg3 ?? undefined);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.versioned = versioned;
|
|
39
|
+
function renamed(ctx, from, version, to, checker) {
|
|
40
|
+
return versioned(ctx, {
|
|
41
|
+
[from]: checker,
|
|
42
|
+
}, version, {
|
|
43
|
+
[to]: checker,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
exports.renamed = renamed;
|
|
47
|
+
function deprecated(ctx, version, checker) {
|
|
48
|
+
if (cmpVersion(ctx, version) < 0) {
|
|
49
|
+
return checker;
|
|
50
|
+
}
|
|
51
|
+
return (0, checker_1.deprecate)(checker);
|
|
52
|
+
}
|
|
53
|
+
exports.deprecated = deprecated;
|
|
54
|
+
//# sourceMappingURL=version.js.map
|