@spyglassmc/java-edition 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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" | "worldgen/biome" | "worldgen/configured_carver" | "worldgen/configured_feature" | "worldgen/configured_structure_feature" | "worldgen/configured_surface_builder" | "worldgen/noise" | "worldgen/noise_settings" | "worldgen/placed_feature" | "worldgen/processor_list" | "worldgen/template_pool" | "tag/function" | "tag/block" | "tag/activity" | "tag/attribute" | "tag/block_entity_type" | "tag/block_predicate_type" | "tag/chunk_status" | "tag/custom_stat" | "tag/enchantment" | "tag/entity_type" | "tag/float_provider_type" | "tag/fluid" | "tag/game_event" | "tag/height_provider_type" | "tag/int_provider_type" | "tag/item" | "tag/loot_condition_type" | "tag/loot_function_type" | "tag/loot_nbt_provider_type" | "tag/loot_number_provider_type" | "tag/loot_pool_entry_type" | "tag/loot_score_provider_type" | "tag/memory_module_type" | "tag/menu" | "tag/mob_effect" | "tag/motive" | "tag/particle_type" | "tag/point_of_interest_type" | "tag/pos_rule_test" | "tag/position_source_type" | "tag/potion" | "tag/recipe_serializer" | "tag/recipe_type" | "tag/rule_test" | "tag/schedule" | "tag/sensor_type" | "tag/sound_event" | "tag/stat_type" | "tag/villager_profession" | "tag/villager_type" | "tag/worldgen/biome_source" | "tag/worldgen/block_placer_type" | "tag/worldgen/block_state_provider_type" | "tag/worldgen/carver" | "tag/worldgen/chunk_generator" | "tag/worldgen/decorator" | "tag/worldgen/feature" | "tag/worldgen/feature_size_type" | "tag/worldgen/foliage_placer_type" | "tag/worldgen/material_condition" | "tag/worldgen/material_rule" | "tag/worldgen/placement_modifier_type" | "tag/worldgen/structure_feature" | "tag/worldgen/structure_piece" | "tag/worldgen/structure_pool_element" | "tag/worldgen/structure_processor" | "tag/worldgen/surface_builder" | "tag/worldgen/tree_decorator_type" | "tag/worldgen/trunk_placer_type" | "tag/worldgen/biome" | "tag/worldgen/configured_carver" | "tag/worldgen/configured_feature" | "tag/worldgen/configured_structure_feature" | "tag/worldgen/configured_surface_builder" | "tag/worldgen/noise" | "tag/worldgen/noise_settings" | "tag/worldgen/placed_feature" | "tag/worldgen/processor_list" | "tag/worldgen/template_pool" | "advancement" | "dimension" | "dimension_type" | "item_modifier" | "loot_table" | "predicate" | "recipe" | "structure";
10
+ category: "function" | "worldgen/biome" | "worldgen/configured_carver" | "worldgen/configured_feature" | "worldgen/configured_structure_feature" | "worldgen/configured_surface_builder" | "worldgen/noise" | "worldgen/noise_settings" | "worldgen/placed_feature" | "worldgen/processor_list" | "worldgen/template_pool" | "tag/function" | "tag/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" | "advancement" | "dimension" | "dimension_type" | "item_modifier" | "loot_table" | "predicate" | "recipe" | "structure";
11
11
  namespace: string;
12
12
  identifier: string;
13
13
  } | undefined;
package/lib/index.js CHANGED
@@ -22,6 +22,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.initialize = exports.mcf = exports.json = exports.dependency = void 0;
23
23
  const core = __importStar(require("@spyglassmc/core"));
24
24
  const nbt = __importStar(require("@spyglassmc/nbt"));
25
+ const nbtdoc = __importStar(require("@spyglassmc/nbtdoc"));
25
26
  const binder_1 = require("./binder");
26
27
  const dependency_1 = require("./dependency");
27
28
  const jeJson = __importStar(require("./json"));
