@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
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# `@spyglassmc/java-edition`
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
[](https://npmjs.com/package/@spyglassmc/java-edition)
|
|
6
|
+
|
|
7
|
+
This package provides support for [_Minecraft: Java Edition_][java-edition] map making.
|
|
8
|
+
|
|
9
|
+
# mcfunction
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
1. Register vanilla command trees and command tree patches to `CommandTreeRegistry`.
|
|
14
|
+
```typescript
|
|
15
|
+
CommandTreeRegistry.instance.register('1.15', vanillaCommandTreeFor1_15)
|
|
16
|
+
CommandTreeRegistry.instance.register('1.16', vanillaCommandTreeFor1_16)
|
|
17
|
+
CommandTreeRegistry.instance.register('1.17', vanillaCommandTreeFor1_17)
|
|
18
|
+
|
|
19
|
+
CommandTreeRegistry.instance.register('1.17-tdn', vanillaCommandTreeFor1_17, tridentCommandTreePatchFor1_17)
|
|
20
|
+
```
|
|
21
|
+
2. // TODO
|
|
22
|
+
|
|
23
|
+
## Supported Minecraft Parsers
|
|
24
|
+
|
|
25
|
+
See `ParsersToNodes` at `src/mcfunction/parser/argument.ts`.
|
|
26
|
+
|
|
27
|
+
## Exported Parsers
|
|
28
|
+
|
|
29
|
+
- `mcfunction:block_predicate`
|
|
30
|
+
- `mcfunction:command`
|
|
31
|
+
- `mcfunction:component`
|
|
32
|
+
- `mcfunction:particle` // TODO
|
|
33
|
+
- `mcfunction:tag`
|
|
34
|
+
- `mcfunction:team`
|
|
35
|
+
|
|
36
|
+
[java-edition]: https://minecraft.fandom.com/Java_Edition
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ContextBase, FileCategory, RootUriString, UriBinder } from '@spyglassmc/core';
|
|
2
|
+
export declare const Categories: Map<string, {
|
|
3
|
+
category: FileCategory;
|
|
4
|
+
extname: string;
|
|
5
|
+
since?: `1.${bigint}` | undefined;
|
|
6
|
+
until?: `1.${bigint}` | undefined;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function getRels(uri: string, rootUris: readonly RootUriString[]): Generator<string, undefined, unknown>;
|
|
9
|
+
export declare function dissectUri(uri: string, ctx: ContextBase): {
|
|
10
|
+
category: "function" | "worldgen/biome" | "worldgen/configured_carver" | "worldgen/configured_feature" | "worldgen/configured_structure_feature" | "worldgen/configured_surface_builder" | "worldgen/noise" | "worldgen/noise_settings" | "worldgen/placed_feature" | "worldgen/processor_list" | "worldgen/template_pool" | "tag/function" | "tag/block" | "tag/activity" | "tag/attribute" | "tag/block_entity_type" | "tag/block_predicate_type" | "tag/chunk_status" | "tag/custom_stat" | "tag/enchantment" | "tag/entity_type" | "tag/float_provider_type" | "tag/fluid" | "tag/game_event" | "tag/height_provider_type" | "tag/int_provider_type" | "tag/item" | "tag/loot_condition_type" | "tag/loot_function_type" | "tag/loot_nbt_provider_type" | "tag/loot_number_provider_type" | "tag/loot_pool_entry_type" | "tag/loot_score_provider_type" | "tag/memory_module_type" | "tag/menu" | "tag/mob_effect" | "tag/motive" | "tag/particle_type" | "tag/point_of_interest_type" | "tag/pos_rule_test" | "tag/position_source_type" | "tag/potion" | "tag/recipe_serializer" | "tag/recipe_type" | "tag/rule_test" | "tag/schedule" | "tag/sensor_type" | "tag/sound_event" | "tag/stat_type" | "tag/villager_profession" | "tag/villager_type" | "tag/worldgen/biome_source" | "tag/worldgen/block_placer_type" | "tag/worldgen/block_state_provider_type" | "tag/worldgen/carver" | "tag/worldgen/chunk_generator" | "tag/worldgen/decorator" | "tag/worldgen/feature" | "tag/worldgen/feature_size_type" | "tag/worldgen/foliage_placer_type" | "tag/worldgen/material_condition" | "tag/worldgen/material_rule" | "tag/worldgen/placement_modifier_type" | "tag/worldgen/structure_feature" | "tag/worldgen/structure_piece" | "tag/worldgen/structure_pool_element" | "tag/worldgen/structure_processor" | "tag/worldgen/surface_builder" | "tag/worldgen/tree_decorator_type" | "tag/worldgen/trunk_placer_type" | "tag/worldgen/biome" | "tag/worldgen/configured_carver" | "tag/worldgen/configured_feature" | "tag/worldgen/configured_structure_feature" | "tag/worldgen/configured_surface_builder" | "tag/worldgen/noise" | "tag/worldgen/noise_settings" | "tag/worldgen/placed_feature" | "tag/worldgen/processor_list" | "tag/worldgen/template_pool" | "advancement" | "dimension" | "dimension_type" | "item_modifier" | "loot_table" | "predicate" | "recipe" | "structure";
|
|
11
|
+
namespace: string;
|
|
12
|
+
identifier: string;
|
|
13
|
+
} | undefined;
|
|
14
|
+
export declare const uriBinder: UriBinder;
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uriBinder = exports.dissectUri = exports.getRels = exports.Categories = void 0;
|
|
4
|
+
const core_1 = require("@spyglassmc/core");
|
|
5
|
+
const dependency_1 = require("../dependency");
|
|
6
|
+
exports.Categories = (() => {
|
|
7
|
+
const NonTaggableRegistries = new Set([
|
|
8
|
+
'block', 'fluid', 'game_event', 'item',
|
|
9
|
+
'worldgen/block_placer_type', 'worldgen/surface_builder', // They are removed at some point.
|
|
10
|
+
]);
|
|
11
|
+
const ans = new Map([
|
|
12
|
+
['advancements', { category: 'advancement', extname: '.json' }],
|
|
13
|
+
['dimension', { category: 'dimension', extname: '.json', since: '1.16' }],
|
|
14
|
+
['dimension_type', { category: 'dimension_type', extname: '.json', since: '1.16' }],
|
|
15
|
+
['functions', { category: 'function', extname: '.mcfunction' }],
|
|
16
|
+
['item_modifiers', { category: 'item_modifier', extname: '.json', since: '1.17' }],
|
|
17
|
+
['loot_tables', { category: 'loot_table', extname: '.json' }],
|
|
18
|
+
['predicates', { category: 'predicate', extname: '.json' }],
|
|
19
|
+
['recipes', { category: 'recipe', extname: '.json' }],
|
|
20
|
+
['tags/blocks', { category: 'tag/block', extname: '.json' }],
|
|
21
|
+
['tags/entity_types', { category: 'tag/entity_type', extname: '.json' }],
|
|
22
|
+
['tags/fluids', { category: 'tag/fluid', extname: '.json' }],
|
|
23
|
+
['tags/functions', { category: 'tag/function', extname: '.json' }],
|
|
24
|
+
['tags/game_events', { category: 'tag/game_event', extname: '.json', since: '1.17' }],
|
|
25
|
+
['tags/items', { category: 'tag/item', extname: '.json' }],
|
|
26
|
+
['worldgen/biome', { category: 'worldgen/biome', extname: '.json', since: '1.16' }],
|
|
27
|
+
['worldgen/configured_carver', { category: 'worldgen/configured_carver', extname: '.json', since: '1.16' }],
|
|
28
|
+
['worldgen/configured_feature', { category: 'worldgen/configured_feature', extname: '.json', since: '1.16' }],
|
|
29
|
+
['worldgen/configured_structure_feature', { category: 'worldgen/configured_structure_feature', extname: '.json', since: '1.16' }],
|
|
30
|
+
['worldgen/configured_surface_builder', { category: 'worldgen/configured_surface_builder', extname: '.json', since: '1.16', until: '1.17' }],
|
|
31
|
+
['worldgen/noise', { category: 'worldgen/noise', extname: '.json', since: '1.18' }],
|
|
32
|
+
['worldgen/noise_settings', { category: 'worldgen/noise_settings', extname: '.json', since: '1.16' }],
|
|
33
|
+
['worldgen/placed_feature', { category: 'worldgen/placed_feature', extname: '.json', since: '1.18' }],
|
|
34
|
+
['worldgen/processor_list', { category: 'worldgen/processor_list', extname: '.json', since: '1.16' }],
|
|
35
|
+
['worldgen/template_pool', { category: 'worldgen/template_pool', extname: '.json', since: '1.16' }],
|
|
36
|
+
]);
|
|
37
|
+
for (const registry of core_1.RegistryCategories) {
|
|
38
|
+
if (NonTaggableRegistries.has(registry)) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
ans.set(`tags/${registry}`, { category: `tag/${registry}`, extname: '.json', since: '1.18' });
|
|
42
|
+
}
|
|
43
|
+
return ans;
|
|
44
|
+
})();
|
|
45
|
+
function* getRels(uri, rootUris) {
|
|
46
|
+
yield* core_1.fileUtil.getRels(uri, rootUris);
|
|
47
|
+
const parts = uri.split('/');
|
|
48
|
+
for (let i = parts.length - 2; i >= 0; i--) {
|
|
49
|
+
if (parts[i] === 'data') {
|
|
50
|
+
yield parts.slice(i).join('/');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
exports.getRels = getRels;
|
|
56
|
+
function dissectUri(uri, ctx) {
|
|
57
|
+
const regex = /^data\/([^\/]+)\/((?:tags\/|worldgen\/)?[a-z_]+)\/(.*)(\.(?:mcfunction|json))$/;
|
|
58
|
+
const rels = getRels(uri, ctx.roots);
|
|
59
|
+
for (const rel of rels) {
|
|
60
|
+
const match = rel.match(regex);
|
|
61
|
+
if (!match) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const def = exports.Categories.get(match[2]);
|
|
65
|
+
if (!def || def.extname !== match[4]) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (!matchVersion(ctx.project['loadedVersion'], def.since, def.until)) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
category: def.category,
|
|
73
|
+
namespace: match[1],
|
|
74
|
+
identifier: match[3],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
exports.dissectUri = dissectUri;
|
|
80
|
+
const uriBinder = (uris, ctx) => {
|
|
81
|
+
for (const uri of uris) {
|
|
82
|
+
const parts = dissectUri(uri, ctx);
|
|
83
|
+
if (parts) {
|
|
84
|
+
ctx.symbols
|
|
85
|
+
.query(uri, parts.category, `${parts.namespace}:${parts.identifier}`)
|
|
86
|
+
.enter({
|
|
87
|
+
usage: {
|
|
88
|
+
type: 'definition',
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
exports.uriBinder = uriBinder;
|
|
95
|
+
function matchVersion(target, since, until) {
|
|
96
|
+
if (since && dependency_1.MajorVersion.cmp(target, since) < 0)
|
|
97
|
+
return false;
|
|
98
|
+
if (until && dependency_1.MajorVersion.cmp(until, target) < 0)
|
|
99
|
+
return false;
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as core from '@spyglassmc/core';
|
|
2
|
+
/**
|
|
3
|
+
* @returns An array of URIs corresponding to the specified resource.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getUris(category: core.FileCategory, id: string, ctx: core.ProcessorContext): readonly string[];
|
|
6
|
+
export declare function getTagValues(category: core.TagFileCategory, id: string, ctx: core.ProcessorContext): readonly core.FullResourceLocation[];
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
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.getTagValues = exports.getUris = void 0;
|
|
23
|
+
const core = __importStar(require("@spyglassmc/core"));
|
|
24
|
+
const json = __importStar(require("@spyglassmc/json"));
|
|
25
|
+
/**
|
|
26
|
+
* @returns An array of URIs corresponding to the specified resource.
|
|
27
|
+
*/
|
|
28
|
+
function getUris(category, id, ctx) {
|
|
29
|
+
return ctx.symbols
|
|
30
|
+
.query(ctx.doc, category, core.ResourceLocation.lengthen(id))
|
|
31
|
+
.symbol?.definition?.map(v => v.uri) ?? [];
|
|
32
|
+
}
|
|
33
|
+
exports.getUris = getUris;
|
|
34
|
+
function getTagValues(category, id, ctx) {
|
|
35
|
+
const resolveValueNode = (node) => json.JsonStringNode.is(node)
|
|
36
|
+
? node.value
|
|
37
|
+
: node.children.find(n => n.key?.value === 'id').value.value;
|
|
38
|
+
const set = getUris(category, id, ctx).reduce((ans, uri) => {
|
|
39
|
+
const result = ctx.getDocAndNode(uri);
|
|
40
|
+
if (!result || result.node.parserErrors.length || result.node.checkerErrors?.length) {
|
|
41
|
+
return ans;
|
|
42
|
+
}
|
|
43
|
+
// No errors in the node. We can assume it is a semantically correct tag file.
|
|
44
|
+
const rootNode = result.node.children[0];
|
|
45
|
+
const replaceNode = rootNode.children.find(n => n.key?.value === 'replace')?.value;
|
|
46
|
+
const valuesNode = rootNode.children.find(n => n.key?.value === 'values')?.value;
|
|
47
|
+
const replace = replaceNode?.value;
|
|
48
|
+
const values = valuesNode.children.map(n => core.ResourceLocation.lengthen(resolveValueNode(n.value)));
|
|
49
|
+
if (replace) {
|
|
50
|
+
ans = new Set();
|
|
51
|
+
}
|
|
52
|
+
for (const value of values) {
|
|
53
|
+
ans.add(value);
|
|
54
|
+
}
|
|
55
|
+
return ans;
|
|
56
|
+
}, new Set());
|
|
57
|
+
return [...set];
|
|
58
|
+
}
|
|
59
|
+
exports.getTagValues = getTagValues;
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare type MajorVersion = `1.${bigint}`;
|
|
2
|
+
export declare namespace MajorVersion {
|
|
3
|
+
/**
|
|
4
|
+
* @returns
|
|
5
|
+
* * `-1` if `a` is older than `b`.
|
|
6
|
+
* * `0` if `a` is the same as `b`.
|
|
7
|
+
* * `1` if `a` is newer than `b`.
|
|
8
|
+
*/
|
|
9
|
+
function cmp(a: MajorVersion, b: MajorVersion): number;
|
|
10
|
+
}
|
|
11
|
+
export interface VersionInfo {
|
|
12
|
+
major: MajorVersion;
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
isLatest: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare const PackVersionMap: Record<number, MajorVersion | undefined>;
|
|
18
|
+
export interface PackMcmeta {
|
|
19
|
+
pack: {
|
|
20
|
+
pack_format: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export declare namespace PackMcmeta {
|
|
24
|
+
function assert(data: any): asserts data is PackMcmeta;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PackMcmeta = exports.PackVersionMap = exports.MajorVersion = void 0;
|
|
4
|
+
var MajorVersion;
|
|
5
|
+
(function (MajorVersion) {
|
|
6
|
+
/**
|
|
7
|
+
* @returns
|
|
8
|
+
* * `-1` if `a` is older than `b`.
|
|
9
|
+
* * `0` if `a` is the same as `b`.
|
|
10
|
+
* * `1` if `a` is newer than `b`.
|
|
11
|
+
*/
|
|
12
|
+
function cmp(a, b) {
|
|
13
|
+
return Math.sign(Number(a) - Number(b));
|
|
14
|
+
}
|
|
15
|
+
MajorVersion.cmp = cmp;
|
|
16
|
+
})(MajorVersion = exports.MajorVersion || (exports.MajorVersion = {}));
|
|
17
|
+
// DOCS: Update here when format_version is changed.
|
|
18
|
+
exports.PackVersionMap = {
|
|
19
|
+
5: '1.15',
|
|
20
|
+
6: '1.16',
|
|
21
|
+
7: '1.17',
|
|
22
|
+
8: '1.18',
|
|
23
|
+
9: '1.18',
|
|
24
|
+
10: '1.19',
|
|
25
|
+
};
|
|
26
|
+
var PackMcmeta;
|
|
27
|
+
(function (PackMcmeta) {
|
|
28
|
+
function assert(data) {
|
|
29
|
+
const format = data?.pack?.pack_format?.toString();
|
|
30
|
+
if (!format) {
|
|
31
|
+
throw new Error('“pack.pack_format” undefined');
|
|
32
|
+
}
|
|
33
|
+
if (!Object.keys(exports.PackVersionMap).includes(format)) {
|
|
34
|
+
throw new Error(`Unknown pack_format “${format}”`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
PackMcmeta.assert = assert;
|
|
38
|
+
})(PackMcmeta = exports.PackMcmeta || (exports.PackMcmeta = {}));
|
|
39
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export * from './common';
|
|
2
|
+
export * from './mcmeta';
|
|
3
|
+
import * as core from '@spyglassmc/core';
|
|
4
|
+
import type { McmetaSummary, McmetaVersions } from './mcmeta';
|
|
5
|
+
/**
|
|
6
|
+
* Return the deserialized [`versions.json`][versions.json].
|
|
7
|
+
*
|
|
8
|
+
* [versions.json]: https://github.com/misode/mcmeta/blob/summary/versions/data.json
|
|
9
|
+
*/
|
|
10
|
+
export declare function getVersions(downloader: core.Downloader): Promise<McmetaVersions | undefined>;
|
|
11
|
+
interface GetMcmetaSummaryResult extends Partial<McmetaSummary> {
|
|
12
|
+
checksum: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get vanilla resources, including block definitions, fluid definitions, command tree, and registries.
|
|
16
|
+
*
|
|
17
|
+
* @throws Network/file system errors.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getMcmetaSummary(downloader: core.Downloader, logger: core.Logger, version: string, isLatest: boolean, source: string, overridePaths?: core.EnvConfig['mcmetaSummaryOverrides']): Promise<GetMcmetaSummaryResult>;
|
|
20
|
+
/**
|
|
21
|
+
* @param version An already resolved version identifier.
|
|
22
|
+
*
|
|
23
|
+
* @throws Network/file system errors.
|
|
24
|
+
*
|
|
25
|
+
* @returns
|
|
26
|
+
* - `startDepth`: The amount of level to skip when unzipping the tarball.
|
|
27
|
+
* - `uri`: URI to the `.tar.gz` file.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getMcNbtdoc(downloader: core.Downloader, version: string, isLatest: boolean): Promise<core.Dependency>;
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,172 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
|
+
if (mod && mod.__esModule) return mod;
|
|
19
|
+
var result = {};
|
|
20
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
__setModuleDefault(result, mod);
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.getMcNbtdoc = exports.getMcmetaSummary = exports.getVersions = void 0;
|
|
26
|
+
__exportStar(require("./common"), exports);
|
|
27
|
+
__exportStar(require("./mcmeta"), exports);
|
|
28
|
+
const core = __importStar(require("@spyglassmc/core"));
|
|
29
|
+
const mcmeta_1 = require("./mcmeta");
|
|
30
|
+
const DownloaderTtl = 15000;
|
|
31
|
+
/* istanbul ignore next */
|
|
32
|
+
/**
|
|
33
|
+
* Return the deserialized [`versions.json`][versions.json].
|
|
34
|
+
*
|
|
35
|
+
* [versions.json]: https://github.com/misode/mcmeta/blob/summary/versions/data.json
|
|
36
|
+
*/
|
|
37
|
+
async function getVersions(downloader) {
|
|
38
|
+
return downloader.download({
|
|
39
|
+
id: 'mc-je/versions.json.gz',
|
|
40
|
+
uri: 'https://raw.githubusercontent.com/misode/mcmeta/summary/versions/data.json.gz',
|
|
41
|
+
transformer: buffer => core.parseGzippedJson(buffer),
|
|
42
|
+
cache: getCacheOptionsBasedOnGitHubCommitSha('misode', 'mcmeta', 'refs/heads/summary'),
|
|
43
|
+
ttl: DownloaderTtl,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
exports.getVersions = getVersions;
|
|
47
|
+
/* istanbul ignore next */
|
|
48
|
+
/**
|
|
49
|
+
* Get vanilla resources, including block definitions, fluid definitions, command tree, and registries.
|
|
50
|
+
*
|
|
51
|
+
* @throws Network/file system errors.
|
|
52
|
+
*/
|
|
53
|
+
async function getMcmetaSummary(downloader, logger, version, isLatest, source, overridePaths = {}) {
|
|
54
|
+
const ref = getGitRef({
|
|
55
|
+
defaultBranch: 'summary',
|
|
56
|
+
getTag: v => `${v}-summary`,
|
|
57
|
+
isLatest,
|
|
58
|
+
version,
|
|
59
|
+
});
|
|
60
|
+
const uris = (0, mcmeta_1.getMcmetaSummaryUris)(version, isLatest, source);
|
|
61
|
+
let checksum;
|
|
62
|
+
const handleOverride = async (currentValue, overrideConfig) => {
|
|
63
|
+
if (overrideConfig) {
|
|
64
|
+
try {
|
|
65
|
+
const override = await core.fileUtil.readJson(core.fileUtil.pathToFileUri(overrideConfig.path));
|
|
66
|
+
if (overrideConfig.replace) {
|
|
67
|
+
return override;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return core.merge(currentValue, override);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
logger.error(`[je] [mcmeta-overrides] Failed loading customized mcmeta summary file “${overrideConfig.path}”`, e);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return currentValue;
|
|
78
|
+
};
|
|
79
|
+
const getResource = async (type, overrideConfig) => {
|
|
80
|
+
const out = {};
|
|
81
|
+
const data = await downloader.download({
|
|
82
|
+
id: `mc-je/${version}/${type}.json.gz`,
|
|
83
|
+
uri: uris[type],
|
|
84
|
+
transformer: buffer => core.parseGzippedJson(buffer),
|
|
85
|
+
cache: getCacheOptionsBasedOnGitHubCommitSha('misode', 'mcmeta', ref),
|
|
86
|
+
ttl: DownloaderTtl,
|
|
87
|
+
}, out);
|
|
88
|
+
checksum || (checksum = out.checksum);
|
|
89
|
+
return handleOverride(data, overrideConfig);
|
|
90
|
+
};
|
|
91
|
+
const [blocks, commands, fluids, registries] = [
|
|
92
|
+
await getResource('blocks', overridePaths.blocks),
|
|
93
|
+
await getResource('commands', overridePaths.commands),
|
|
94
|
+
await handleOverride(mcmeta_1.Fluids, overridePaths.fluids),
|
|
95
|
+
await getResource('registries', overridePaths.registries),
|
|
96
|
+
];
|
|
97
|
+
return { blocks, commands, fluids, registries, checksum };
|
|
98
|
+
}
|
|
99
|
+
exports.getMcmetaSummary = getMcmetaSummary;
|
|
100
|
+
function getGitRef({ defaultBranch, getTag, isLatest, version }) {
|
|
101
|
+
return isLatest ? `refs/heads/${defaultBranch}` : `refs/tags/${getTag(version)}`;
|
|
102
|
+
}
|
|
103
|
+
const GitHubApiDownloadOptions = {
|
|
104
|
+
headers: {
|
|
105
|
+
Accept: 'application/vnd.github.v3+json',
|
|
106
|
+
'User-Agent': 'SpyglassMC',
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
function getCacheOptionsBasedOnGitHubCommitSha(owner, repo, ref) {
|
|
110
|
+
return {
|
|
111
|
+
checksumExtension: '.commit-sha',
|
|
112
|
+
checksumJob: {
|
|
113
|
+
uri: `https://api.github.com/repos/${owner}/${repo}/git/${ref}`,
|
|
114
|
+
transformer: (buffer) => {
|
|
115
|
+
const response = JSON.parse(core.bufferToString(buffer));
|
|
116
|
+
if (Array.isArray(response)) {
|
|
117
|
+
return response[0].object.sha;
|
|
118
|
+
}
|
|
119
|
+
else if (response.message === undefined) {
|
|
120
|
+
return response.object.sha;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
throw new Error(response.message);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
options: GitHubApiDownloadOptions,
|
|
127
|
+
ttl: DownloaderTtl,
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* @returns The URI to the `.tar.gz` file.
|
|
133
|
+
*/
|
|
134
|
+
async function downloadGitHubRepo({ defaultBranch, downloader, getTag, repo, isLatest, owner, version }) {
|
|
135
|
+
const ref = getGitRef({ defaultBranch, getTag, isLatest, version });
|
|
136
|
+
const out = {};
|
|
137
|
+
await downloader.download({
|
|
138
|
+
id: `mc-je/${version}/${repo}.tar.gz`,
|
|
139
|
+
uri: `https://api.github.com/repos/${owner}/${repo}/tarball/${ref}`,
|
|
140
|
+
transformer: b => b,
|
|
141
|
+
cache: getCacheOptionsBasedOnGitHubCommitSha(owner, repo, ref),
|
|
142
|
+
options: GitHubApiDownloadOptions,
|
|
143
|
+
ttl: DownloaderTtl,
|
|
144
|
+
}, out);
|
|
145
|
+
return core.fileUtil.pathToFileUri(out.cachePath);
|
|
146
|
+
}
|
|
147
|
+
/* istanbul ignore next */
|
|
148
|
+
/**
|
|
149
|
+
* @param version An already resolved version identifier.
|
|
150
|
+
*
|
|
151
|
+
* @throws Network/file system errors.
|
|
152
|
+
*
|
|
153
|
+
* @returns
|
|
154
|
+
* - `startDepth`: The amount of level to skip when unzipping the tarball.
|
|
155
|
+
* - `uri`: URI to the `.tar.gz` file.
|
|
156
|
+
*/
|
|
157
|
+
async function getMcNbtdoc(downloader, version, isLatest) {
|
|
158
|
+
return {
|
|
159
|
+
info: { startDepth: 1 },
|
|
160
|
+
uri: await downloadGitHubRepo({
|
|
161
|
+
defaultBranch: 'master',
|
|
162
|
+
downloader,
|
|
163
|
+
getTag: v => v,
|
|
164
|
+
isLatest,
|
|
165
|
+
owner: 'Yurihaia',
|
|
166
|
+
repo: 'mc-nbtdoc',
|
|
167
|
+
version,
|
|
168
|
+
}),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
exports.getMcNbtdoc = getMcNbtdoc;
|
|
172
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as core from '@spyglassmc/core';
|
|
2
|
+
import type { MajorVersion, PackMcmeta, VersionInfo } from './common';
|
|
3
|
+
export declare function getMajorVersion(version: McmetaVersion): MajorVersion;
|
|
4
|
+
/**
|
|
5
|
+
* @param inputVersion {@link Config.env.gameVersion}
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveConfiguredVersion(inputVersion: string, { packMcmeta, versions }: {
|
|
8
|
+
packMcmeta: PackMcmeta | undefined;
|
|
9
|
+
versions: McmetaVersions;
|
|
10
|
+
}): VersionInfo;
|
|
11
|
+
export declare function getMcmetaSummaryUris(version: string, isLatest: boolean, source: string): {
|
|
12
|
+
blocks: core.RemoteUriString;
|
|
13
|
+
commands: core.RemoteUriString;
|
|
14
|
+
registries: core.RemoteUriString;
|
|
15
|
+
};
|
|
16
|
+
export declare function symbolRegistrar(summary: McmetaSummary): core.SymbolRegistrar;
|
|
17
|
+
export declare const Fluids: McmetaStates;
|
|
18
|
+
export interface McmetaVersion {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
release_target: string;
|
|
22
|
+
type: 'release' | 'snapshot';
|
|
23
|
+
stable: boolean;
|
|
24
|
+
data_version: number;
|
|
25
|
+
protocol_version: number;
|
|
26
|
+
data_pack_version: number;
|
|
27
|
+
resource_pack_version: number;
|
|
28
|
+
build_time: string;
|
|
29
|
+
release_time: string;
|
|
30
|
+
sha1: string;
|
|
31
|
+
}
|
|
32
|
+
export declare type McmetaVersions = McmetaVersion[];
|
|
33
|
+
export interface McmetaSummary {
|
|
34
|
+
blocks: McmetaStates;
|
|
35
|
+
commands: McmetaCommands;
|
|
36
|
+
fluids: McmetaStates;
|
|
37
|
+
registries: McmetaRegistries;
|
|
38
|
+
}
|
|
39
|
+
export interface McmetaStates {
|
|
40
|
+
[id: string]: [
|
|
41
|
+
{
|
|
42
|
+
[name: string]: string[];
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
[name: string]: string;
|
|
46
|
+
}
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
export declare type McmetaCommands = RootTreeNode;
|
|
50
|
+
interface BaseTreeNode {
|
|
51
|
+
type: string;
|
|
52
|
+
children?: {
|
|
53
|
+
[name: string]: CommandTreeNode;
|
|
54
|
+
};
|
|
55
|
+
executable?: boolean;
|
|
56
|
+
redirect?: [string];
|
|
57
|
+
}
|
|
58
|
+
export interface ArgumentTreeNode extends BaseTreeNode {
|
|
59
|
+
type: 'argument';
|
|
60
|
+
parser: string;
|
|
61
|
+
properties?: {
|
|
62
|
+
[name: string]: any;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export interface LiteralTreeNode extends BaseTreeNode {
|
|
66
|
+
type: 'literal';
|
|
67
|
+
}
|
|
68
|
+
export interface RootTreeNode extends BaseTreeNode {
|
|
69
|
+
type: 'root';
|
|
70
|
+
children: {
|
|
71
|
+
[command: string]: LiteralTreeNode;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export declare type CommandTreeNode = ArgumentTreeNode | LiteralTreeNode | RootTreeNode;
|
|
75
|
+
export interface McmetaRegistries {
|
|
76
|
+
[id: string]: string[];
|
|
77
|
+
}
|
|
78
|
+
export {};
|
|
79
|
+
//# sourceMappingURL=mcmeta.d.ts.map
|