@spyglassmc/java-edition 0.3.2 → 0.3.4
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 +21 -5
- package/lib/dependency/common.d.ts +1 -5
- package/lib/dependency/common.js +0 -15
- package/lib/dependency/index.d.ts +8 -0
- package/lib/dependency/index.js +23 -1
- package/lib/dependency/mcmeta.d.ts +4 -4
- package/lib/dependency/mcmeta.js +50 -17
- package/lib/index.js +6 -1
- package/lib/json/checker/index.js +2 -1
- package/lib/mcfunction/checker/index.js +5 -6
- package/lib/mcfunction/common/index.d.ts +4 -0
- package/lib/mcfunction/common/index.js +25 -0
- package/lib/mcfunction/completer/argument.js +10 -1
- package/lib/mcfunction/index.js +13 -1
- package/lib/mcfunction/inlayHintProvider.js +2 -1
- package/lib/mcfunction/node/argument.d.ts +5 -5
- package/lib/mcfunction/parser/argument.js +56 -24
- package/lib/mcfunction/signatureHelpProvider.js +3 -1
- package/lib/mcfunction/tree/argument.d.ts +19 -1
- package/lib/mcfunction/tree/patch.js +39 -1
- package/package.json +7 -7
- package/lib/json/checker/data/advancement.d.ts +0 -14
- package/lib/json/checker/data/advancement.js +0 -458
- package/lib/json/checker/data/biome.d.ts +0 -4
- package/lib/json/checker/data/biome.js +0 -148
- package/lib/json/checker/data/common.d.ts +0 -22
- package/lib/json/checker/data/common.js +0 -267
- package/lib/json/checker/data/dimension.d.ts +0 -4
- package/lib/json/checker/data/dimension.js +0 -224
- package/lib/json/checker/data/feature.d.ts +0 -9
- package/lib/json/checker/data/feature.js +0 -744
- package/lib/json/checker/data/index.d.ts +0 -4
- package/lib/json/checker/data/index.js +0 -40
- package/lib/json/checker/data/loot_table.d.ts +0 -8
- package/lib/json/checker/data/loot_table.js +0 -275
- package/lib/json/checker/data/recipe.d.ts +0 -2
- package/lib/json/checker/data/recipe.js +0 -50
- package/lib/json/checker/data/structure.d.ts +0 -8
- package/lib/json/checker/data/structure.js +0 -153
- package/lib/json/checker/data/tag.d.ts +0 -7
- package/lib/json/checker/data/tag.js +0 -35
- package/lib/json/checker/data/text_component.d.ts +0 -2
- package/lib/json/checker/data/text_component.js +0 -148
- package/lib/json/checker/util/advancement.d.ts +0 -3
- package/lib/json/checker/util/advancement.js +0 -16
- package/lib/json/checker/util/block_states.d.ts +0 -13
- package/lib/json/checker/util/block_states.js +0 -63
- package/lib/json/checker/util/color.d.ts +0 -4
- package/lib/json/checker/util/color.js +0 -65
- package/lib/json/checker/util/index.d.ts +0 -8
- package/lib/json/checker/util/index.js +0 -8
- package/lib/json/checker/util/nbt.d.ts +0 -16
- package/lib/json/checker/util/nbt.js +0 -67
- package/lib/json/checker/util/recipe.d.ts +0 -6
- package/lib/json/checker/util/recipe.js +0 -13
- package/lib/json/checker/util/uuid.d.ts +0 -2
- package/lib/json/checker/util/uuid.js +0 -9
- package/lib/json/checker/util/version.d.ts +0 -46
- package/lib/json/checker/util/version.js +0 -48
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" | "
|
|
10
|
+
category: "function" | "advancement" | "chat_type" | "damage_type" | "dimension" | "dimension_type" | "item_modifier" | "loot_table" | "predicate" | "recipe" | "structure" | "trim_material" | "trim_pattern" | "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" | "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";
|
|
11
11
|
namespace: string;
|
|
12
12
|
identifier: string;
|
|
13
13
|
} | undefined;
|
package/lib/binder/index.js
CHANGED
|
@@ -6,7 +6,7 @@ export const Categories = (() => {
|
|
|
6
6
|
'fluid',
|
|
7
7
|
'function',
|
|
8
8
|
'game_event',
|
|
9
|
-
'item',
|
|
9
|
+
'item', // They have the legacy `tags/${plural}` path.
|
|
10
10
|
'worldgen/block_placer_type',
|
|
11
11
|
'worldgen/surface_builder', // They are removed at some point.
|
|
12
12
|
]);
|
|
@@ -85,19 +85,35 @@ export const Categories = (() => {
|
|
|
85
85
|
],
|
|
86
86
|
[
|
|
87
87
|
'worldgen/noise_settings',
|
|
88
|
-
{
|
|
88
|
+
{
|
|
89
|
+
category: 'worldgen/noise_settings',
|
|
90
|
+
extname: '.json',
|
|
91
|
+
since: '1.16',
|
|
92
|
+
},
|
|
89
93
|
],
|
|
90
94
|
[
|
|
91
95
|
'worldgen/placed_feature',
|
|
92
|
-
{
|
|
96
|
+
{
|
|
97
|
+
category: 'worldgen/placed_feature',
|
|
98
|
+
extname: '.json',
|
|
99
|
+
since: '1.18',
|
|
100
|
+
},
|
|
93
101
|
],
|
|
94
102
|
[
|
|
95
103
|
'worldgen/processor_list',
|
|
96
|
-
{
|
|
104
|
+
{
|
|
105
|
+
category: 'worldgen/processor_list',
|
|
106
|
+
extname: '.json',
|
|
107
|
+
since: '1.16',
|
|
108
|
+
},
|
|
97
109
|
],
|
|
98
110
|
[
|
|
99
111
|
'worldgen/template_pool',
|
|
100
|
-
{
|
|
112
|
+
{
|
|
113
|
+
category: 'worldgen/template_pool',
|
|
114
|
+
extname: '.json',
|
|
115
|
+
since: '1.16',
|
|
116
|
+
},
|
|
101
117
|
],
|
|
102
118
|
]);
|
|
103
119
|
for (const registry of TaggableResourceLocationCategories) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type ReleaseVersion = `1.${number}`;
|
|
2
2
|
export declare namespace ReleaseVersion {
|
|
3
3
|
/**
|
|
4
4
|
* @returns
|
|
@@ -14,10 +14,6 @@ export interface VersionInfo {
|
|
|
14
14
|
name: string;
|
|
15
15
|
isLatest: boolean;
|
|
16
16
|
}
|
|
17
|
-
/**
|
|
18
|
-
* A map from `pack_format` numbers to a RegExp. The latest version whose `release_target` matches the RegExp should be used.
|
|
19
|
-
*/
|
|
20
|
-
export declare const PackVersionMap: Record<number, RegExp | undefined>;
|
|
21
17
|
export interface PackMcmeta {
|
|
22
18
|
pack: {
|
|
23
19
|
pack_format: number;
|
package/lib/dependency/common.js
CHANGED
|
@@ -11,18 +11,6 @@ export var ReleaseVersion;
|
|
|
11
11
|
}
|
|
12
12
|
ReleaseVersion.cmp = cmp;
|
|
13
13
|
})(ReleaseVersion || (ReleaseVersion = {}));
|
|
14
|
-
// DOCS: Update here when format_version is changed.
|
|
15
|
-
/**
|
|
16
|
-
* A map from `pack_format` numbers to a RegExp. The latest version whose `release_target` matches the RegExp should be used.
|
|
17
|
-
*/
|
|
18
|
-
export const PackVersionMap = {
|
|
19
|
-
5: /^1\.15.*$/,
|
|
20
|
-
6: /^1\.16.*$/,
|
|
21
|
-
7: /^1\.17.*$/,
|
|
22
|
-
8: /^1\.18(\.1)?$/,
|
|
23
|
-
9: /^1\.18.*$/,
|
|
24
|
-
10: /^1\.19.*$/,
|
|
25
|
-
};
|
|
26
14
|
export var PackMcmeta;
|
|
27
15
|
(function (PackMcmeta) {
|
|
28
16
|
function assert(data) {
|
|
@@ -30,9 +18,6 @@ export var PackMcmeta;
|
|
|
30
18
|
if (!format) {
|
|
31
19
|
throw new Error('“pack.pack_format” undefined');
|
|
32
20
|
}
|
|
33
|
-
if (!Object.keys(PackVersionMap).includes(format)) {
|
|
34
|
-
throw new Error(`Unknown pack_format “${format}”`);
|
|
35
|
-
}
|
|
36
21
|
}
|
|
37
22
|
PackMcmeta.assert = assert;
|
|
38
23
|
})(PackMcmeta || (PackMcmeta = {}));
|
|
@@ -17,6 +17,14 @@ interface GetMcmetaSummaryResult extends Partial<McmetaSummary> {
|
|
|
17
17
|
* @throws Network/file system errors.
|
|
18
18
|
*/
|
|
19
19
|
export declare function getMcmetaSummary(externals: core.Externals, downloader: core.Downloader, logger: core.Logger, version: string, isLatest: boolean, source: string, overridePaths?: core.EnvConfig['mcmetaSummaryOverrides']): Promise<GetMcmetaSummaryResult>;
|
|
20
|
+
/**
|
|
21
|
+
* @throws Network/file system errors.
|
|
22
|
+
*
|
|
23
|
+
* @returns
|
|
24
|
+
* - `startDepth`: The amount of level to skip when unzipping the tarball.
|
|
25
|
+
* - `uri`: URI to the `.tar.gz` file.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getVanillaDatapack(downloader: core.Downloader, version: string, isLatest: boolean): Promise<core.Dependency>;
|
|
20
28
|
/**
|
|
21
29
|
* @throws Network/file system errors.
|
|
22
30
|
*
|
package/lib/dependency/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export * from './common.js';
|
|
|
2
2
|
export * from './mcmeta.js';
|
|
3
3
|
import * as core from '@spyglassmc/core';
|
|
4
4
|
import { Fluids, getMcmetaSummaryUris } from './mcmeta.js';
|
|
5
|
-
const DownloaderTtl =
|
|
5
|
+
const DownloaderTtl = 15_000;
|
|
6
6
|
/* istanbul ignore next */
|
|
7
7
|
/**
|
|
8
8
|
* Return the deserialized [`versions.json`][versions.json].
|
|
@@ -125,6 +125,28 @@ async function downloadGitHubRepo({ defaultBranch, downloader, getTag, repo, isL
|
|
|
125
125
|
return out.cacheUri;
|
|
126
126
|
}
|
|
127
127
|
/* istanbul ignore next */
|
|
128
|
+
/**
|
|
129
|
+
* @throws Network/file system errors.
|
|
130
|
+
*
|
|
131
|
+
* @returns
|
|
132
|
+
* - `startDepth`: The amount of level to skip when unzipping the tarball.
|
|
133
|
+
* - `uri`: URI to the `.tar.gz` file.
|
|
134
|
+
*/
|
|
135
|
+
export async function getVanillaDatapack(downloader, version, isLatest) {
|
|
136
|
+
const uri = await downloadGitHubRepo({
|
|
137
|
+
defaultBranch: 'data',
|
|
138
|
+
downloader,
|
|
139
|
+
getTag: (v) => `${v}-data`,
|
|
140
|
+
owner: 'misode',
|
|
141
|
+
repo: 'mcmeta',
|
|
142
|
+
isLatest,
|
|
143
|
+
version,
|
|
144
|
+
});
|
|
145
|
+
return {
|
|
146
|
+
info: { startDepth: 1 },
|
|
147
|
+
uri,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
128
150
|
/**
|
|
129
151
|
* @throws Network/file system errors.
|
|
130
152
|
*
|
|
@@ -17,7 +17,7 @@ export declare const Fluids: McmetaStates;
|
|
|
17
17
|
export interface McmetaVersion {
|
|
18
18
|
id: string;
|
|
19
19
|
name: string;
|
|
20
|
-
release_target: string;
|
|
20
|
+
release_target: string | undefined;
|
|
21
21
|
type: 'release' | 'snapshot';
|
|
22
22
|
stable: boolean;
|
|
23
23
|
data_version: number;
|
|
@@ -28,7 +28,7 @@ export interface McmetaVersion {
|
|
|
28
28
|
release_time: string;
|
|
29
29
|
sha1: string;
|
|
30
30
|
}
|
|
31
|
-
export
|
|
31
|
+
export type McmetaVersions = McmetaVersion[];
|
|
32
32
|
export interface McmetaSummary {
|
|
33
33
|
blocks: McmetaStates;
|
|
34
34
|
commands: McmetaCommands;
|
|
@@ -45,7 +45,7 @@ export interface McmetaStates {
|
|
|
45
45
|
}
|
|
46
46
|
];
|
|
47
47
|
}
|
|
48
|
-
export
|
|
48
|
+
export type McmetaCommands = RootTreeNode;
|
|
49
49
|
interface BaseTreeNode {
|
|
50
50
|
type: string;
|
|
51
51
|
children?: {
|
|
@@ -70,7 +70,7 @@ export interface RootTreeNode extends BaseTreeNode {
|
|
|
70
70
|
[command: string]: LiteralTreeNode;
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
export
|
|
73
|
+
export type CommandTreeNode = ArgumentTreeNode | LiteralTreeNode | RootTreeNode;
|
|
74
74
|
export interface McmetaRegistries {
|
|
75
75
|
[id: string]: string[];
|
|
76
76
|
}
|
package/lib/dependency/mcmeta.js
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
import * as core from '@spyglassmc/core';
|
|
2
|
-
import { PackVersionMap } from './common.js';
|
|
3
2
|
/**
|
|
4
3
|
* @param inputVersion {@link core.Config.env.gameVersion}
|
|
5
4
|
*/
|
|
6
5
|
export function resolveConfiguredVersion(inputVersion, { packMcmeta, versions, }) {
|
|
7
|
-
function
|
|
8
|
-
if (
|
|
9
|
-
|
|
6
|
+
function findReleaseTarget(version) {
|
|
7
|
+
if (version.release_target) {
|
|
8
|
+
return version.release_target;
|
|
10
9
|
}
|
|
11
|
-
|
|
10
|
+
if (version.type === 'release') {
|
|
11
|
+
return version.id;
|
|
12
|
+
}
|
|
13
|
+
const index = versions.findIndex((v) => v.id === version.id);
|
|
14
|
+
for (let i = index; i >= 0; i -= 1) {
|
|
15
|
+
if (versions[i].type === 'release') {
|
|
16
|
+
return versions[i].id;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// DOCS: Update this when a new snapshot cycle begins
|
|
20
|
+
return '1.21';
|
|
21
|
+
}
|
|
22
|
+
function toVersionInfo(version) {
|
|
23
|
+
version = version ?? versions[0];
|
|
12
24
|
return {
|
|
13
25
|
id: version.id,
|
|
14
26
|
name: version.name,
|
|
15
|
-
release: (version
|
|
16
|
-
isLatest:
|
|
27
|
+
release: findReleaseTarget(version),
|
|
28
|
+
isLatest: version === versions[0],
|
|
17
29
|
};
|
|
18
30
|
}
|
|
19
31
|
if (versions.length === 0) {
|
|
@@ -21,22 +33,40 @@ export function resolveConfiguredVersion(inputVersion, { packMcmeta, versions, }
|
|
|
21
33
|
}
|
|
22
34
|
inputVersion = inputVersion.toLowerCase();
|
|
23
35
|
versions = versions.sort((a, b) => b.data_version - a.data_version);
|
|
36
|
+
const latestRelease = versions.find((v) => v.type === 'release');
|
|
24
37
|
if (inputVersion === 'auto') {
|
|
25
|
-
if (packMcmeta) {
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
return toVersionInfo(versions
|
|
38
|
+
if (packMcmeta && latestRelease) {
|
|
39
|
+
// If the pack format is larger than the latest release, use the latest snapshot
|
|
40
|
+
if (packMcmeta.pack.pack_format > latestRelease.data_pack_version) {
|
|
41
|
+
return toVersionInfo(versions[0]);
|
|
42
|
+
}
|
|
43
|
+
// Look for versions from recent to oldest, picking the most recent release that matches
|
|
44
|
+
let oldestRelease = undefined;
|
|
45
|
+
for (const version of versions) {
|
|
46
|
+
if (version.type === 'release') {
|
|
47
|
+
// If we already passed the pack format, use the oldest release so far
|
|
48
|
+
if (packMcmeta.pack.pack_format > version.data_pack_version) {
|
|
49
|
+
return toVersionInfo(oldestRelease);
|
|
50
|
+
}
|
|
51
|
+
if (packMcmeta.pack.pack_format === version.data_pack_version) {
|
|
52
|
+
return toVersionInfo(version);
|
|
53
|
+
}
|
|
54
|
+
oldestRelease = version;
|
|
55
|
+
}
|
|
29
56
|
}
|
|
57
|
+
// If the pack format is still lower, use the oldest known release version
|
|
58
|
+
return toVersionInfo(oldestRelease);
|
|
30
59
|
}
|
|
31
|
-
|
|
60
|
+
// Fall back to the latest release if pack mcmeta is not available
|
|
61
|
+
return toVersionInfo(latestRelease);
|
|
32
62
|
}
|
|
33
63
|
else if (inputVersion === 'latest release') {
|
|
34
|
-
return toVersionInfo(
|
|
64
|
+
return toVersionInfo(latestRelease);
|
|
35
65
|
}
|
|
36
66
|
else if (inputVersion === 'latest snapshot') {
|
|
37
|
-
return toVersionInfo(versions
|
|
67
|
+
return toVersionInfo(versions[0]);
|
|
38
68
|
}
|
|
39
|
-
return toVersionInfo(versions.
|
|
69
|
+
return toVersionInfo(versions.find((v) => inputVersion === v.id.toLowerCase() ||
|
|
40
70
|
inputVersion === v.name.toLowerCase()));
|
|
41
71
|
}
|
|
42
72
|
const DataSources = {
|
|
@@ -93,7 +123,10 @@ export function symbolRegistrar(summary) {
|
|
|
93
123
|
stateQuery.amend({
|
|
94
124
|
data: {
|
|
95
125
|
relations: {
|
|
96
|
-
default: {
|
|
126
|
+
default: {
|
|
127
|
+
category,
|
|
128
|
+
path: valueQuery.path,
|
|
129
|
+
},
|
|
97
130
|
},
|
|
98
131
|
},
|
|
99
132
|
});
|
|
@@ -143,5 +176,5 @@ export const Fluids = {
|
|
|
143
176
|
lava: [{ falling: ['false', 'true'] }, { falling: 'false' }],
|
|
144
177
|
water: [{ falling: ['false', 'true'] }, { falling: 'false' }],
|
|
145
178
|
};
|
|
146
|
-
|
|
179
|
+
// #endregion
|
|
147
180
|
//# sourceMappingURL=mcmeta.js.map
|
package/lib/index.js
CHANGED
|
@@ -2,6 +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 { getVanillaDatapack } from './dependency/index.js';
|
|
5
6
|
import { getMcmetaSummary, getVanillaMcdoc, getVersions, PackMcmeta, resolveConfiguredVersion, symbolRegistrar, } from './dependency/index.js';
|
|
6
7
|
import * as jeJson from './json/index.js';
|
|
7
8
|
import * as jeMcf from './mcfunction/index.js';
|
|
@@ -33,7 +34,11 @@ export const initialize = async (ctx) => {
|
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
35
36
|
const packMcmeta = await getPackMcmeta();
|
|
36
|
-
const { release, id: version, isLatest, } = resolveConfiguredVersion(config.env.gameVersion, {
|
|
37
|
+
const { release, id: version, isLatest, } = resolveConfiguredVersion(config.env.gameVersion, {
|
|
38
|
+
packMcmeta,
|
|
39
|
+
versions,
|
|
40
|
+
});
|
|
41
|
+
meta.registerDependencyProvider('@vanilla-datapack', () => getVanillaDatapack(downloader, version, isLatest));
|
|
37
42
|
meta.registerDependencyProvider('@vanilla-mcdoc', () => getVanillaMcdoc(downloader));
|
|
38
43
|
const summary = await getMcmetaSummary(ctx.externals, downloader, logger, version, isLatest, config.env.dataSource, config.env.mcmetaSummaryOverrides);
|
|
39
44
|
if (!summary.blocks ||
|
|
@@ -116,7 +116,8 @@ export function object(typeDef) {
|
|
|
116
116
|
export function fieldValue(type) {
|
|
117
117
|
const isInRange = (value, { kind, min = -Infinity, max = Infinity }) => {
|
|
118
118
|
const comparator = (a, b, exclusive) => exclusive ? a < b : a <= b;
|
|
119
|
-
return (comparator(min, value, kind & 0b10) &&
|
|
119
|
+
return (comparator(min, value, kind & 0b10) &&
|
|
120
|
+
comparator(value, max, kind & 0b01));
|
|
120
121
|
};
|
|
121
122
|
const ExpectedTypes = {
|
|
122
123
|
boolean: 'json:boolean',
|
|
@@ -4,7 +4,6 @@ import { localize } from '@spyglassmc/locales';
|
|
|
4
4
|
import * as mcf from '@spyglassmc/mcfunction';
|
|
5
5
|
import * as nbt from '@spyglassmc/nbt';
|
|
6
6
|
import { getTagValues } from '../../common/index.js';
|
|
7
|
-
import { text_component } from '../../json/checker/data/text_component.js';
|
|
8
7
|
import { BlockNode, EntityNode, ItemNode, ParticleNode } from '../node/index.js';
|
|
9
8
|
export const command = (node, ctx) => {
|
|
10
9
|
if (node.slash && node.parent && mcf.McfunctionNode.is(node.parent)) {
|
|
@@ -33,7 +32,7 @@ const rootCommand = (nodes, index, ctx) => {
|
|
|
33
32
|
particle(node, ctx);
|
|
34
33
|
}
|
|
35
34
|
else if (json.JsonNode.is(node)) {
|
|
36
|
-
|
|
35
|
+
// TODO v4.0: check text component
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
if (getName(nodes, index) === 'data') {
|
|
@@ -124,7 +123,7 @@ const rootCommand = (nodes, index, ctx) => {
|
|
|
124
123
|
summonNbt(nodes, index + 1, ctx);
|
|
125
124
|
}
|
|
126
125
|
};
|
|
127
|
-
|
|
126
|
+
// #region Checkers for argument nodes
|
|
128
127
|
const block = (node, ctx) => {
|
|
129
128
|
if (!node.nbt) {
|
|
130
129
|
return;
|
|
@@ -149,8 +148,8 @@ const item = (node, ctx) => {
|
|
|
149
148
|
const particle = (node, ctx) => {
|
|
150
149
|
core.checker.dispatchSync(node, ctx);
|
|
151
150
|
};
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
// #endregion
|
|
152
|
+
// #region Checkers for command argument structure.
|
|
154
153
|
/**
|
|
155
154
|
* - `block <targetPos: block_pos> <nbt: nbt_compound_tag>`
|
|
156
155
|
* - `entity <target: entity> <nbt: nbt_compound_tag>`
|
|
@@ -231,7 +230,7 @@ const summonNbt = (nodes, index, ctx) => {
|
|
|
231
230
|
nbt.checker.index('entity_type', core.ResourceLocationNode.toString(typeNode, 'full'))(nbtNode, ctx);
|
|
232
231
|
}
|
|
233
232
|
};
|
|
234
|
-
|
|
233
|
+
// #endregion
|
|
235
234
|
export const getTypesFromEntity = (entity, ctx) => {
|
|
236
235
|
if (entity.playerName !== undefined || entity.selector?.playersOnly) {
|
|
237
236
|
return ['minecraft:player'];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export declare const ColorArgumentValues: string[];
|
|
2
2
|
export declare const EntityAnchorArgumentValues: string[];
|
|
3
|
+
export declare const GamemodeArgumentValues: string[];
|
|
3
4
|
export declare const ItemSlotArgumentValues: string[];
|
|
4
5
|
export declare const OperationArgumentValues: string[];
|
|
5
6
|
export declare const ScoreboardSlotArgumentValues: string[];
|
|
6
7
|
export declare const SwizzleArgumentValues: string[];
|
|
8
|
+
export declare const HeightmapValues: string[];
|
|
9
|
+
export declare const RotationValues: string[];
|
|
10
|
+
export declare const MirrorValues: string[];
|
|
7
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import * as core from '@spyglassmc/core';
|
|
2
2
|
export const ColorArgumentValues = [...core.Color.ColorNames, 'reset'];
|
|
3
3
|
export const EntityAnchorArgumentValues = ['feet', 'eyes'];
|
|
4
|
+
export const GamemodeArgumentValues = [
|
|
5
|
+
'adventure',
|
|
6
|
+
'survival',
|
|
7
|
+
'creative',
|
|
8
|
+
'spectator',
|
|
9
|
+
];
|
|
4
10
|
export const ItemSlotArgumentValues = [
|
|
5
11
|
...[...Array(54).keys()].map((n) => `container.${n}`),
|
|
6
12
|
...[...Array(27).keys()].map((n) => `enderchest.${n}`),
|
|
@@ -53,4 +59,23 @@ export const SwizzleArgumentValues = [
|
|
|
53
59
|
'zxy',
|
|
54
60
|
'zyx',
|
|
55
61
|
];
|
|
62
|
+
export const HeightmapValues = [
|
|
63
|
+
'motion_blocking',
|
|
64
|
+
'motion_blocking_no_leaves',
|
|
65
|
+
'ocean_floor',
|
|
66
|
+
'ocean_floor_wg',
|
|
67
|
+
'world_surface',
|
|
68
|
+
'world_surface_wg',
|
|
69
|
+
];
|
|
70
|
+
export const RotationValues = [
|
|
71
|
+
'none',
|
|
72
|
+
'clockwise_90',
|
|
73
|
+
'180',
|
|
74
|
+
'counterclockwise_90',
|
|
75
|
+
];
|
|
76
|
+
export const MirrorValues = [
|
|
77
|
+
'none',
|
|
78
|
+
'left_right',
|
|
79
|
+
'front_back',
|
|
80
|
+
];
|
|
56
81
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,7 +2,7 @@ import { AstNode, BooleanNode, BrigadierStringOptions, completer, CompletionItem
|
|
|
2
2
|
import * as json from '@spyglassmc/json';
|
|
3
3
|
import { localeQuote, localize } from '@spyglassmc/locales';
|
|
4
4
|
import { getTagValues } from '../../common/index.js';
|
|
5
|
-
import { ColorArgumentValues, EntityAnchorArgumentValues, ItemSlotArgumentValues, OperationArgumentValues, ScoreboardSlotArgumentValues, SwizzleArgumentValues, } from '../common/index.js';
|
|
5
|
+
import { ColorArgumentValues, EntityAnchorArgumentValues, GamemodeArgumentValues, HeightmapValues, ItemSlotArgumentValues, MirrorValues, OperationArgumentValues, RotationValues, ScoreboardSlotArgumentValues, SwizzleArgumentValues, } from '../common/index.js';
|
|
6
6
|
import { BlockNode, CoordinateNode, EntitySelectorNode, IntRangeNode, ItemNode, ObjectiveCriteriaNode, ParticleNode, ScoreHolderNode, VectorNode, } from '../node/index.js';
|
|
7
7
|
export const getMockNodes = (rawTreeNode, range) => {
|
|
8
8
|
const treeNode = rawTreeNode;
|
|
@@ -45,12 +45,16 @@ export const getMockNodes = (rawTreeNode, range) => {
|
|
|
45
45
|
case 'minecraft:entity':
|
|
46
46
|
case 'minecraft:game_profile':
|
|
47
47
|
return EntitySelectorNode.mock(range);
|
|
48
|
+
case 'minecraft:heightmap':
|
|
49
|
+
return LiteralNode.mock(range, { pool: HeightmapValues });
|
|
48
50
|
case 'minecraft:entity_anchor':
|
|
49
51
|
return LiteralNode.mock(range, { pool: EntityAnchorArgumentValues });
|
|
50
52
|
case 'minecraft:entity_summon':
|
|
51
53
|
return ResourceLocationNode.mock(range, { category: 'entity_type' });
|
|
52
54
|
case 'minecraft:function':
|
|
53
55
|
return ResourceLocationNode.mock(range, { category: 'function' });
|
|
56
|
+
case 'minecraft:gamemode':
|
|
57
|
+
return LiteralNode.mock(range, { pool: GamemodeArgumentValues });
|
|
54
58
|
case 'minecraft:int_range':
|
|
55
59
|
return IntRangeNode.mock(range);
|
|
56
60
|
case 'minecraft:item_enchantment':
|
|
@@ -75,6 +79,7 @@ export const getMockNodes = (rawTreeNode, range) => {
|
|
|
75
79
|
case 'minecraft:particle':
|
|
76
80
|
return ParticleNode.mock(range);
|
|
77
81
|
case 'minecraft:resource':
|
|
82
|
+
case 'minecraft:resource_key':
|
|
78
83
|
case 'minecraft:resource_or_tag':
|
|
79
84
|
return ResourceLocationNode.mock(range, {
|
|
80
85
|
category: ResourceLocation.shorten(treeNode.properties.registry),
|
|
@@ -92,6 +97,10 @@ export const getMockNodes = (rawTreeNode, range) => {
|
|
|
92
97
|
return LiteralNode.mock(range, { pool: SwizzleArgumentValues });
|
|
93
98
|
case 'minecraft:team':
|
|
94
99
|
return SymbolNode.mock(range, { category: 'team' });
|
|
100
|
+
case 'minecraft:template_mirror':
|
|
101
|
+
return LiteralNode.mock(range, { pool: MirrorValues });
|
|
102
|
+
case 'minecraft:template_rotation':
|
|
103
|
+
return LiteralNode.mock(range, { pool: RotationValues });
|
|
95
104
|
case 'minecraft:vec2':
|
|
96
105
|
return VectorNode.mock(range, { dimension: 2, integersOnly: true });
|
|
97
106
|
case 'minecraft:vec3':
|
package/lib/mcfunction/index.js
CHANGED
|
@@ -19,7 +19,19 @@ export const initialize = (ctx, commands, releaseVersion) => {
|
|
|
19
19
|
extensions: ['.mcfunction'],
|
|
20
20
|
parser: mcf.entry(releaseVersion, parser.argument),
|
|
21
21
|
completer: mcf.completer.entry(releaseVersion, completer.getMockNodes),
|
|
22
|
-
triggerCharacters: [
|
|
22
|
+
triggerCharacters: [
|
|
23
|
+
' ',
|
|
24
|
+
'[',
|
|
25
|
+
'=',
|
|
26
|
+
'!',
|
|
27
|
+
',',
|
|
28
|
+
'{',
|
|
29
|
+
':',
|
|
30
|
+
'/',
|
|
31
|
+
'.',
|
|
32
|
+
'"',
|
|
33
|
+
"'",
|
|
34
|
+
],
|
|
23
35
|
});
|
|
24
36
|
meta.registerParser('mcfunction:block_predicate', parser.blockPredicate);
|
|
25
37
|
meta.registerParser('mcfunction:component', parser.component);
|
|
@@ -13,7 +13,8 @@ export const inlayHintProvider = (node, ctx) => {
|
|
|
13
13
|
config.enabledNodes.includes(node.children[0].type))) {
|
|
14
14
|
ans.push({
|
|
15
15
|
offset: node.range.start,
|
|
16
|
-
|
|
16
|
+
label: `${node.path[node.path.length - 1]}:`,
|
|
17
|
+
paddingRight: true,
|
|
17
18
|
});
|
|
18
19
|
}
|
|
19
20
|
});
|
|
@@ -18,7 +18,7 @@ export declare namespace BlockNode {
|
|
|
18
18
|
function mock(range: core.RangeLike, isPredicate: boolean): BlockNode;
|
|
19
19
|
}
|
|
20
20
|
export declare const CoordinateNotations: readonly ["", "~", "^"];
|
|
21
|
-
export
|
|
21
|
+
export type CoordinateNodeNotation = typeof CoordinateNotations[number];
|
|
22
22
|
export interface CoordinateNode extends core.FloatBaseNode {
|
|
23
23
|
type: 'mcfunction:coordinate';
|
|
24
24
|
notation: CoordinateNodeNotation;
|
|
@@ -55,12 +55,12 @@ export declare namespace EntitySelectorArgumentsNode {
|
|
|
55
55
|
function is(node: core.AstNode): node is EntitySelectorArgumentsNode;
|
|
56
56
|
}
|
|
57
57
|
export declare const EntitySelectorVariables: readonly ["a", "e", "p", "r", "s"];
|
|
58
|
-
export
|
|
58
|
+
export type EntitySelectorVariable = typeof EntitySelectorVariables[number];
|
|
59
59
|
export declare namespace EntitySelectorVariable {
|
|
60
60
|
function is(value: string): value is EntitySelectorVariable;
|
|
61
61
|
}
|
|
62
62
|
export declare const EntitySelectorAtVariables: ("@a" | "@e" | "@p" | "@r" | "@s")[];
|
|
63
|
-
export
|
|
63
|
+
export type EntitySelectorAtVariable = typeof EntitySelectorAtVariables[number];
|
|
64
64
|
export declare namespace EntitySelectorAtVariable {
|
|
65
65
|
function is(value: string): value is EntitySelectorAtVariable;
|
|
66
66
|
}
|
|
@@ -78,9 +78,9 @@ export interface EntitySelectorNode extends core.AstNode {
|
|
|
78
78
|
typeLimited?: boolean;
|
|
79
79
|
}
|
|
80
80
|
export declare namespace EntitySelectorNode {
|
|
81
|
-
function is<T extends core.DeepReadonly<core.AstNode> | undefined>(node: T): node is core.
|
|
81
|
+
function is<T extends core.DeepReadonly<core.AstNode> | undefined>(node: T): node is core.InheritReadonly<EntitySelectorNode, T>;
|
|
82
82
|
function mock(range: core.RangeLike): EntitySelectorNode;
|
|
83
|
-
const ArgumentKeys: Set<"predicate" | "tag" | "team" | "type" | "level" | "advancements" | "
|
|
83
|
+
const ArgumentKeys: Set<"predicate" | "tag" | "team" | "type" | "level" | "advancements" | "sort" | "distance" | "gamemode" | "limit" | "name" | "nbt" | "scores" | "x" | "y" | "z" | "dx" | "dy" | "dz" | "x_rotation" | "y_rotation">;
|
|
84
84
|
type ArgumentKey = typeof ArgumentKeys extends Set<infer T> ? T : undefined;
|
|
85
85
|
const enum Result {
|
|
86
86
|
Ok = 0,
|