@@ -65,6 +66,17 @@ const initialize = async (ctx) => {
65
66
  checksum: summary.checksum,
66
67
  registrar: (0, dependency_1.symbolRegistrar)(summary),
67
68
  });
69
+ meta.registerLinter('nameOfNbtKey', {
70
+ configValidator: core.linter.configValidator.nameConvention,
71
+ linter: core.linter.nameConvention('value'),
72
+ nodePredicate: n => (
73
+ // nbt compound keys without nbtdoc definition.
74
+ (!n.symbol && n.parent?.parent?.type === 'nbt:compound' && core.PairNode.is(n.parent) && n.type === 'string' && n.parent.key === n) ||
75
+ // nbt path keys without nbtdoc definition.
76
+ (!n.symbol && n.parent?.type === 'nbt:path' && n.type === 'string') ||
77
+ // nbtdoc compound key definition outside of `::minecraft` modules.
78
+ (nbtdoc.CompoundFieldNode.is(n.parent) && nbtdoc.CompoundFieldKey.is(n) && !n.symbol?.path[0]?.startsWith('::minecraft'))),
79
+ });
68
80
  jeJson.initialize(ctx);
69
81
  jeMcf.initialize(ctx, summary.commands, major);
70
82
  nbt.initialize(ctx);
@@ -1,4 +1,4 @@
1
1
  import type { JsonChecker } from '@spyglassmc/json/lib/checker/JsonChecker';
2
2
  export declare const pack_mcmeta: JsonChecker;
3
- export declare const Checkers: Map<"function" | "worldgen/biome" | "worldgen/configured_carver" | "worldgen/configured_feature" | "worldgen/configured_structure_feature" | "worldgen/configured_surface_builder" | "worldgen/noise" | "worldgen/noise_settings" | "worldgen/placed_feature" | "worldgen/processor_list" | "worldgen/template_pool" | "tag/function" | "tag/block" | "tag/activity" | "tag/attribute" | "tag/block_entity_type" | "tag/block_predicate_type" | "tag/chunk_status" | "tag/custom_stat" | "tag/enchantment" | "tag/entity_type" | "tag/float_provider_type" | "tag/fluid" | "tag/game_event" | "tag/height_provider_type" | "tag/int_provider_type" | "tag/item" | "tag/loot_condition_type" | "tag/loot_function_type" | "tag/loot_nbt_provider_type" | "tag/loot_number_provider_type" | "tag/loot_pool_entry_type" | "tag/loot_score_provider_type" | "tag/memory_module_type" | "tag/menu" | "tag/mob_effect" | "tag/motive" | "tag/particle_type" | "tag/point_of_interest_type" | "tag/pos_rule_test" | "tag/position_source_type" | "tag/potion" | "tag/recipe_serializer" | "tag/recipe_type" | "tag/rule_test" | "tag/schedule" | "tag/sensor_type" | "tag/sound_event" | "tag/stat_type" | "tag/villager_profession" | "tag/villager_type" | "tag/worldgen/biome_source" | "tag/worldgen/block_placer_type" | "tag/worldgen/block_state_provider_type" | "tag/worldgen/carver" | "tag/worldgen/chunk_generator" | "tag/worldgen/decorator" | "tag/worldgen/feature" | "tag/worldgen/feature_size_type" | "tag/worldgen/foliage_placer_type" | "tag/worldgen/material_condition" | "tag/worldgen/material_rule" | "tag/worldgen/placement_modifier_type" | "tag/worldgen/structure_feature" | "tag/worldgen/structure_piece" | "tag/worldgen/structure_pool_element" | "tag/worldgen/structure_processor" | "tag/worldgen/surface_builder" | "tag/worldgen/tree_decorator_type" | "tag/worldgen/trunk_placer_type" | "tag/worldgen/biome" | "tag/worldgen/configured_carver" | "tag/worldgen/configured_feature" | "tag/worldgen/configured_structure_feature" | "tag/worldgen/configured_surface_builder" | "tag/worldgen/noise" | "tag/worldgen/noise_settings" | "tag/worldgen/placed_feature" | "tag/worldgen/processor_list" | "tag/worldgen/template_pool" | "advancement" | "dimension" | "dimension_type" | "item_modifier" | "loot_table" | "predicate" | "recipe" | "structure", JsonChecker>;
3
+ export declare const Checkers: Map<"function" | "worldgen/biome" | "worldgen/configured_carver" | "worldgen/configured_feature" | "worldgen/configured_structure_feature" | "worldgen/configured_surface_builder" | "worldgen/noise" | "worldgen/noise_settings" | "worldgen/placed_feature" | "worldgen/processor_list" | "worldgen/template_pool" | "tag/function" | "tag/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" | "advancement" | "dimension" | "dimension_type" | "item_modifier" | "loot_table" | "predicate" | "recipe" | "structure", JsonChecker>;
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -43,6 +43,23 @@ const getNode = (nodes, index) => {
43
43
  return nodes[index]?.children[0];
44
44
  };
