@spyglassmc/java-edition 0.3.1 → 0.3.2
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 +94 -19
- package/lib/common/index.js +10 -7
- package/lib/dependency/index.js +11 -9
- package/lib/dependency/mcmeta.d.ts +1 -1
- package/lib/dependency/mcmeta.js +27 -13
- package/lib/index.js +15 -6
- package/lib/json/checker/data/advancement.js +24 -13
- package/lib/json/checker/data/biome.js +3 -3
- package/lib/json/checker/data/common.js +15 -27
- package/lib/json/checker/data/dimension.js +7 -18
- package/lib/json/checker/data/feature.js +41 -27
- package/lib/json/checker/data/index.d.ts +1 -1
- package/lib/json/checker/data/index.js +3 -3
- package/lib/json/checker/data/loot_table.js +16 -17
- package/lib/json/checker/data/recipe.js +1 -1
- package/lib/json/checker/data/structure.js +20 -12
- package/lib/json/checker/data/tag.js +2 -2
- package/lib/json/checker/data/text_component.js +21 -12
- package/lib/json/checker/index.d.ts +10 -3
- package/lib/json/checker/index.js +230 -3
- package/lib/json/checker/util/advancement.js +3 -3
- package/lib/json/checker/util/block_states.d.ts +2 -2
- package/lib/json/checker/util/block_states.js +7 -5
- package/lib/json/checker/util/color.js +8 -2
- package/lib/json/checker/util/nbt.js +3 -2
- package/lib/json/checker/util/recipe.js +7 -6
- package/lib/json/checker/util/version.js +2 -2
- package/lib/mcfunction/checker/index.js +10 -7
- package/lib/mcfunction/colorizer/index.js +2 -4
- package/lib/mcfunction/common/index.js +46 -15
- package/lib/mcfunction/completer/argument.js +53 -24
- package/lib/mcfunction/inlayHintProvider.js +8 -3
- package/lib/mcfunction/node/argument.d.ts +3 -3
- package/lib/mcfunction/node/argument.js +57 -17
- package/lib/mcfunction/parser/argument.js +124 -52
- package/lib/mcfunction/signatureHelpProvider.js +6 -3
- package/lib/mcfunction/tree/patch.js +132 -126
- package/package.json +7 -7
package/lib/binder/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const Categories: Map<string, {
|
|
|
7
7
|
}>;
|
|
8
8
|
export declare function getRels(uri: string, rootUris: readonly RootUriString[]): Generator<string, undefined, unknown>;
|
|
9
9
|
export declare function dissectUri(uri: string, ctx: ContextBase): {
|
|
10
|
-
category: "function" | "advancement" | "dimension" | "dimension_type" | "item_modifier" | "loot_table" | "predicate" | "recipe" | "structure" | "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/activity" | "tag/attribute" | "tag/block" | "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";
|
|
10
|
+
category: "function" | "advancement" | "dimension" | "dimension_type" | "item_modifier" | "loot_table" | "predicate" | "recipe" | "structure" | "worldgen/biome" | "worldgen/configured_carver" | "worldgen/configured_feature" | "worldgen/configured_structure_feature" | "worldgen/configured_surface_builder" | "worldgen/density_function" | "worldgen/noise" | "worldgen/noise_settings" | "worldgen/placed_feature" | "worldgen/processor_list" | "worldgen/template_pool" | "tag/function" | "tag/activity" | "tag/attribute" | "tag/block" | "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/density_function" | "tag/worldgen/noise" | "tag/worldgen/noise_settings" | "tag/worldgen/placed_feature" | "tag/worldgen/processor_list" | "tag/worldgen/template_pool";
|
|
11
11
|
namespace: string;
|
|
12
12
|
identifier: string;
|
|
13
13
|
} | undefined;
|
package/lib/binder/index.js
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
|
-
import { fileUtil,
|
|
1
|
+
import { fileUtil, TaggableResourceLocationCategories } from '@spyglassmc/core';
|
|
2
2
|
import { ReleaseVersion } from '../dependency/index.js';
|
|
3
3
|
export const Categories = (() => {
|
|
4
4
|
const NonTaggableRegistries = new Set([
|
|
5
|
-
'block',
|
|
6
|
-
'
|
|
5
|
+
'block',
|
|
6
|
+
'fluid',
|
|
7
|
+
'function',
|
|
8
|
+
'game_event',
|
|
9
|
+
'item',
|
|
10
|
+
'worldgen/block_placer_type',
|
|
11
|
+
'worldgen/surface_builder', // They are removed at some point.
|
|
7
12
|
]);
|
|
8
13
|
const ans = new Map([
|
|
9
14
|
['advancements', { category: 'advancement', extname: '.json' }],
|
|
10
15
|
['dimension', { category: 'dimension', extname: '.json', since: '1.16' }],
|
|
11
|
-
[
|
|
16
|
+
[
|
|
17
|
+
'dimension_type',
|
|
18
|
+
{ category: 'dimension_type', extname: '.json', since: '1.16' },
|
|
19
|
+
],
|
|
12
20
|
['functions', { category: 'function', extname: '.mcfunction' }],
|
|
13
|
-
[
|
|
21
|
+
[
|
|
22
|
+
'item_modifiers',
|
|
23
|
+
{ category: 'item_modifier', extname: '.json', since: '1.17' },
|
|
24
|
+
],
|
|
14
25
|
['loot_tables', { category: 'loot_table', extname: '.json' }],
|
|
15
26
|
['predicates', { category: 'predicate', extname: '.json' }],
|
|
16
27
|
['recipes', { category: 'recipe', extname: '.json' }],
|
|
@@ -18,24 +29,86 @@ export const Categories = (() => {
|
|
|
18
29
|
['tags/entity_types', { category: 'tag/entity_type', extname: '.json' }],
|
|
19
30
|
['tags/fluids', { category: 'tag/fluid', extname: '.json' }],
|
|
20
31
|
['tags/functions', { category: 'tag/function', extname: '.json' }],
|
|
21
|
-
[
|
|
32
|
+
[
|
|
33
|
+
'tags/game_events',
|
|
34
|
+
{ category: 'tag/game_event', extname: '.json', since: '1.17' },
|
|
35
|
+
],
|
|
22
36
|
['tags/items', { category: 'tag/item', extname: '.json' }],
|
|
23
|
-
[
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
[
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
[
|
|
38
|
+
'worldgen/biome',
|
|
39
|
+
{ category: 'worldgen/biome', extname: '.json', since: '1.16' },
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
'worldgen/configured_carver',
|
|
43
|
+
{
|
|
44
|
+
category: 'worldgen/configured_carver',
|
|
45
|
+
extname: '.json',
|
|
46
|
+
since: '1.16',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
[
|
|
50
|
+
'worldgen/configured_feature',
|
|
51
|
+
{
|
|
52
|
+
category: 'worldgen/configured_feature',
|
|
53
|
+
extname: '.json',
|
|
54
|
+
since: '1.16',
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
'worldgen/configured_structure_feature',
|
|
59
|
+
{
|
|
60
|
+
category: 'worldgen/configured_structure_feature',
|
|
61
|
+
extname: '.json',
|
|
62
|
+
since: '1.16',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
'worldgen/configured_surface_builder',
|
|
67
|
+
{
|
|
68
|
+
category: 'worldgen/configured_surface_builder',
|
|
69
|
+
extname: '.json',
|
|
70
|
+
since: '1.16',
|
|
71
|
+
until: '1.17',
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
[
|
|
75
|
+
'worldgen/density_function',
|
|
76
|
+
{
|
|
77
|
+
category: 'worldgen/density_function',
|
|
78
|
+
extname: '.json',
|
|
79
|
+
since: '1.18',
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
[
|
|
83
|
+
'worldgen/noise',
|
|
84
|
+
{ category: 'worldgen/noise', extname: '.json', since: '1.18' },
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
'worldgen/noise_settings',
|
|
88
|
+
{ category: 'worldgen/noise_settings', extname: '.json', since: '1.16' },
|
|
89
|
+
],
|
|
90
|
+
[
|
|
91
|
+
'worldgen/placed_feature',
|
|
92
|
+
{ category: 'worldgen/placed_feature', extname: '.json', since: '1.18' },
|
|
93
|
+
],
|
|
94
|
+
[
|
|
95
|
+
'worldgen/processor_list',
|
|
96
|
+
{ category: 'worldgen/processor_list', extname: '.json', since: '1.16' },
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
'worldgen/template_pool',
|
|
100
|
+
{ category: 'worldgen/template_pool', extname: '.json', since: '1.16' },
|
|
101
|
+
],
|
|
33
102
|
]);
|
|
34
|
-
for (const registry of
|
|
103
|
+
for (const registry of TaggableResourceLocationCategories) {
|
|
35
104
|
if (NonTaggableRegistries.has(registry)) {
|
|
36
105
|
continue;
|
|
37
106
|
}
|
|
38
|
-
ans.set(`tags/${registry}`, {
|
|
107
|
+
ans.set(`tags/${registry}`, {
|
|
108
|
+
category: `tag/${registry}`,
|
|
109
|
+
extname: '.json',
|
|
110
|
+
since: '1.18',
|
|
111
|
+
});
|
|
39
112
|
}
|
|
40
113
|
return ans;
|
|
41
114
|
})();
|
|
@@ -61,7 +134,9 @@ export function dissectUri(uri, ctx) {
|
|
|
61
134
|
if (!def || def.extname !== match[4]) {
|
|
62
135
|
continue;
|
|
63
136
|
}
|
|
64
|
-
|
|
137
|
+
const loadedVersion = ctx.project['loadedVersion'];
|
|
138
|
+
if (!loadedVersion || // FIXME: check why this can be undefined sometimes
|
|
139
|
+
!matchVersion(loadedVersion, def.since, def.until)) {
|
|
65
140
|
continue;
|
|
66
141
|
}
|
|
67
142
|
return {
|
package/lib/common/index.js
CHANGED
|
@@ -4,26 +4,29 @@ import * as json from '@spyglassmc/json';
|
|
|
4
4
|
* @returns An array of URIs corresponding to the specified resource.
|
|
5
5
|
*/
|
|
6
6
|
export function getUris(category, id, ctx) {
|
|
7
|
-
return ctx.symbols
|
|
7
|
+
return (ctx.symbols
|
|
8
8
|
.query(ctx.doc, category, core.ResourceLocation.lengthen(id))
|
|
9
|
-
.symbol?.definition?.map(v => v.uri) ?? [];
|
|
9
|
+
.symbol?.definition?.map((v) => v.uri) ?? []);
|
|
10
10
|
}
|
|
11
11
|
export function getTagValues(category, id, ctx) {
|
|
12
12
|
const resolveValueNode = (node) => json.JsonStringNode.is(node)
|
|
13
13
|
? node.value
|
|
14
|
-
: node.children.find(n => n.key?.value === 'id')
|
|
14
|
+
: node.children.find((n) => n.key?.value === 'id')
|
|
15
|
+
.value.value;
|
|
15
16
|
const set = getUris(category, id, ctx).reduce((ans, uri) => {
|
|
16
17
|
// const result = ctx.getDocAndNode(uri)
|
|
17
18
|
const result = undefined; // FIXME: Use global symbol table to get the result
|
|
18
|
-
if (!result ||
|
|
19
|
+
if (!result ||
|
|
20
|
+
result.node.parserErrors.length ||
|
|
21
|
+
result.node.checkerErrors?.length) {
|
|
19
22
|
return ans;
|
|
20
23
|
}
|
|
21
24
|
// No errors in the node. We can assume it is a semantically correct tag file.
|
|
22
25
|
const rootNode = result.node.children[0];
|
|
23
|
-
const replaceNode = rootNode.children.find(n => n.key?.value === 'replace')?.value;
|
|
24
|
-
const valuesNode = rootNode.children.find(n => n.key?.value === 'values')?.value;
|
|
26
|
+
const replaceNode = rootNode.children.find((n) => n.key?.value === 'replace')?.value;
|
|
27
|
+
const valuesNode = rootNode.children.find((n) => n.key?.value === 'values')?.value;
|
|
25
28
|
const replace = replaceNode?.value;
|
|
26
|
-
const values = valuesNode.children.map(n => core.ResourceLocation.lengthen(resolveValueNode(n.value)));
|
|
29
|
+
const values = valuesNode.children.map((n) => core.ResourceLocation.lengthen(resolveValueNode(n.value)));
|
|
27
30
|
if (replace) {
|
|
28
31
|
ans = new Set();
|
|
29
32
|
}
|
package/lib/dependency/index.js
CHANGED
|
@@ -13,7 +13,7 @@ export async function getVersions(externals, downloader) {
|
|
|
13
13
|
return downloader.download({
|
|
14
14
|
id: 'mc-je/versions.json.gz',
|
|
15
15
|
uri: 'https://raw.githubusercontent.com/misode/mcmeta/summary/versions/data.json.gz',
|
|
16
|
-
transformer: buffer => core.parseGzippedJson(externals, buffer),
|
|
16
|
+
transformer: (buffer) => core.parseGzippedJson(externals, buffer),
|
|
17
17
|
cache: getCacheOptionsBasedOnGitHubCommitSha('misode', 'mcmeta', 'refs/heads/summary'),
|
|
18
18
|
ttl: DownloaderTtl,
|
|
19
19
|
});
|
|
@@ -27,7 +27,7 @@ export async function getVersions(externals, downloader) {
|
|
|
27
27
|
export async function getMcmetaSummary(externals, downloader, logger, version, isLatest, source, overridePaths = {}) {
|
|
28
28
|
const ref = getGitRef({
|
|
29
29
|
defaultBranch: 'summary',
|
|
30
|
-
getTag: v => `${v}-summary`,
|
|
30
|
+
getTag: (v) => `${v}-summary`,
|
|
31
31
|
isLatest,
|
|
32
32
|
version,
|
|
33
33
|
});
|
|
@@ -36,7 +36,7 @@ export async function getMcmetaSummary(externals, downloader, logger, version, i
|
|
|
36
36
|
async function handleOverride(currentValue, overrideConfig) {
|
|
37
37
|
if (overrideConfig) {
|
|
38
38
|
try {
|
|
39
|
-
const override = await core.fileUtil.readJson(externals, overrideConfig.path);
|
|
39
|
+
const override = (await core.fileUtil.readJson(externals, overrideConfig.path));
|
|
40
40
|
if (overrideConfig.replace) {
|
|
41
41
|
return override;
|
|
42
42
|
}
|
|
@@ -55,7 +55,7 @@ export async function getMcmetaSummary(externals, downloader, logger, version, i
|
|
|
55
55
|
const data = await downloader.download({
|
|
56
56
|
id: `mc-je/${version}/${type}.json.gz`,
|
|
57
57
|
uri: uris[type],
|
|
58
|
-
transformer: buffer => core.parseGzippedJson(externals, buffer),
|
|
58
|
+
transformer: (buffer) => core.parseGzippedJson(externals, buffer),
|
|
59
59
|
cache: getCacheOptionsBasedOnGitHubCommitSha('misode', 'mcmeta', ref),
|
|
60
60
|
ttl: DownloaderTtl,
|
|
61
61
|
}, out);
|
|
@@ -70,8 +70,10 @@ export async function getMcmetaSummary(externals, downloader, logger, version, i
|
|
|
70
70
|
];
|
|
71
71
|
return { blocks, commands, fluids, registries, checksum };
|
|
72
72
|
}
|
|
73
|
-
function getGitRef({ defaultBranch, getTag, isLatest, version }) {
|
|
74
|
-
return isLatest
|
|
73
|
+
function getGitRef({ defaultBranch, getTag, isLatest, version, }) {
|
|
74
|
+
return isLatest
|
|
75
|
+
? `refs/heads/${defaultBranch}`
|
|
76
|
+
: `refs/tags/${getTag(version)}`;
|
|
75
77
|
}
|
|
76
78
|
const GitHubApiDownloadOptions = {
|
|
77
79
|
headers: {
|
|
@@ -109,13 +111,13 @@ function getCacheOptionsBasedOnGitHubCommitSha(owner, repo, ref) {
|
|
|
109
111
|
*
|
|
110
112
|
* @returns The URI to the `.tar.gz` file.
|
|
111
113
|
*/
|
|
112
|
-
async function downloadGitHubRepo({ defaultBranch, downloader, getTag, repo, isLatest, owner, version }) {
|
|
114
|
+
async function downloadGitHubRepo({ defaultBranch, downloader, getTag, repo, isLatest, owner, version, }) {
|
|
113
115
|
const ref = getGitRef({ defaultBranch, getTag, isLatest, version });
|
|
114
116
|
const out = {};
|
|
115
117
|
await downloader.download({
|
|
116
118
|
id: `mc-je/${version}/${repo}.tar.gz`,
|
|
117
119
|
uri: `https://api.github.com/repos/${owner}/${repo}/tarball/${ref}`,
|
|
118
|
-
transformer: b => b,
|
|
120
|
+
transformer: (b) => b,
|
|
119
121
|
cache: getCacheOptionsBasedOnGitHubCommitSha(owner, repo, ref),
|
|
120
122
|
options: GitHubApiDownloadOptions,
|
|
121
123
|
ttl: DownloaderTtl,
|
|
@@ -138,7 +140,7 @@ export async function getVanillaMcdoc(downloader) {
|
|
|
138
140
|
await downloader.download({
|
|
139
141
|
id: 'mc-je/vanilla-mcdoc.tar.gz',
|
|
140
142
|
uri: `https://api.github.com/repos/${owner}/${repo}/tarball/${ref}`,
|
|
141
|
-
transformer: b => b,
|
|
143
|
+
transformer: (b) => b,
|
|
142
144
|
cache: getCacheOptionsBasedOnGitHubCommitSha(owner, repo, ref),
|
|
143
145
|
options: GitHubApiDownloadOptions,
|
|
144
146
|
ttl: DownloaderTtl,
|
|
@@ -3,7 +3,7 @@ import type { PackMcmeta, VersionInfo } from './common.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* @param inputVersion {@link core.Config.env.gameVersion}
|
|
5
5
|
*/
|
|
6
|
-
export declare function resolveConfiguredVersion(inputVersion: string, { packMcmeta, versions }: {
|
|
6
|
+
export declare function resolveConfiguredVersion(inputVersion: string, { packMcmeta, versions, }: {
|
|
7
7
|
packMcmeta: PackMcmeta | undefined;
|
|
8
8
|
versions: McmetaVersions;
|
|
9
9
|
}): VersionInfo;
|
package/lib/dependency/mcmeta.js
CHANGED
|
@@ -3,7 +3,7 @@ import { PackVersionMap } from './common.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* @param inputVersion {@link core.Config.env.gameVersion}
|
|
5
5
|
*/
|
|
6
|
-
export function resolveConfiguredVersion(inputVersion, { packMcmeta, versions }) {
|
|
6
|
+
export function resolveConfiguredVersion(inputVersion, { packMcmeta, versions, }) {
|
|
7
7
|
function toVersionInfo(index) {
|
|
8
8
|
if (index < 0) {
|
|
9
9
|
index = 0;
|
|
@@ -12,7 +12,7 @@ export function resolveConfiguredVersion(inputVersion, { packMcmeta, versions })
|
|
|
12
12
|
return {
|
|
13
13
|
id: version.id,
|
|
14
14
|
name: version.name,
|
|
15
|
-
release: version.release_target,
|
|
15
|
+
release: (version.release_target ?? '1.99'),
|
|
16
16
|
isLatest: index === 0,
|
|
17
17
|
};
|
|
18
18
|
}
|
|
@@ -25,18 +25,19 @@ export function resolveConfiguredVersion(inputVersion, { packMcmeta, versions })
|
|
|
25
25
|
if (packMcmeta) {
|
|
26
26
|
const regex = PackVersionMap[packMcmeta.pack.pack_format];
|
|
27
27
|
if (regex) {
|
|
28
|
-
return toVersionInfo(versions.findIndex(v => regex.test(v.release_target)));
|
|
28
|
+
return toVersionInfo(versions.findIndex((v) => regex.test(v.release_target)));
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
return toVersionInfo(0);
|
|
32
32
|
}
|
|
33
33
|
else if (inputVersion === 'latest release') {
|
|
34
|
-
return toVersionInfo(versions.findIndex(v => v.type === 'release'));
|
|
34
|
+
return toVersionInfo(versions.findIndex((v) => v.type === 'release'));
|
|
35
35
|
}
|
|
36
36
|
else if (inputVersion === 'latest snapshot') {
|
|
37
|
-
return toVersionInfo(versions.findIndex(v => v.type === 'snapshot'));
|
|
37
|
+
return toVersionInfo(versions.findIndex((v) => v.type === 'snapshot'));
|
|
38
38
|
}
|
|
39
|
-
return toVersionInfo(versions.findIndex(v => inputVersion === v.id.toLowerCase() ||
|
|
39
|
+
return toVersionInfo(versions.findIndex((v) => inputVersion === v.id.toLowerCase() ||
|
|
40
|
+
inputVersion === v.name.toLowerCase()));
|
|
40
41
|
}
|
|
41
42
|
const DataSources = {
|
|
42
43
|
fastly: 'https://fastly.jsdelivr.net/gh/${user}/${repo}@${tag}/${path}',
|
|
@@ -76,14 +77,14 @@ export function symbolRegistrar(summary) {
|
|
|
76
77
|
.query(uri, category, core.ResourceLocation.lengthen(id))
|
|
77
78
|
.onEach(Object.entries(properties), ([state, values], blockQuery) => {
|
|
78
79
|
const defaultValue = defaults[state];
|
|
79
|
-
blockQuery.member(`${uri}#${capitalizedCategory}_states`, state, stateQuery => {
|
|
80
|
+
blockQuery.member(`${uri}#${capitalizedCategory}_states`, state, (stateQuery) => {
|
|
80
81
|
stateQuery
|
|
81
82
|
.enter({
|
|
82
83
|
data: { subcategory: 'state' },
|
|
83
84
|
usage: { type: 'declaration' },
|
|
84
85
|
})
|
|
85
|
-
.onEach(values, value => {
|
|
86
|
-
stateQuery.member(value, valueQuery => {
|
|
86
|
+
.onEach(values, (value) => {
|
|
87
|
+
stateQuery.member(value, (valueQuery) => {
|
|
87
88
|
valueQuery.enter({
|
|
88
89
|
data: { subcategory: 'state_value' },
|
|
89
90
|
usage: { type: 'declaration' },
|
|
@@ -105,7 +106,8 @@ export function symbolRegistrar(summary) {
|
|
|
105
106
|
}
|
|
106
107
|
function addRegistriesSymbols(registries, symbols) {
|
|
107
108
|
function isCategory(str) {
|
|
108
|
-
return (core.FileCategories.includes(str) ||
|
|
109
|
+
return (core.FileCategories.includes(str) ||
|
|
110
|
+
core.RegistryCategories.includes(str));
|
|
109
111
|
}
|
|
110
112
|
for (const [registryId, registry] of Object.entries(registries)) {
|
|
111
113
|
if (isCategory(registryId)) {
|
|
@@ -117,15 +119,27 @@ export function symbolRegistrar(summary) {
|
|
|
117
119
|
}
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
|
-
return symbols => {
|
|
122
|
+
return (symbols) => {
|
|
121
123
|
addRegistriesSymbols(summary.registries, symbols);
|
|
122
124
|
addStatesSymbols('block', summary.blocks, symbols);
|
|
123
125
|
addStatesSymbols('fluid', summary.fluids, symbols);
|
|
124
126
|
};
|
|
125
127
|
}
|
|
126
128
|
export const Fluids = {
|
|
127
|
-
flowing_lava: [
|
|
128
|
-
|
|
129
|
+
flowing_lava: [
|
|
130
|
+
{
|
|
131
|
+
falling: ['false', 'true'],
|
|
132
|
+
level: ['1', '2', '3', '4', '5', '6', '7', '8'],
|
|
133
|
+
},
|
|
134
|
+
{ falling: 'false', level: '1' },
|
|
135
|
+
],
|
|
136
|
+
flowing_water: [
|
|
137
|
+
{
|
|
138
|
+
falling: ['false', 'true'],
|
|
139
|
+
level: ['1', '2', '3', '4', '5', '6', '7', '8'],
|
|
140
|
+
},
|
|
141
|
+
{ falling: 'false', level: '1' },
|
|
142
|
+
],
|
|
129
143
|
lava: [{ falling: ['false', 'true'] }, { falling: 'false' }],
|
|
130
144
|
water: [{ falling: ['false', 'true'] }, { falling: 'false' }],
|
|
131
145
|
};
|
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as core from '@spyglassmc/core';
|
|
|
2
2
|
import * as mcdoc from '@spyglassmc/mcdoc';
|
|
3
3
|
import * as nbt from '@spyglassmc/nbt';
|
|
4
4
|
import { uriBinder } from './binder/index.js';
|
|
5
|
-
import { getMcmetaSummary, getVanillaMcdoc, getVersions, PackMcmeta, resolveConfiguredVersion, symbolRegistrar } from './dependency/index.js';
|
|
5
|
+
import { getMcmetaSummary, getVanillaMcdoc, getVersions, PackMcmeta, resolveConfiguredVersion, symbolRegistrar, } from './dependency/index.js';
|
|
6
6
|
import * as jeJson from './json/index.js';
|
|
7
7
|
import * as jeMcf from './mcfunction/index.js';
|
|
8
8
|
export * as dependency from './dependency/index.js';
|
|
@@ -33,10 +33,13 @@ export const initialize = async (ctx) => {
|
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
const packMcmeta = await getPackMcmeta();
|
|
36
|
-
const { release, id: version, isLatest } = resolveConfiguredVersion(config.env.gameVersion, { packMcmeta, versions });
|
|
36
|
+
const { release, id: version, isLatest, } = resolveConfiguredVersion(config.env.gameVersion, { packMcmeta, versions });
|
|
37
37
|
meta.registerDependencyProvider('@vanilla-mcdoc', () => getVanillaMcdoc(downloader));
|
|
38
38
|
const summary = await getMcmetaSummary(ctx.externals, downloader, logger, version, isLatest, config.env.dataSource, config.env.mcmetaSummaryOverrides);
|
|
39
|
-
if (!summary.blocks ||
|
|
39
|
+
if (!summary.blocks ||
|
|
40
|
+
!summary.commands ||
|
|
41
|
+
!summary.fluids ||
|
|
42
|
+
!summary.registries) {
|
|
40
43
|
ctx.logger.error('[je-initialize] Failed loading mcmeta summaries. Expect everything to be broken.');
|
|
41
44
|
return;
|
|
42
45
|
}
|
|
@@ -47,13 +50,19 @@ export const initialize = async (ctx) => {
|
|
|
47
50
|
meta.registerLinter('nameOfNbtKey', {
|
|
48
51
|
configValidator: core.linter.configValidator.nameConvention,
|
|
49
52
|
linter: core.linter.nameConvention('value'),
|
|
50
|
-
nodePredicate: n =>
|
|
53
|
+
nodePredicate: (n) =>
|
|
51
54
|
// nbt compound keys without mcdoc definition.
|
|
52
|
-
(!n.symbol &&
|
|
55
|
+
(!n.symbol &&
|
|
56
|
+
n.parent?.parent?.type === 'nbt:compound' &&
|
|
57
|
+
core.PairNode.is(n.parent) &&
|
|
58
|
+
n.type === 'string' &&
|
|
59
|
+
n.parent.key === n) ||
|
|
53
60
|
// nbt path keys without mcdoc definition.
|
|
54
61
|
(!n.symbol && n.parent?.type === 'nbt:path' && n.type === 'string') ||
|
|
55
62
|
// mcdoc compound key definition outside of `::minecraft` modules.
|
|
56
|
-
(mcdoc.StructFieldNode.is(n.parent) &&
|
|
63
|
+
(mcdoc.StructFieldNode.is(n.parent) &&
|
|
64
|
+
mcdoc.StructKeyNode.is(n) &&
|
|
65
|
+
!n.symbol?.path[0]?.startsWith('::minecraft')),
|
|
57
66
|
});
|
|
58
67
|
jeJson.initialize(ctx);
|
|
59
68
|
jeMcf.initialize(ctx, summary.commands, release);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { any, as, boolean, dispatch, extract, extractStringArray, int, listOf, literal, object, opt, pick, record, ref, resource, simpleString, string, when } from '@spyglassmc/json/lib/checker/primitives/index.js';
|
|
1
|
+
import { any, as, boolean, dispatch, extract, extractStringArray, int, listOf, literal, object, opt, pick, record, ref, resource, simpleString, string, when, } from '@spyglassmc/json/lib/checker/primitives/index.js';
|
|
2
2
|
import { dissectUri } from '../../../binder/index.js';
|
|
3
|
-
import { blockStateMap, criterionReference, deprecated, nbt, versioned } from '../util/index.js';
|
|
3
|
+
import { blockStateMap, criterionReference, deprecated, nbt, versioned, } from '../util/index.js';
|
|
4
4
|
import { float_bounds, int_bounds, Slots } from './common.js';
|
|
5
5
|
import { predicate } from './loot_table.js';
|
|
6
6
|
import { text_component } from './text_component.js';
|
|
@@ -64,7 +64,11 @@ export const item_predicate = as('item', dispatch((props, ctx) => record({
|
|
|
64
64
|
count: opt(int_bounds),
|
|
65
65
|
durability: opt(float_bounds),
|
|
66
66
|
potion: opt(resource('potion')),
|
|
67
|
-
nbt: opt(nbt({
|
|
67
|
+
nbt: opt(nbt({
|
|
68
|
+
registry: 'item',
|
|
69
|
+
ids: extractStringArray('items', props),
|
|
70
|
+
tag: extract('tag', props),
|
|
71
|
+
})),
|
|
68
72
|
enchantments: opt(listOf(record({
|
|
69
73
|
enchantment: opt(resource('enchantment')),
|
|
70
74
|
levels: opt(int_bounds),
|
|
@@ -77,14 +81,18 @@ export const block_predicate = as('block', dispatch((props, ctx) => record({
|
|
|
77
81
|
blocks: opt(listOf(resource('block'))),
|
|
78
82
|
}),
|
|
79
83
|
tag: opt(resource('tag/block')),
|
|
80
|
-
nbt: opt(nbt({
|
|
84
|
+
nbt: opt(nbt({
|
|
85
|
+
registry: 'block',
|
|
86
|
+
ids: extractStringArray('blocks', props),
|
|
87
|
+
tag: extract('tag', props),
|
|
88
|
+
})),
|
|
81
89
|
state: opt(blockStateMap({
|
|
82
90
|
ids: extractStringArray('blocks', props),
|
|
83
91
|
tag: extract('tag', props),
|
|
84
92
|
mixedTypes: true,
|
|
85
93
|
})),
|
|
86
94
|
})));
|
|
87
|
-
export const fluid_predicate = as('fluid', dispatch(props => record({
|
|
95
|
+
export const fluid_predicate = as('fluid', dispatch((props) => record({
|
|
88
96
|
fluid: opt(resource('fluid')),
|
|
89
97
|
tag: opt(resource('tag/fluid')),
|
|
90
98
|
state: opt(blockStateMap({
|
|
@@ -197,13 +205,10 @@ export const damage_predicate = as('damage', record({
|
|
|
197
205
|
source_entity: opt(entity_predicate),
|
|
198
206
|
type: opt(damage_source_predicate),
|
|
199
207
|
}));
|
|
200
|
-
const entity = any([
|
|
201
|
-
entity_predicate,
|
|
202
|
-
listOf(ref(() => predicate)),
|
|
203
|
-
]);
|
|
208
|
+
const entity = any([entity_predicate, listOf(ref(() => predicate))]);
|
|
204
209
|
export const criterion = as('criterion', dispatch('trigger', (trigger, _, ctx) => record({
|
|
205
210
|
trigger: resource(Triggers(ctx)),
|
|
206
|
-
conditions: opt(dispatch(props => record({
|
|
211
|
+
conditions: opt(dispatch((props) => record({
|
|
207
212
|
...versioned(ctx, '1.16', when(trigger, ['impossible'], {}, {
|
|
208
213
|
player: opt(versioned(ctx, entity_predicate, '1.16', entity)),
|
|
209
214
|
})),
|
|
@@ -381,7 +386,12 @@ export const criterion = as('criterion', dispatch('trigger', (trigger, _, ctx) =
|
|
|
381
386
|
location: opt(versioned(ctx, '1.16', location_predicate)),
|
|
382
387
|
},
|
|
383
388
|
}),
|
|
384
|
-
...when(trigger, [
|
|
389
|
+
...when(trigger, [
|
|
390
|
+
'hero_of_the_village',
|
|
391
|
+
'location',
|
|
392
|
+
'slept_in_bed',
|
|
393
|
+
'voluntary_exile',
|
|
394
|
+
], {
|
|
385
395
|
position: opt(deprecated(ctx, '1.16', record({
|
|
386
396
|
x: opt(float_bounds),
|
|
387
397
|
y: opt(float_bounds),
|
|
@@ -401,7 +411,7 @@ export const criterion = as('criterion', dispatch('trigger', (trigger, _, ctx) =
|
|
|
401
411
|
})));
|
|
402
412
|
export const advancement = as('advancement', record({
|
|
403
413
|
display: opt(record({
|
|
404
|
-
icon: dispatch(props => record({
|
|
414
|
+
icon: dispatch((props) => record({
|
|
405
415
|
item: resource('item'),
|
|
406
416
|
nbt: opt(nbt({ registry: 'item', id: extract('item', props) })),
|
|
407
417
|
})),
|
|
@@ -422,7 +432,8 @@ export const advancement = as('advancement', record({
|
|
|
422
432
|
const parts = dissectUri(ctx.doc.uri, ctx);
|
|
423
433
|
const advancement = `${parts?.namespace}:${parts?.identifier}`;
|
|
424
434
|
const criterion = node.value;
|
|
425
|
-
ctx.symbols
|
|
435
|
+
ctx.symbols
|
|
436
|
+
.query(ctx.doc, 'advancement', advancement, criterion)
|
|
426
437
|
.enter({
|
|
427
438
|
data: { subcategory: 'criterion' },
|
|
428
439
|
usage: { type: 'definition', node },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { any, as, boolean, dispatch, float, floatRange, int, intRange, listOf, literal, object, opt, record, resource, when } from '@spyglassmc/json/lib/checker/primitives/index.js';
|
|
1
|
+
import { any, as, boolean, dispatch, float, floatRange, int, intRange, listOf, literal, object, opt, record, resource, when, } from '@spyglassmc/json/lib/checker/primitives/index.js';
|
|
2
2
|
import { intColor, versioned } from '../util/index.js';
|
|
3
|
-
import { block_state, floatProvider, height_provider, vertical_anchor } from './common.js';
|
|
4
|
-
import { configured_feature_list_ref, placed_feature_list_ref } from './feature.js';
|
|
3
|
+
import { block_state, floatProvider, height_provider, vertical_anchor, } from './common.js';
|
|
4
|
+
import { configured_feature_list_ref, placed_feature_list_ref, } from './feature.js';
|
|
5
5
|
import { configured_structure_feature } from './structure.js';
|
|
6
6
|
const BiomeCategory = (ctx) => [
|
|
7
7
|
'beach',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { any, as, dispatch, extract, float, floatRange, int, intRange, listOf, literal, opt, pick, record, ref, resource, simpleString } from '@spyglassmc/json/lib/checker/primitives/index.js';
|
|
1
|
+
import { any, as, dispatch, extract, float, floatRange, int, intRange, listOf, literal, opt, pick, record, ref, resource, simpleString, } from '@spyglassmc/json/lib/checker/primitives/index.js';
|
|
2
2
|
import { blockStateMap } from '../util/index.js';
|
|
3
3
|
function smallestEncompassingPowerOfTwo(n) {
|
|
4
4
|
n = n - 1;
|
|
@@ -17,10 +17,12 @@ export const number_provider = as('range', any([
|
|
|
17
17
|
float,
|
|
18
18
|
dispatch('type', (type) => record({
|
|
19
19
|
type: opt(resource('loot_number_provider_type')),
|
|
20
|
-
...type === undefined
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
...(type === undefined
|
|
21
|
+
? {
|
|
22
|
+
min: number_provider,
|
|
23
|
+
max: number_provider,
|
|
24
|
+
}
|
|
25
|
+
: {}),
|
|
24
26
|
...pick(type, {
|
|
25
27
|
constant: {
|
|
26
28
|
value: float,
|
|
@@ -57,7 +59,7 @@ export const score_provider = any([
|
|
|
57
59
|
]);
|
|
58
60
|
export const nbt_provider = any([
|
|
59
61
|
literal(['this', 'killer', 'killer_player', 'block_entity']),
|
|
60
|
-
dispatch('type', type => record({
|
|
62
|
+
dispatch('type', (type) => record({
|
|
61
63
|
type: resource('loot_nbt_provider_type'),
|
|
62
64
|
...pick(type, {
|
|
63
65
|
context: {
|
|
@@ -95,14 +97,14 @@ export const float_bounds = as('bounds', any([
|
|
|
95
97
|
}),
|
|
96
98
|
]),
|
|
97
99
|
]));
|
|
98
|
-
export const block_state = as('block_state', dispatch(props => record({
|
|
100
|
+
export const block_state = as('block_state', dispatch((props) => record({
|
|
99
101
|
Name: resource('block'),
|
|
100
102
|
Properties: opt(blockStateMap({
|
|
101
103
|
id: extract('Name', props),
|
|
102
104
|
requireAll: true,
|
|
103
105
|
})),
|
|
104
106
|
})));
|
|
105
|
-
export const fluid_state = as('fluid_state', dispatch(props => record({
|
|
107
|
+
export const fluid_state = as('fluid_state', dispatch((props) => record({
|
|
106
108
|
Name: resource('fluid'),
|
|
107
109
|
Properties: opt(blockStateMap({
|
|
108
110
|
id: extract('Name', props),
|
|
@@ -123,7 +125,7 @@ export const vertical_anchor = as('vertical_anchor', any([
|
|
|
123
125
|
]));
|
|
124
126
|
export const height_provider = as('height_provider', any([
|
|
125
127
|
vertical_anchor,
|
|
126
|
-
dispatch('type', type => record({
|
|
128
|
+
dispatch('type', (type) => record({
|
|
127
129
|
type: resource('height_provider_type'),
|
|
128
130
|
...pick(type, {
|
|
129
131
|
constant: {
|
|
@@ -159,7 +161,7 @@ export const height_provider = as('height_provider', any([
|
|
|
159
161
|
]));
|
|
160
162
|
export const floatProvider = (min = undefined, max = undefined) => as('float_provider', any([
|
|
161
163
|
floatRange(min, max),
|
|
162
|
-
dispatch('type', type => record({
|
|
164
|
+
dispatch('type', (type) => record({
|
|
163
165
|
type: resource('float_provider_type'),
|
|
164
166
|
...pick(type, {
|
|
165
167
|
constant: {
|
|
@@ -191,7 +193,7 @@ export const floatProvider = (min = undefined, max = undefined) => as('float_pro
|
|
|
191
193
|
]));
|
|
192
194
|
export const intProvider = (min = undefined, max = undefined) => as('int_provider', any([
|
|
193
195
|
intRange(min, max),
|
|
194
|
-
dispatch('type', type => record({
|
|
196
|
+
dispatch('type', (type) => record({
|
|
195
197
|
type: resource('int_provider_type'),
|
|
196
198
|
...pick(type, {
|
|
197
199
|
constant: {
|
|
@@ -260,20 +262,6 @@ export const HeightmapType = [
|
|
|
260
262
|
'WORLD_SURFACE',
|
|
261
263
|
'WORLD_SURFACE_WG',
|
|
262
264
|
];
|
|
263
|
-
export const Slots = [
|
|
264
|
-
|
|
265
|
-
'offhand',
|
|
266
|
-
'head',
|
|
267
|
-
'chest',
|
|
268
|
-
'legs',
|
|
269
|
-
'feet',
|
|
270
|
-
];
|
|
271
|
-
export const Direction = [
|
|
272
|
-
'up',
|
|
273
|
-
'down',
|
|
274
|
-
'north',
|
|
275
|
-
'east',
|
|
276
|
-
'south',
|
|
277
|
-
'west',
|
|
278
|
-
];
|
|
265
|
+
export const Slots = ['mainhand', 'offhand', 'head', 'chest', 'legs', 'feet'];
|
|
266
|
+
export const Direction = ['up', 'down', 'north', 'east', 'south', 'west'];
|
|
279
267
|
//# sourceMappingURL=common.js.map
|