@spyglassmc/nbt 0.1.0 → 0.1.1
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/checker/index.d.ts +1 -1
- package/lib/checker/index.js +12 -13
- package/lib/checker/nbtdocUtil.js +3 -2
- package/package.json +4 -4
package/lib/checker/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare function path(registry: nbtdoc.ExtendableRootRegistry, id: core.F
|
|
|
34
34
|
export declare function fieldValue(type: nbtdoc.NbtdocType, options: Options): core.SyncChecker<NbtNode>;
|
|
35
35
|
declare type ResolvedCompoundData = Record<string, {
|
|
36
36
|
data: nbtdoc.NbtdocType;
|
|
37
|
-
query
|
|
37
|
+
query: core.SymbolQuery;
|
|
38
38
|
}>;
|
|
39
39
|
export {};
|
|
40
40
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/checker/index.js
CHANGED
|
@@ -22,6 +22,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
22
|
exports.fieldValue = exports.path = exports.enum_ = exports.compound = exports.blockStates = exports.definition = exports.index = void 0;
|
|
23
23
|
const core = __importStar(require("@spyglassmc/core"));
|
|
24
24
|
const nbtdoc = __importStar(require("@spyglassmc/nbtdoc"));
|
|
25
|
+
const nbtdoc_1 = require("@spyglassmc/nbtdoc");
|
|
25
26
|
const lib_1 = require("../../../locales/lib");
|
|
26
27
|
const node_1 = require("../node");
|
|
27
28
|
const util_1 = require("../util");
|
|
@@ -107,7 +108,7 @@ function compound(data, options = {}) {
|
|
|
107
108
|
const key = keyNode.value;
|
|
108
109
|
const fieldData = data[key];
|
|
109
110
|
if (fieldData) {
|
|
110
|
-
fieldData.query
|
|
111
|
+
fieldData.query.enter({ usage: { type: 'reference', node: keyNode } });
|
|
111
112
|
fieldValue(fieldData.data, options)(valueNode, ctx);
|
|
112
113
|
}
|
|
113
114
|
else if (!options.allowUnknownKey) {
|
|
@@ -150,7 +151,7 @@ function path(registry, id) {
|
|
|
150
151
|
return (node, ctx) => {
|
|
151
152
|
const resolveResult = resolveRootRegistry(registry, id, ctx, undefined);
|
|
152
153
|
let data = { type: 'resolved_compound', data: resolveResult.value };
|
|
153
|
-
let targetType = { type: '
|
|
154
|
+
let targetType = { type: 'index', index: { registry, path: [] } };
|
|
154
155
|
const options = { allowUnknownKey: resolveResult.allowUnknownKey, isPredicate: true };
|
|
155
156
|
let currentCompound;
|
|
156
157
|
for (const child of node.children) {
|
|
@@ -169,7 +170,7 @@ function path(registry, id) {
|
|
|
169
170
|
if (data?.type === 'resolved_compound') {
|
|
170
171
|
const fieldData = data.data[child.value];
|
|
171
172
|
if (fieldData) {
|
|
172
|
-
fieldData.query
|
|
173
|
+
fieldData.query.enter({ usage: { type: 'reference', node: child } });
|
|
173
174
|
if (fieldData.data.type === 'byte_array' || fieldData.data.type === 'int_array' || fieldData.data.type === 'long_array' || fieldData.data.type === 'list') {
|
|
174
175
|
data = fieldData.data;
|
|
175
176
|
}
|
|
@@ -323,8 +324,13 @@ function fieldValue(type, options) {
|
|
|
323
324
|
case 'index':
|
|
324
325
|
node = node;
|
|
325
326
|
const id = resolveFieldPath(node.parent?.parent, type.index.path);
|
|
326
|
-
if (type.index.registry
|
|
327
|
-
|
|
327
|
+
if (type.index.registry) {
|
|
328
|
+
if (nbtdoc_1.ExtendableRootRegistry.is(type.index.registry)) {
|
|
329
|
+
index(type.index.registry, id ? core.ResourceLocation.lengthen(id) : undefined, options)(node, ctx);
|
|
330
|
+
}
|
|
331
|
+
else if (id) {
|
|
332
|
+
index(type.index.registry, core.ResourceLocation.lengthen(id), options)(node, ctx);
|
|
333
|
+
}
|
|
328
334
|
}
|
|
329
335
|
break;
|
|
330
336
|
case 'id':
|
|
@@ -524,14 +530,7 @@ function resolveSymbolPaths(paths, ctx, compound) {
|
|
|
524
530
|
return;
|
|
525
531
|
}
|
|
526
532
|
if (ans[key]) {
|
|
527
|
-
|
|
528
|
-
const existingData = ans[key].data;
|
|
529
|
-
if (existingData.type === 'union') {
|
|
530
|
-
existingData.members.push(data.fieldType);
|
|
531
|
-
}
|
|
532
|
-
else {
|
|
533
|
-
ans[key].data = { type: 'union', members: [existingData, data.fieldType] };
|
|
534
|
-
}
|
|
533
|
+
ans[key].data = nbtdoc.unionTypes(ans[key].data, data.fieldType);
|
|
535
534
|
}
|
|
536
535
|
else {
|
|
537
536
|
ans[key] = { data: data.fieldType, query: keyQuery };
|
|
@@ -140,8 +140,7 @@ const SpecialStrings = {
|
|
|
140
140
|
'::minecraft::block::sign::Sign.Text2': 'mcfunction:component',
|
|
141
141
|
'::minecraft::block::sign::Sign.Text3': 'mcfunction:component',
|
|
142
142
|
'::minecraft::block::sign::Sign.Text4': 'mcfunction:component',
|
|
143
|
-
|
|
144
|
-
// '::minecraft::entity::effectcloud::EffectCloud.Particle': 'mcfunction:particle',
|
|
143
|
+
'::minecraft::entity::effectcloud::EffectCloud.Particle': 'mcfunction:particle',
|
|
145
144
|
'::minecraft::entity::minecart::CommandMinecart.Command': 'mcfunction:command',
|
|
146
145
|
'::minecraft::entity::mob::LivingEntity.Team': 'mcfunction:team',
|
|
147
146
|
'::minecraft::entity::EntityBase.Tags[]': 'mcfunction:tag',
|
|
@@ -156,6 +155,8 @@ exports.getSpecialStringParser = getSpecialStringParser;
|
|
|
156
155
|
const ExpandableCompounds = [
|
|
157
156
|
'::minecraft::item::ItemBase',
|
|
158
157
|
'::minecraft::entity::marker::Any',
|
|
158
|
+
'::minecraft::util::any::Any',
|
|
159
|
+
'::minecraft::util::Any',
|
|
159
160
|
];
|
|
160
161
|
/**
|
|
161
162
|
* @param nbtdocPath Path of the nbtdoc compound definition.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spyglassmc/nbt",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"author": "SPGoding",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"url": "https://github.com/SpyglassMC/Spyglass/issues"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@spyglassmc/core": "0.1.
|
|
28
|
-
"@spyglassmc/locales": "0.1.
|
|
29
|
-
"@spyglassmc/nbtdoc": "0.1.
|
|
27
|
+
"@spyglassmc/core": "0.1.1",
|
|
28
|
+
"@spyglassmc/locales": "0.1.1",
|
|
29
|
+
"@spyglassmc/nbtdoc": "0.1.1"
|
|
30
30
|
}
|
|
31
31
|
}
|