45
45
  const rootCommand = (nodes, index, ctx) => {
46
+ for (const { children: [node] } of nodes) {
47
+ if (node_1.BlockNode.is(node)) {
48
+ block(node, ctx);
49
+ }
50
+ else if (node_1.EntityNode.is(node)) {
51
+ entity(node, ctx);
52
+ }
53
+ else if (node_1.ItemNode.is(node)) {
54
+ item(node, ctx);
55
+ }
56
+ else if (node_1.ParticleNode.is(node)) {
57
+ particle(node, ctx);
58
+ }
59
+ else if (json.JsonNode.is(node)) {
60
+ (0, text_component_1.text_component)(node, { ...ctx, context: '' });
61
+ }
62
+ }
46
63
  if (getName(nodes, index) === 'data') {
47
64
  if (getName(nodes, index + 1) === 'get') {
48
65
  nbtPath(nodes, index + 2, ctx);
@@ -53,24 +70,57 @@ const rootCommand = (nodes, index, ctx) => {
53
70
  else if (getName(nodes, index + 1) === 'modify') {
54
71
  nbtPath(nodes, index + 2, ctx);
55
72
  const targetPath = getNode(nodes, index + 4);
56
- const operation = getName(nodes, index + 5);
57
- const sourceTypeIndex = operation === 'insert' ? index + 7 : index + 6;
58
- if (getName(nodes, sourceTypeIndex) === 'from') {
59
- // `from <$nbtPath$>`
60
- nbtPath(nodes, sourceTypeIndex + 1, ctx);
61
- const sourcePath = getNode(nodes, sourceTypeIndex + 3);
62
- if (nbt.NbtPathNode.is(targetPath) && nbt.NbtPathNode.is(sourcePath)) {
63
- const { errorMessage } = nbtdoc.checkAssignability({ source: sourcePath.targetType, target: targetPath.targetType });
64
- if (errorMessage) {
65
- ctx.err.report(errorMessage, core.Range.span(targetPath, sourcePath), 2 /* Warning */);
73
+ if (nbt.NbtPathNode.is(targetPath)) {
74
+ const operationNode = getNode(nodes, index + 5);
75
+ const operation = getName(nodes, index + 5);
76
+ const sourceTypeIndex = operation === 'insert' ? index + 7 : index + 6;
77
+ let targetNbtdocType = targetPath.targetType ? nbtdoc.simplifyType(targetPath.targetType) : undefined;
78
+ const isType = (type) => !targetNbtdocType || targetNbtdocType.type === type || (targetNbtdocType.type === 'union' && targetNbtdocType.members.some(m => m.type === type));
79
+ if (operation === 'merge') {
80
+ if (!(isType('compound') || isType('index'))) {
81
+ ctx.err.report((0, lib_1.localize)('mcfunction.checker.command.data-modify-unapplicable-operation', (0, lib_1.localeQuote)(operation), (0, lib_1.localize)('nbt.node.compound'), (0, lib_1.localeQuote)(nbtdoc.NbtdocType.toString(targetNbtdocType))), core.Range.span(targetPath, operationNode), 2 /* Warning */);
82
+ targetNbtdocType = undefined;
66
83
  }
67
84
  }
68
- }
69
- else if (getName(nodes, sourceTypeIndex) === 'value') {
70
- // `value <value: nbt_tag>`
71
- const valueNode = getNode(nodes, sourceTypeIndex + 1);
72
- if (nbt.NbtPathNode.is(targetPath) && targetPath.targetType && nbt.NbtNode.is(valueNode)) {
73
- nbt.checker.fieldValue(targetPath.targetType, { allowUnknownKey: true })(valueNode, ctx);
85
+ else if (operation === 'append' || operation === 'insert' || operation === 'prepend') {
86
+ if (isType('list') || isType('byte_array') || isType('int_array') || isType('long_array')) {
87
+ if (targetNbtdocType?.type === 'list') {
88
+ targetNbtdocType = targetNbtdocType.item;
89
+ }
90
+ else if (targetNbtdocType?.type === 'byte_array') {
91
+ targetNbtdocType = { type: 'byte', valueRange: targetNbtdocType.valueRange };
92
+ }
93
+ else if (targetNbtdocType?.type === 'int_array') {
94
+ targetNbtdocType = { type: 'int', valueRange: targetNbtdocType.valueRange };
95
+ }
96
+ else if (targetNbtdocType?.type === 'long_array') {
97
+ targetNbtdocType = { type: 'long', valueRange: targetNbtdocType.valueRange };
98
+ }
99
+ }
100
+ else {
101
+ ctx.err.report((0, lib_1.localize)('mcfunction.checker.command.data-modify-unapplicable-operation', (0, lib_1.localeQuote)(operation), (0, lib_1.localize)('nbt.node.list'), (0, lib_1.localeQuote)(nbtdoc.NbtdocType.toString(targetNbtdocType))), core.Range.span(targetPath, operationNode), 2 /* Warning */);
102
+ targetNbtdocType = undefined;
103
+ }
104
+ }
105
+ if (targetNbtdocType) {
106
+ if (getName(nodes, sourceTypeIndex) === 'from') {
107
+ // `from <$nbtPath$>`
108
+ nbtPath(nodes, sourceTypeIndex + 1, ctx);
109
+ const sourcePath = getNode(nodes, sourceTypeIndex + 3);
110
+ if (nbt.NbtPathNode.is(sourcePath)) {
111
+ const { errorMessage } = nbtdoc.checkAssignability({ source: sourcePath.targetType, target: targetNbtdocType });
112
+ if (errorMessage) {
113
+ ctx.err.report(errorMessage, core.Range.span(targetPath, sourcePath), 2 /* Warning */);
114
+ }
115
+ }
116
+ }
117
+ else if (getName(nodes, sourceTypeIndex) === 'value') {
118
+ // `value <value: nbt_tag>`
119
+ const valueNode = getNode(nodes, sourceTypeIndex + 1);
120
+ if (nbt.NbtNode.is(valueNode)) {
121
+ nbt.checker.fieldValue(targetNbtdocType, { allowUnknownKey: true })(valueNode, ctx);
122
+ }
123
+ }
74
124
  }
75
125
  }
76
126
  }
@@ -94,12 +144,34 @@ const rootCommand = (nodes, index, ctx) => {
94
144
  else if (getName(nodes, index) === 'summon') {
95
145
  summonNbt(nodes, index + 1, ctx);
96
146
  }
97
- for (const { children: [node] } of nodes) {
98
- if (json.JsonNode.is(node)) {
99
- (0, text_component_1.text_component)(node, { ...ctx, context: '' });
100
- }
147
+ };
148
+ //#region Checkers for argument nodes
149
+ const block = (node, ctx) => {
150
+ if (!node.nbt) {
151
+ return;
101
152
  }
153
+ nbt.checker.index('block', core.ResourceLocationNode.toString(node.id, 'full'))(node.nbt, ctx);
154
+ };
155
+ const entity = (node, ctx) => {
156
+ const nbtPair = node.selector?.arguments?.children.find(pair => pair.key?.value === 'nbt');
157
+ if (!nbtPair) {
158
+ return;
159
+ }
160
+ const types = (0, exports.getTypesFromEntity)(node, ctx);
161
+ const nbtValue = nbtPair.value;
162
+ nbt.checker.index('entity_type', types)(nbtValue, ctx);
163
+ };
164
+ const item = (node, ctx) => {
165
+ if (!node.nbt) {
166
+ return;
167
+ }
168
+ nbt.checker.index('item', core.ResourceLocationNode.toString(node.id, 'full'))(node.nbt, ctx);
169
+ };
170
+ const particle = (node, ctx) => {
171
+ core.checker.dispatchSync(node, ctx);
102
172
  };
173
+ //#endregion
174
+ //#region Checkers for command argument structure.
103
175
  /**
104
176
  * - `block <targetPos: block_pos> <nbt: nbt_compound_tag>`
105
177
  * - `entity <target: entity> <nbt: nbt_compound_tag>`
@@ -178,6 +250,7 @@ const summonNbt = (nodes, index, ctx) => {
178
250
  nbt.checker.index('entity_type', core.ResourceLocationNode.toString(typeNode, 'full'))(nbtNode, ctx);
179
251
  }
180
252
  };
253
+ //#endregion
181
254
  const getTypesFromEntity = (entity, ctx) => {
182
255
  if (entity.playerName !== undefined || entity.selector?.playersOnly) {
183
256
  return ['minecraft:player'];
@@ -212,6 +285,10 @@ const getTypesFromEntity = (entity, ctx) => {
212
285
  exports.getTypesFromEntity = getTypesFromEntity;
213
286
  function register(meta) {
214
287
  meta.registerChecker('mcfunction:command', exports.command);
288
+ meta.registerChecker('mcfunction:block', block);
289
+ meta.registerChecker('mcfunction:entity', entity);
290
+ meta.registerChecker('mcfunction:item', item);
291
+ meta.registerChecker('mcfunction:particle', particle);
215
292
  }
216
293
  exports.register = register;
217
294
  //# sourceMappingURL=index.js.map
@@ -57,8 +57,7 @@ const initialize = (ctx, commands, majorVersion) => {
57
57
  });
58
58
  meta.registerParser('mcfunction:block_predicate', parser.blockPredicate);
59
59
  meta.registerParser('mcfunction:component', parser.component);
60
- // TODO: 'mcfunction:particle'
61
- // TODO: Uncomment in `SpecialStrings` in `nbtdocUtil.ts` as well.
60
+ meta.registerParser('mcfunction:particle', parser.particle);
62
61
  meta.registerParser('mcfunction:tag', parser.tag());
63
62
  meta.registerParser('mcfunction:team', parser.team());
64
63
  meta.registerParser('mcfunction:command', mcf.command(mcf.CommandTreeRegistry.instance.get(majorVersion), parser.argument));
@@ -80,7 +80,7 @@ export interface EntitySelectorNode extends core.AstNode {
80
80
  export declare namespace EntitySelectorNode {
81
81
  function is(node: core.AstNode | undefined): node is EntitySelectorNode;
82
82
  function mock(range: core.RangeLike): EntitySelectorNode;
83
- const ArgumentKeys: Set<"predicate" | "tag" | "team" | "type" | "x" | "y" | "z" | "sort" | "level" | "advancements" | "nbt" | "name" | "scores" | "limit" | "distance" | "gamemode" | "dx" | "dy" | "dz" | "x_rotation" | "y_rotation">;
83
+ const ArgumentKeys: Set<"sort" | "type" | "predicate" | "tag" | "team" | "x" | "y" | "z" | "level" | "advancements" | "nbt" | "name" | "scores" | "limit" | "distance" | "gamemode" | "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,
@@ -111,6 +111,7 @@ export interface ItemNode extends core.AstNode {
111
111
  nbt?: nbt.NbtCompoundNode;
112
112
  }
113
113
  export declare namespace ItemNode {
114
+ function is(node: core.AstNode | undefined): node is ItemNode;
114
115
  function mock(range: core.RangeLike, isPredicate: boolean): ItemNode;
115
116
  }
116
117
  export interface IntRangeNode extends core.AstNode {
@@ -145,6 +146,7 @@ export declare namespace ParticleNode {
145
146
  const SpecialTypes: Set<"block" | "item" | "block_marker" | "dust" | "dust_color_transition" | "falling_dust" | "sculk_charge" | "vibration">;
146
147
  export type SpecialType = typeof SpecialTypes extends Set<infer T> ? T : undefined;
147
148
  export function isSpecialType(type: string | undefined): type is SpecialType;
149
+ export function is(node: core.AstNode | undefined): node is ParticleNode;
148
150
  export function mock(range: core.RangeLike): ParticleNode;
149
151
  export {};
150
152
  }
@@ -166,6 +166,10 @@ var EntityNode;
166
166
  })(EntityNode = exports.EntityNode || (exports.EntityNode = {}));
167
167
  var ItemNode;
168
168
  (function (ItemNode) {
169
+ function is(node) {
170
+ return node?.type === 'mcfunction:item';
171
+ }
172
+ ItemNode.is = is;
169
173
  function mock(range, isPredicate) {
170
174
  const id = core.ResourceLocationNode.mock(range, { category: 'item', allowTag: isPredicate });
171
175
  return {
@@ -231,6 +235,10 @@ var ParticleNode;
231
235
  return SpecialTypes.has(type);
232
236
  }
233
237
  ParticleNode.isSpecialType = isSpecialType;
238
+ function is(node) {
239
+ return node?.type === 'mcfunction:particle';
240
+ }
241
+ ParticleNode.is = is;
234
242
  function mock(range) {
235
243
  const id = core.ResourceLocationNode.mock(range, { category: 'particle_type' });
236
244
  return {
@@ -1,7 +1,7 @@
1
1
  import * as core from '@spyglassmc/core';
2
2
  import * as json from '@spyglassmc/json';
3
3
  import * as mcf from '@spyglassmc/mcfunction';
4
- import type { BlockNode } from '../node';
4
+ import type { BlockNode, ParticleNode } from '../node';
5
5
  /**
6
6
  * @returns The parser for the specified argument tree node. All argument parsers used in the `mcfunction` package
7
7
  * fail on empty input.
@@ -9,6 +9,7 @@ import type { BlockNode } from '../node';
9
9
  export declare const argument: mcf.ArgumentParserGetter;
10
10
  export declare const blockPredicate: core.InfallibleParser<BlockNode>;
11
11
  export declare const component: core.Parser<json.JsonNode>;
12
+ export declare const particle: core.InfallibleParser<ParticleNode>;
12
13
  export declare const scoreHolderFakeName: core.Parser<core.SymbolNode>;
13
14
  export declare function tag(terminators?: string[]): core.InfallibleParser<core.SymbolNode>;
14
15
  export declare function team(usageType?: core.SymbolUsageType, terminators?: string[]): core.InfallibleParser<core.SymbolNode>;
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
19
19
  return result;
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.team = exports.tag = exports.scoreHolderFakeName = exports.component = exports.blockPredicate = exports.argument = void 0;
22
+ exports.team = exports.tag = exports.scoreHolderFakeName = exports.particle = exports.component = exports.blockPredicate = exports.argument = void 0;
23
23
  const core = __importStar(require("@spyglassmc/core"));
24
24
  const core_1 = require("@spyglassmc/core");
25
25
  const json = __importStar(require("@spyglassmc/json"));
@@ -163,7 +163,7 @@ const argument = (rawTreeNode) => {
163
163
  colorTokenType: 'operator',
164
164
  }));
165
165
  case 'minecraft:particle':
166
- return wrap(particle);
166
+ return wrap(exports.particle);
167
167
  case 'minecraft:resource':
168
168
  case 'minecraft:resource_or_tag':
169
169
  return wrap(core.resourceLocation({
@@ -363,7 +363,7 @@ const message = (src, ctx) => {
363
363
  }
364
364
  return ans;
365
365
  };
366
- const particle = (() => {
366
+ exports.particle = (() => {
367
367
  const sep = core.map(mcf.sep, () => []);
368
368
  const vec = vector({ dimension: 3 });
369
369
  const color = core.map(vec, res => ({
@@ -10,17 +10,17 @@ export declare const Tree1_18: {
10
10
  children?: any | undefined;
11
11
  executable?: boolean | undefined;
12
12
  redirect?: readonly (string | undefined)[] | undefined;
13
- permission?: 0 | 2 | 1 | 3 | 4 | undefined;
14
- } | any | {
13
+ permission?: 0 | 2 | 3 | 1 | 4 | undefined;
14
+ } | {
15
15
  type?: "literal" | undefined;
16
16
  children?: any | undefined;
17
17
  executable?: boolean | undefined;
18
18
  redirect?: readonly (string | undefined)[] | undefined;
19
- permission?: 0 | 2 | 1 | 3 | 4 | undefined;
20
- } | undefined;
19
+ permission?: 0 | 2 | 3 | 1 | 4 | undefined;
20
+ } | any | undefined;
21
21
  } | undefined;
22
22
  executable?: boolean | undefined;
23
23
  redirect?: readonly (string | undefined)[] | undefined;
24
- permission?: 0 | 2 | 1 | 3 | 4 | undefined;
24
+ permission?: 0 | 2 | 3 | 1 | 4 | undefined;
25
25
  };
26
26
  //# sourceMappingURL=1.18.d.ts.map
@@ -10,17 +10,17 @@ export declare const Tree1_19: {
10
10
  children?: any | undefined;
11
11
  executable?: boolean | undefined;
12
12
  redirect?: readonly (string | undefined)[] | undefined;
13
- permission?: 0 | 2 | 1 | 3 | 4 | undefined;
14
- } | any | {
13
+ permission?: 0 | 2 | 3 | 1 | 4 | undefined;
14
+ } | {
15
15
  type?: "literal" | undefined;
16
16
  children?: any | undefined;
17
17
  executable?: boolean | undefined;
18
18
  redirect?: readonly (string | undefined)[] | undefined;
19
- permission?: 0 | 2 | 1 | 3 | 4 | undefined;
20
- } | undefined;
19
+ permission?: 0 | 2 | 3 | 1 | 4 | undefined;
20
+ } | any | undefined;
21
21
  } | undefined;
22
22
  executable?: boolean | undefined;
23
23
  redirect?: readonly (string | undefined)[] | undefined;
24
- permission?: 0 | 2 | 1 | 3 | 4 | undefined;
24
+ permission?: 0 | 2 | 3 | 1 | 4 | undefined;
25
25
  };
26
26
  //# sourceMappingURL=1.19.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spyglassmc/java-edition",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "SPGoding",
@@ -16,12 +16,12 @@
16
16
  "release:dry": "npm publish --dry-run"
17
17
  },
18
18
  "dependencies": {
19
- "@spyglassmc/core": "0.1.0",
20
- "@spyglassmc/json": "0.1.0",
21
- "@spyglassmc/locales": "0.1.0",
22
- "@spyglassmc/mcfunction": "0.1.0",
23
- "@spyglassmc/nbt": "0.1.0",
24
- "@spyglassmc/nbtdoc": "0.1.0"
19
+ "@spyglassmc/core": "0.1.1",
20
+ "@spyglassmc/json": "0.1.1",
21
+ "@spyglassmc/locales": "0.1.1",
22
+ "@spyglassmc/mcfunction": "0.1.1",
23
+ "@spyglassmc/nbt": "0.1.1",
24
+ "@spyglassmc/nbtdoc": "0.1.1"
25
25
  },
26
26
  "devDependencies": {
27
27
  "fast-glob": "^3.2.5",