@spyglassmc/java-edition 0.3.18 → 0.3.20
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 +2 -1
- package/lib/binder/index.js +63 -26
- package/lib/dependency/common.d.ts +10 -0
- package/lib/dependency/common.js +7 -0
- package/lib/dependency/index.d.ts +8 -0
- package/lib/dependency/index.js +23 -2
- package/lib/dependency/mcmeta.d.ts +4 -2
- package/lib/dependency/mcmeta.js +89 -19
- package/lib/index.d.ts +1 -0
- package/lib/index.js +51 -80
- package/lib/mcdocAttributes.d.ts +6 -0
- package/lib/mcdocAttributes.js +89 -0
- package/lib/mcfunction/checker/index.js +12 -15
- package/lib/mcfunction/completer/argument.js +27 -14
- package/lib/mcfunction/mcdocAttributes.js +1 -1
- package/lib/mcfunction/node/argument.d.ts +23 -4
- package/lib/mcfunction/node/argument.js +16 -0
- package/lib/mcfunction/parser/argument.js +92 -22
- package/lib/mcfunction/tree/argument.d.ts +8 -0
- package/lib/mcfunction/tree/patch.js +39 -4
- package/package.json +7 -7
package/lib/binder/index.d.ts
CHANGED
|
@@ -5,8 +5,9 @@ export declare function dissectUri(uri: string, ctx: UriBinderContext): {
|
|
|
5
5
|
identifier: string;
|
|
6
6
|
expected: string | undefined;
|
|
7
7
|
path: string;
|
|
8
|
-
category: "function" | "advancement" | "banner_pattern" | "chat_type" | "damage_type" | "dimension" | "dimension_type" | "enchantment" | "enchantment_provider" | "instrument" | "item_modifier" | "jukebox_song" | "loot_table" | "painting_variant" | "predicate" | "recipe" | "structure" | "trial_spawner" | "trim_material" | "trim_pattern" | "wolf_variant" | "tag/function" | "tag/activity" | "tag/armor_material" | "tag/attribute" | "tag/block" | "tag/block_entity_type" | "tag/block_predicate_type" | "tag/block_type" | "tag/cat_variant" | "tag/chunk_status" | "tag/command_argument_type" | "tag/creative_mode_tab" | "tag/custom_stat" | "tag/data_component_type" | "tag/decorated_pot_pattern" | "tag/enchantment_effect_component_type" | "tag/enchantment_entity_effect_type" | "tag/enchantment_level_based_value_type" | "tag/enchantment_location_based_effect_type" | "tag/enchantment_provider_type" | "tag/enchantment_value_effect_type" | "tag/entity_sub_predicate_type" | "tag/entity_type" | "tag/float_provider_type" | "tag/fluid" | "tag/frog_variant" | "tag/game_event" | "tag/height_provider_type" | "tag/instrument" | "tag/int_provider_type" | "tag/item" | "tag/item_sub_predicate_type" | "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/map_decoration_type" | "tag/memory_module_type" | "tag/menu" | "tag/mob_effect" | "tag/motive" | "tag/number_format_type" | "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_block_entity_modifier" | "tag/rule_test" | "tag/schedule" | "tag/sensor_type" | "tag/sound_event" | "tag/stat_type" | "tag/trigger_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/density_function_type" | "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/pool_alias_binding" | "tag/worldgen/root_placer_type" | "tag/worldgen/structure_feature" | "tag/worldgen/structure_piece" | "tag/worldgen/structure_placement" | "tag/worldgen/structure_pool_element" | "tag/worldgen/structure_processor" | "tag/worldgen/structure_type" | "tag/worldgen/surface_builder" | "tag/worldgen/tree_decorator_type" | "tag/worldgen/trunk_placer_type" | "tag/advancement" | "tag/banner_pattern" | "tag/chat_type" | "tag/damage_type" | "tag/dimension" | "tag/dimension_type" | "tag/enchantment" | "tag/enchantment_provider" | "tag/item_modifier" | "tag/jukebox_song" | "tag/loot_table" | "tag/painting_variant" | "tag/predicate" | "tag/recipe" | "tag/structure" | "tag/trial_spawner" | "tag/trim_material" | "tag/trim_pattern" | "tag/wolf_variant" | "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/flat_level_generator_preset" | "tag/worldgen/multi_noise_biome_source_parameter_list" | "tag/worldgen/noise" | "tag/worldgen/noise_settings" | "tag/worldgen/placed_feature" | "tag/worldgen/processor_list" | "tag/worldgen/structure" | "tag/worldgen/structure_set" | "tag/worldgen/template_pool" | "tag/worldgen/world_preset" | "worldgen/biome" | "worldgen/configured_carver" | "worldgen/configured_feature" | "worldgen/configured_structure_feature" | "worldgen/configured_surface_builder" | "worldgen/density_function" | "worldgen/flat_level_generator_preset" | "worldgen/multi_noise_biome_source_parameter_list" | "worldgen/noise" | "worldgen/noise_settings" | "worldgen/placed_feature" | "worldgen/processor_list" | "worldgen/structure" | "worldgen/structure_set" | "worldgen/template_pool" | "worldgen/world_preset";
|
|
8
|
+
category: "function" | "advancement" | "banner_pattern" | "chat_type" | "damage_type" | "dimension" | "dimension_type" | "enchantment" | "enchantment_provider" | "instrument" | "item_modifier" | "jukebox_song" | "loot_table" | "painting_variant" | "predicate" | "recipe" | "structure" | "trial_spawner" | "trim_material" | "trim_pattern" | "wolf_variant" | "tag/function" | "tag/activity" | "tag/armor_material" | "tag/attribute" | "tag/block" | "tag/block_entity_type" | "tag/block_predicate_type" | "tag/block_type" | "tag/cat_variant" | "tag/chunk_status" | "tag/command_argument_type" | "tag/consume_effect_type" | "tag/creative_mode_tab" | "tag/custom_stat" | "tag/data_component_type" | "tag/decorated_pot_pattern" | "tag/decorated_pot_patterns" | "tag/enchantment_effect_component_type" | "tag/enchantment_entity_effect_type" | "tag/enchantment_level_based_value_type" | "tag/enchantment_location_based_effect_type" | "tag/enchantment_provider_type" | "tag/enchantment_value_effect_type" | "tag/entity_sub_predicate_type" | "tag/entity_type" | "tag/float_provider_type" | "tag/fluid" | "tag/frog_variant" | "tag/game_event" | "tag/height_provider_type" | "tag/instrument" | "tag/int_provider_type" | "tag/item" | "tag/item_sub_predicate_type" | "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/map_decoration_type" | "tag/memory_module_type" | "tag/menu" | "tag/mob_effect" | "tag/motive" | "tag/number_format_type" | "tag/particle_type" | "tag/point_of_interest_type" | "tag/pos_rule_test" | "tag/position_source_type" | "tag/potion" | "tag/recipe_book_category" | "tag/recipe_display" | "tag/recipe_serializer" | "tag/recipe_type" | "tag/rule_block_entity_modifier" | "tag/rule_test" | "tag/schedule" | "tag/sensor_type" | "tag/slot_display" | "tag/sound_event" | "tag/stat_type" | "tag/trigger_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/density_function_type" | "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/pool_alias_binding" | "tag/worldgen/root_placer_type" | "tag/worldgen/structure_feature" | "tag/worldgen/structure_piece" | "tag/worldgen/structure_placement" | "tag/worldgen/structure_pool_element" | "tag/worldgen/structure_processor" | "tag/worldgen/structure_type" | "tag/worldgen/surface_builder" | "tag/worldgen/tree_decorator_type" | "tag/worldgen/trunk_placer_type" | "tag/advancement" | "tag/banner_pattern" | "tag/chat_type" | "tag/damage_type" | "tag/dimension" | "tag/dimension_type" | "tag/enchantment" | "tag/enchantment_provider" | "tag/item_modifier" | "tag/jukebox_song" | "tag/loot_table" | "tag/painting_variant" | "tag/predicate" | "tag/recipe" | "tag/structure" | "tag/trial_spawner" | "tag/trim_material" | "tag/trim_pattern" | "tag/wolf_variant" | "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/flat_level_generator_preset" | "tag/worldgen/multi_noise_biome_source_parameter_list" | "tag/worldgen/noise" | "tag/worldgen/noise_settings" | "tag/worldgen/placed_feature" | "tag/worldgen/processor_list" | "tag/worldgen/structure" | "tag/worldgen/structure_set" | "tag/worldgen/template_pool" | "tag/worldgen/world_preset" | "worldgen/biome" | "worldgen/configured_carver" | "worldgen/configured_feature" | "worldgen/configured_structure_feature" | "worldgen/configured_surface_builder" | "worldgen/density_function" | "worldgen/flat_level_generator_preset" | "worldgen/multi_noise_biome_source_parameter_list" | "worldgen/noise" | "worldgen/noise_settings" | "worldgen/placed_feature" | "worldgen/processor_list" | "worldgen/structure" | "worldgen/structure_set" | "worldgen/template_pool" | "worldgen/world_preset" | "atlas" | "block_definition" | "equipment" | "font" | "font/ttf" | "font/otf" | "font/unihex" | "item_definition" | "lang" | "model" | "particle" | "post_effect" | "shader" | "shader/fragment" | "shader/vertex" | "sound" | "texture";
|
|
9
9
|
ext: `.${string}`;
|
|
10
|
+
pack: "assets" | "data";
|
|
10
11
|
since?: `1.${number}` | undefined;
|
|
11
12
|
until?: `1.${number}` | undefined;
|
|
12
13
|
ok: boolean;
|
package/lib/binder/index.js
CHANGED
|
@@ -3,12 +3,17 @@ import { localeQuote, localize } from '@spyglassmc/locales';
|
|
|
3
3
|
import { ReleaseVersion } from '../dependency/index.js';
|
|
4
4
|
const Resources = new Map();
|
|
5
5
|
function resource(path, resource = {}) {
|
|
6
|
-
Resources.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const previous = Resources.get(path) ?? [];
|
|
7
|
+
Resources.set(path, [
|
|
8
|
+
...previous,
|
|
9
|
+
{
|
|
10
|
+
path,
|
|
11
|
+
category: resource.category ?? path,
|
|
12
|
+
ext: resource.ext ?? '.json',
|
|
13
|
+
pack: resource.pack ?? 'data',
|
|
14
|
+
...resource,
|
|
15
|
+
},
|
|
16
|
+
]);
|
|
12
17
|
}
|
|
13
18
|
// Pre-1.21 data pack plurals
|
|
14
19
|
resource('advancements', { category: 'advancement', until: '1.21' });
|
|
@@ -88,11 +93,36 @@ for (const registry of TaggableResourceLocationCategories) {
|
|
|
88
93
|
}
|
|
89
94
|
resource(`tags/${registry}`, { category: `tag/${registry}`, since: '1.18' });
|
|
90
95
|
}
|
|
96
|
+
// Resource pack
|
|
97
|
+
resource('atlases', { pack: 'assets', category: 'atlas', since: '1.19.3' });
|
|
98
|
+
resource('blockstates', { pack: 'assets', category: 'block_definition' });
|
|
99
|
+
resource('equipment', { pack: 'assets', category: 'equipment', since: '1.21.4' });
|
|
100
|
+
resource('font', { pack: 'assets', category: 'font', since: '1.16' });
|
|
101
|
+
resource('font', { pack: 'assets', category: 'font/ttf', since: '1.16', ext: '.ttf' });
|
|
102
|
+
resource('font', { pack: 'assets', category: 'font/otf', since: '1.16', ext: '.otf' });
|
|
103
|
+
resource('font', { pack: 'assets', category: 'font/unihex', since: '1.20', ext: '.zip' });
|
|
104
|
+
resource('items', { pack: 'assets', category: 'item_definition', since: '1.21.4' });
|
|
105
|
+
resource('lang', { pack: 'assets', category: 'lang' });
|
|
106
|
+
resource('models', { pack: 'assets', category: 'model' });
|
|
107
|
+
resource('models/equipment', {
|
|
108
|
+
pack: 'assets',
|
|
109
|
+
category: 'equipment',
|
|
110
|
+
since: '1.21.2',
|
|
111
|
+
until: '1.21.4',
|
|
112
|
+
});
|
|
113
|
+
resource('particles', { pack: 'assets', category: 'particle' });
|
|
114
|
+
resource('post_effect', { pack: 'assets', since: '1.21.2' });
|
|
115
|
+
resource('shaders/post', { pack: 'assets', category: 'post_effect', until: '1.21.2' });
|
|
116
|
+
resource('shaders', { pack: 'assets', category: 'shader' });
|
|
117
|
+
resource('shaders', { pack: 'assets', category: 'shader/fragment', ext: '.fsh' });
|
|
118
|
+
resource('shaders', { pack: 'assets', category: 'shader/vertex', ext: '.vsh' });
|
|
119
|
+
resource('sounds', { pack: 'assets', category: 'sound', ext: '.ogg' });
|
|
120
|
+
resource('textures', { pack: 'assets', category: 'texture', ext: '.png' });
|
|
91
121
|
export function* getRels(uri, rootUris) {
|
|
92
122
|
yield* fileUtil.getRels(uri, rootUris);
|
|
93
123
|
const parts = uri.split('/');
|
|
94
124
|
for (let i = parts.length - 2; i >= 0; i--) {
|
|
95
|
-
if (parts[i] === 'data'
|
|
125
|
+
if (parts[i] === 'data' || parts[i] === 'assets') {
|
|
96
126
|
yield parts.slice(i).join('/');
|
|
97
127
|
}
|
|
98
128
|
}
|
|
@@ -110,30 +140,38 @@ export function dissectUri(uri, ctx) {
|
|
|
110
140
|
continue;
|
|
111
141
|
}
|
|
112
142
|
const [pack, namespace, ...rest] = parts;
|
|
113
|
-
if (pack !== 'data') {
|
|
114
|
-
continue;
|
|
143
|
+
if (pack !== 'data' && pack !== 'assets') {
|
|
144
|
+
continue;
|
|
115
145
|
}
|
|
116
|
-
|
|
117
|
-
let matchIndex = 0;
|
|
146
|
+
const candidateResources = [];
|
|
118
147
|
for (let i = 1; i < rest.length; i += 1) {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
148
|
+
const resources = Resources.get(rest.slice(0, i).join('/'));
|
|
149
|
+
for (const res of resources ?? []) {
|
|
150
|
+
if (res.pack !== pack) {
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
let identifier = rest.slice(i).join('/');
|
|
154
|
+
if (!identifier.endsWith(res.ext)) {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
identifier = identifier.slice(0, -res.ext.length);
|
|
158
|
+
candidateResources.push([res, identifier]);
|
|
123
159
|
}
|
|
124
160
|
}
|
|
125
|
-
if (
|
|
161
|
+
if (candidateResources.length === 0) {
|
|
126
162
|
continue;
|
|
127
163
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
164
|
+
// Finding the last, because that will be the deepest match
|
|
165
|
+
let res = candidateResources.findLast(([res]) => matchVersion(release, res.since, res.until));
|
|
166
|
+
if (res !== undefined) {
|
|
167
|
+
return { ok: true, ...res[0], namespace, identifier: res[1], expected: undefined };
|
|
131
168
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
169
|
+
// Try to find the expected path that matches the current version
|
|
170
|
+
res = candidateResources[candidateResources.length - 1];
|
|
171
|
+
let expected = undefined;
|
|
172
|
+
for (const [path, others] of Resources) {
|
|
173
|
+
for (const other of others) {
|
|
174
|
+
if (other.category !== res[0].category) {
|
|
137
175
|
continue;
|
|
138
176
|
}
|
|
139
177
|
if (matchVersion(release, other.since, other.until)) {
|
|
@@ -141,9 +179,8 @@ export function dissectUri(uri, ctx) {
|
|
|
141
179
|
break;
|
|
142
180
|
}
|
|
143
181
|
}
|
|
144
|
-
return { ok: false, ...resource, namespace, identifier, expected };
|
|
145
182
|
}
|
|
146
|
-
return { ok:
|
|
183
|
+
return { ok: false, ...res[0], namespace, identifier: res[1], expected };
|
|
147
184
|
}
|
|
148
185
|
return undefined;
|
|
149
186
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type * as core from '@spyglassmc/core';
|
|
1
2
|
export type ReleaseVersion = `1.${number}`;
|
|
2
3
|
export declare namespace ReleaseVersion {
|
|
3
4
|
/**
|
|
@@ -13,11 +14,13 @@ export declare namespace ReleaseVersion {
|
|
|
13
14
|
*/
|
|
14
15
|
function isBetween(version: ReleaseVersion, since: ReleaseVersion, until: ReleaseVersion): boolean;
|
|
15
16
|
}
|
|
17
|
+
export type VersionInfoReason = 'auto' | 'config' | 'fallback';
|
|
16
18
|
export interface VersionInfo {
|
|
17
19
|
release: ReleaseVersion;
|
|
18
20
|
id: string;
|
|
19
21
|
name: string;
|
|
20
22
|
isLatest: boolean;
|
|
23
|
+
reason: VersionInfoReason;
|
|
21
24
|
}
|
|
22
25
|
export interface PackMcmeta {
|
|
23
26
|
pack: {
|
|
@@ -26,5 +29,12 @@ export interface PackMcmeta {
|
|
|
26
29
|
}
|
|
27
30
|
export declare namespace PackMcmeta {
|
|
28
31
|
function assert(data: any): asserts data is PackMcmeta;
|
|
32
|
+
function getType(packRoot: string, externals: core.Externals): Promise<"assets" | "data">;
|
|
33
|
+
}
|
|
34
|
+
export interface PackInfo {
|
|
35
|
+
type: 'data' | 'assets';
|
|
36
|
+
packRoot: string;
|
|
37
|
+
packMcmeta: PackMcmeta | undefined;
|
|
38
|
+
versionInfo: VersionInfo;
|
|
29
39
|
}
|
|
30
40
|
//# sourceMappingURL=common.d.ts.map
|
package/lib/dependency/common.js
CHANGED
|
@@ -28,5 +28,12 @@ export var PackMcmeta;
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
PackMcmeta.assert = assert;
|
|
31
|
+
async function getType(packRoot, externals) {
|
|
32
|
+
const dir = await externals.fs.readdir(packRoot);
|
|
33
|
+
const isResourcePack = dir.some(e => e.isDirectory() && e.name === 'assets')
|
|
34
|
+
&& !dir.some(e => e.isDirectory() && e.name === 'data');
|
|
35
|
+
return isResourcePack ? 'assets' : 'data';
|
|
36
|
+
}
|
|
37
|
+
PackMcmeta.getType = getType;
|
|
31
38
|
})(PackMcmeta || (PackMcmeta = {}));
|
|
32
39
|
//# sourceMappingURL=common.js.map
|
|
@@ -25,6 +25,14 @@ export declare function getMcmetaSummary(externals: core.Externals, downloader:
|
|
|
25
25
|
* - `uri`: URI to the `.tar.gz` file.
|
|
26
26
|
*/
|
|
27
27
|
export declare function getVanillaDatapack(downloader: core.Downloader, version: string, isLatest: boolean): Promise<core.Dependency>;
|
|
28
|
+
/**
|
|
29
|
+
* @throws Network/file system errors.
|
|
30
|
+
*
|
|
31
|
+
* @returns
|
|
32
|
+
* - `startDepth`: The amount of level to skip when unzipping the tarball.
|
|
33
|
+
* - `uri`: URI to the `.tar.gz` file.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getVanillaResourcepack(downloader: core.Downloader, version: string, isLatest: boolean): Promise<core.Dependency>;
|
|
28
36
|
/**
|
|
29
37
|
* @throws Network/file system errors.
|
|
30
38
|
*
|
package/lib/dependency/index.js
CHANGED
|
@@ -107,11 +107,11 @@ function getCacheOptionsBasedOnGitHubCommitSha(owner, repo, ref) {
|
|
|
107
107
|
*
|
|
108
108
|
* @returns The URI to the `.tar.gz` file.
|
|
109
109
|
*/
|
|
110
|
-
async function downloadGitHubRepo({ defaultBranch, downloader, getTag, repo, isLatest, owner, version }) {
|
|
110
|
+
async function downloadGitHubRepo({ defaultBranch, downloader, getTag, repo, isLatest, owner, version, suffix }) {
|
|
111
111
|
const ref = getGitRef({ defaultBranch, getTag, isLatest, version });
|
|
112
112
|
const out = {};
|
|
113
113
|
await downloader.download({
|
|
114
|
-
id: `mc-je/${version}/${repo}.tar.gz`,
|
|
114
|
+
id: `mc-je/${version}/${repo}${suffix ?? ''}.tar.gz`,
|
|
115
115
|
uri: `https://api.github.com/repos/${owner}/${repo}/tarball/${ref}`,
|
|
116
116
|
transformer: (b) => b,
|
|
117
117
|
cache: getCacheOptionsBasedOnGitHubCommitSha(owner, repo, ref),
|
|
@@ -140,6 +140,27 @@ export async function getVanillaDatapack(downloader, version, isLatest) {
|
|
|
140
140
|
});
|
|
141
141
|
return { info: { startDepth: 1 }, uri };
|
|
142
142
|
}
|
|
143
|
+
/* istanbul ignore next */
|
|
144
|
+
/**
|
|
145
|
+
* @throws Network/file system errors.
|
|
146
|
+
*
|
|
147
|
+
* @returns
|
|
148
|
+
* - `startDepth`: The amount of level to skip when unzipping the tarball.
|
|
149
|
+
* - `uri`: URI to the `.tar.gz` file.
|
|
150
|
+
*/
|
|
151
|
+
export async function getVanillaResourcepack(downloader, version, isLatest) {
|
|
152
|
+
const uri = await downloadGitHubRepo({
|
|
153
|
+
defaultBranch: 'assets-tiny',
|
|
154
|
+
downloader,
|
|
155
|
+
getTag: (v) => `${v}-assets-tiny`,
|
|
156
|
+
owner: 'misode',
|
|
157
|
+
repo: 'mcmeta',
|
|
158
|
+
isLatest,
|
|
159
|
+
version,
|
|
160
|
+
suffix: '-assets',
|
|
161
|
+
});
|
|
162
|
+
return { info: { startDepth: 1 }, uri };
|
|
163
|
+
}
|
|
143
164
|
/**
|
|
144
165
|
* @throws Network/file system errors.
|
|
145
166
|
*
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import * as core from '@spyglassmc/core';
|
|
2
2
|
import type { PackMcmeta, VersionInfo } from './common.js';
|
|
3
|
+
import { ReleaseVersion } from './common.js';
|
|
4
|
+
export declare const NEXT_RELEASE_VERSION = "1.21.4";
|
|
3
5
|
/**
|
|
4
6
|
* @param inputVersion {@link core.Config.env.gameVersion}
|
|
5
7
|
*/
|
|
6
|
-
export declare function resolveConfiguredVersion(inputVersion: string, versions: McmetaVersions,
|
|
8
|
+
export declare function resolveConfiguredVersion(inputVersion: string, versions: McmetaVersions, packMcmeta: PackMcmeta | undefined, packType: 'assets' | 'data' | undefined, logger: core.Logger): VersionInfo;
|
|
7
9
|
export declare function getMcmetaSummaryUris(version: string, isLatest: boolean, source: string): {
|
|
8
10
|
blocks: core.RemoteUriString;
|
|
9
11
|
commands: core.RemoteUriString;
|
|
10
12
|
registries: core.RemoteUriString;
|
|
11
13
|
};
|
|
12
|
-
export declare function symbolRegistrar(summary: McmetaSummary): core.SymbolRegistrar;
|
|
14
|
+
export declare function symbolRegistrar(summary: McmetaSummary, release: ReleaseVersion): core.SymbolRegistrar;
|
|
13
15
|
export declare const Fluids: McmetaStates;
|
|
14
16
|
export interface McmetaVersion {
|
|
15
17
|
id: string;
|
package/lib/dependency/mcmeta.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import * as core from '@spyglassmc/core';
|
|
2
|
+
import { ReleaseVersion } from './common.js';
|
|
3
|
+
// DOCS: Update this when a new snapshot cycle begins
|
|
4
|
+
export const NEXT_RELEASE_VERSION = '1.21.4';
|
|
2
5
|
/**
|
|
3
6
|
* @param inputVersion {@link core.Config.env.gameVersion}
|
|
4
7
|
*/
|
|
5
|
-
export
|
|
8
|
+
export function resolveConfiguredVersion(inputVersion, versions, packMcmeta, packType, logger) {
|
|
6
9
|
function findReleaseTarget(version) {
|
|
7
10
|
if (version.release_target) {
|
|
8
11
|
return version.release_target;
|
|
@@ -16,58 +19,70 @@ export async function resolveConfiguredVersion(inputVersion, versions, getPackMc
|
|
|
16
19
|
return versions[i].id;
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
|
-
|
|
20
|
-
return '1.21.4';
|
|
22
|
+
return NEXT_RELEASE_VERSION;
|
|
21
23
|
}
|
|
22
|
-
function toVersionInfo(version) {
|
|
24
|
+
function toVersionInfo(version, reason) {
|
|
23
25
|
version = version ?? versions[0];
|
|
24
26
|
return {
|
|
25
27
|
id: version.id,
|
|
26
28
|
name: version.name,
|
|
27
29
|
release: findReleaseTarget(version),
|
|
28
30
|
isLatest: version === versions[0],
|
|
31
|
+
reason,
|
|
29
32
|
};
|
|
30
33
|
}
|
|
31
34
|
if (versions.length === 0) {
|
|
32
35
|
throw new Error('mcmeta version list is empty');
|
|
33
36
|
}
|
|
37
|
+
// This should never happen, but for some reason happens sometimes
|
|
38
|
+
// https://github.com/SpyglassMC/Spyglass/issues/1621
|
|
39
|
+
if (inputVersion === undefined) {
|
|
40
|
+
logger.warn('[resolveConfiguredVersion] Input version was undefined! Falling back to "auto"');
|
|
41
|
+
inputVersion = 'auto';
|
|
42
|
+
}
|
|
34
43
|
inputVersion = inputVersion.toLowerCase();
|
|
35
44
|
versions = versions.sort((a, b) => b.data_version - a.data_version);
|
|
36
45
|
const latestRelease = versions.find((v) => v.type === 'release');
|
|
37
46
|
if (inputVersion === 'auto') {
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
47
|
+
const packFormat = packMcmeta?.pack.pack_format;
|
|
48
|
+
if (packFormat && latestRelease) {
|
|
40
49
|
// If the pack format is larger than the latest release, use the latest snapshot
|
|
41
|
-
if (
|
|
42
|
-
|
|
50
|
+
if (packFormat > (packType === 'assets'
|
|
51
|
+
? latestRelease.resource_pack_version
|
|
52
|
+
: latestRelease.data_pack_version)) {
|
|
53
|
+
return toVersionInfo(versions[0], 'auto');
|
|
43
54
|
}
|
|
44
55
|
// Look for versions from recent to oldest, picking the most recent release that matches
|
|
45
56
|
let oldestRelease = undefined;
|
|
46
57
|
for (const version of versions) {
|
|
47
58
|
if (version.type === 'release') {
|
|
48
59
|
// If we already passed the pack format, use the oldest release so far
|
|
49
|
-
if (
|
|
50
|
-
|
|
60
|
+
if (packFormat > (packType === 'assets'
|
|
61
|
+
? version.resource_pack_version
|
|
62
|
+
: version.data_pack_version)) {
|
|
63
|
+
return toVersionInfo(oldestRelease, 'auto');
|
|
51
64
|
}
|
|
52
|
-
if (
|
|
53
|
-
|
|
65
|
+
if (packFormat === (packType === 'assets'
|
|
66
|
+
? version.resource_pack_version
|
|
67
|
+
: version.data_pack_version)) {
|
|
68
|
+
return toVersionInfo(version, 'auto');
|
|
54
69
|
}
|
|
55
70
|
oldestRelease = version;
|
|
56
71
|
}
|
|
57
72
|
}
|
|
58
73
|
// If the pack format is still lower, use the oldest known release version
|
|
59
|
-
return toVersionInfo(oldestRelease);
|
|
74
|
+
return toVersionInfo(oldestRelease, 'auto');
|
|
60
75
|
}
|
|
61
76
|
// Fall back to the latest release if pack mcmeta is not available
|
|
62
|
-
return toVersionInfo(latestRelease);
|
|
77
|
+
return toVersionInfo(latestRelease, 'fallback');
|
|
63
78
|
}
|
|
64
79
|
else if (inputVersion === 'latest release') {
|
|
65
|
-
return toVersionInfo(latestRelease);
|
|
80
|
+
return toVersionInfo(latestRelease, 'config');
|
|
66
81
|
}
|
|
67
82
|
else if (inputVersion === 'latest snapshot') {
|
|
68
|
-
return toVersionInfo(versions[0]);
|
|
83
|
+
return toVersionInfo(versions[0], 'config');
|
|
69
84
|
}
|
|
70
|
-
return toVersionInfo(versions.find((v) => inputVersion === v.id.toLowerCase() || inputVersion === v.name.toLowerCase()));
|
|
85
|
+
return toVersionInfo(versions.find((v) => inputVersion === v.id.toLowerCase() || inputVersion === v.name.toLowerCase()), 'config');
|
|
71
86
|
}
|
|
72
87
|
const DataSources = {
|
|
73
88
|
fastly: 'https://fastly.jsdelivr.net/gh/${user}/${repo}@${tag}/${path}',
|
|
@@ -90,7 +105,7 @@ export function getMcmetaSummaryUris(version, isLatest, source) {
|
|
|
90
105
|
registries: getUri('registries/data.json.gz'),
|
|
91
106
|
};
|
|
92
107
|
}
|
|
93
|
-
export function symbolRegistrar(summary) {
|
|
108
|
+
export function symbolRegistrar(summary, release) {
|
|
94
109
|
const McmetaSummaryUri = 'mcmeta://summary/registries.json';
|
|
95
110
|
/**
|
|
96
111
|
* Add states of blocks or fluids to the symbol table.
|
|
@@ -121,6 +136,55 @@ export function symbolRegistrar(summary) {
|
|
|
121
136
|
});
|
|
122
137
|
});
|
|
123
138
|
}
|
|
139
|
+
const stateTypes = { block: summary.blocks, fluid: summary.fluids };
|
|
140
|
+
for (const [type, states] of Object.entries(stateTypes)) {
|
|
141
|
+
symbols.query(McmetaSummaryUri, 'mcdoc/dispatcher', `mcdoc:${type}_states`)
|
|
142
|
+
.enter({ usage: { type: 'declaration' } })
|
|
143
|
+
.onEach(Object.entries(states), ([id, [properties]], query) => {
|
|
144
|
+
const data = {
|
|
145
|
+
typeDef: {
|
|
146
|
+
kind: 'struct',
|
|
147
|
+
fields: Object.entries(properties).map(([propKey, propValues]) => ({
|
|
148
|
+
kind: 'pair',
|
|
149
|
+
key: propKey,
|
|
150
|
+
optional: true,
|
|
151
|
+
type: {
|
|
152
|
+
kind: 'union',
|
|
153
|
+
members: propValues.map(value => ({
|
|
154
|
+
kind: 'literal',
|
|
155
|
+
value: { kind: 'string', value },
|
|
156
|
+
})),
|
|
157
|
+
},
|
|
158
|
+
})),
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
query.member(id, (stateQuery) => {
|
|
162
|
+
stateQuery.enter({
|
|
163
|
+
data: { data },
|
|
164
|
+
usage: { type: 'declaration' },
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
symbols.query(McmetaSummaryUri, 'mcdoc/dispatcher', `mcdoc:${type}_state_keys`)
|
|
169
|
+
.enter({ usage: { type: 'declaration' } })
|
|
170
|
+
.onEach(Object.entries(states), ([id, [properties]], query) => {
|
|
171
|
+
const data = {
|
|
172
|
+
typeDef: {
|
|
173
|
+
kind: 'union',
|
|
174
|
+
members: Object.keys(properties).map(propKey => ({
|
|
175
|
+
kind: 'literal',
|
|
176
|
+
value: { kind: 'string', value: propKey },
|
|
177
|
+
})),
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
query.member(id, (stateQuery) => {
|
|
181
|
+
stateQuery.enter({
|
|
182
|
+
data: { data },
|
|
183
|
+
usage: { type: 'declaration' },
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
}
|
|
124
188
|
}
|
|
125
189
|
function addRegistriesSymbols(registries, symbols) {
|
|
126
190
|
function isCategory(str) {
|
|
@@ -137,7 +201,13 @@ export function symbolRegistrar(summary) {
|
|
|
137
201
|
}
|
|
138
202
|
}
|
|
139
203
|
function addBuiltinSymbols(symbols) {
|
|
140
|
-
|
|
204
|
+
if (ReleaseVersion.cmp(release, '1.21.2') < 0) {
|
|
205
|
+
symbols.query(McmetaSummaryUri, 'loot_table', 'minecraft:empty')
|
|
206
|
+
.enter({ usage: { type: 'declaration' } });
|
|
207
|
+
}
|
|
208
|
+
symbols.query(McmetaSummaryUri, 'model', 'minecraft:builtin/generated')
|
|
209
|
+
.enter({ usage: { type: 'declaration' } });
|
|
210
|
+
symbols.query(McmetaSummaryUri, 'model', 'minecraft:builtin/entity')
|
|
141
211
|
.enter({ usage: { type: 'declaration' } });
|
|
142
212
|
}
|
|
143
213
|
return (symbols) => {
|
package/lib/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as core from '@spyglassmc/core';
|
|
|
2
2
|
export * as binder from './binder/index.js';
|
|
3
3
|
export * as dependency from './dependency/index.js';
|
|
4
4
|
export * as json from './json/index.js';
|
|
5
|
+
export * from './mcdocAttributes.js';
|
|
5
6
|
export * as mcf from './mcfunction/index.js';
|
|
6
7
|
export declare const initialize: core.ProjectInitializer;
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|