sandstone 1.0.0-beta.2 → 1.0.0-beta.3

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.
Files changed (121) hide show
  1. package/CLAUDE.md +315 -16
  2. package/bun.lock +18 -22
  3. package/dist/arguments/index.js +1093 -367
  4. package/dist/arguments/selector.d.ts +6 -6
  5. package/dist/commands/implementations/block/setblock.d.ts +6 -9
  6. package/dist/commands/implementations/entity/execute.d.ts +36 -21
  7. package/dist/commands/implementations/server/return.d.ts +14 -7
  8. package/dist/commands/implementations/world/data.d.ts +29 -32
  9. package/dist/commands/index.js +1102 -364
  10. package/dist/core/index.js +2207 -1481
  11. package/dist/core/resources/datapack/mcfunction.d.ts +1 -1
  12. package/dist/core/resources/datapack/variant.d.ts +1 -1
  13. package/dist/core/resources/resource.d.ts +4 -4
  14. package/dist/flow/Flow.d.ts +21 -22
  15. package/dist/flow/if_else.d.ts +8 -3
  16. package/dist/flow/index.d.ts +1 -0
  17. package/dist/flow/index.js +2196 -1451
  18. package/dist/flow/loop.d.ts +5 -4
  19. package/dist/flow/loops/for_i.d.ts +1 -1
  20. package/dist/flow/loops/for_of.d.ts +4 -3
  21. package/dist/flow/loops/staticAnalysis.d.ts +26 -0
  22. package/dist/flow/loops/while.d.ts +1 -1
  23. package/dist/flow/switch_case.d.ts +94 -12
  24. package/dist/index.d.ts +6 -6
  25. package/dist/index.js +1093 -367
  26. package/dist/pack/index.js +1103 -364
  27. package/dist/pack/pack.d.ts +12 -12
  28. package/dist/pack/visitors/index.d.ts +1 -0
  29. package/dist/pack/visitors/loopTransformationVisitor.d.ts +13 -6
  30. package/dist/pack/visitors/simplifyExecuteFunction.d.ts +3 -2
  31. package/dist/pack/visitors/simplifyReturnRunFunction.d.ts +2 -1
  32. package/dist/pack/visitors/switchTransformationVisitor.d.ts +31 -0
  33. package/dist/pack/visitors/unifyChainedExecutes.d.ts +3 -2
  34. package/dist/pack/visitors/visitor.d.ts +5 -1
  35. package/dist/utils.d.ts +34 -3
  36. package/dist/variables/Data.d.ts +7 -5
  37. package/dist/variables/DataSets.d.ts +17 -14
  38. package/dist/variables/Label.d.ts +1 -0
  39. package/dist/variables/Loop.d.ts +10 -2
  40. package/dist/variables/ResolveNBT.d.ts +4 -3
  41. package/dist/variables/Score.d.ts +49 -3
  42. package/dist/variables/index.js +1066 -328
  43. package/package.json +1 -1
  44. package/src/arguments/selector.ts +12 -0
  45. package/src/commands/implementations/block/setblock.ts +8 -12
  46. package/src/commands/implementations/entity/damage.ts +2 -2
  47. package/src/commands/implementations/entity/execute.ts +103 -34
  48. package/src/commands/implementations/server/return.ts +15 -7
  49. package/src/commands/implementations/world/data.ts +96 -48
  50. package/src/core/Macro.ts +18 -1
  51. package/src/core/resources/datapack/advancement.ts +1 -1
  52. package/src/core/resources/datapack/bannerPattern.ts +1 -1
  53. package/src/core/resources/datapack/chatType.ts +1 -1
  54. package/src/core/resources/datapack/damageType.ts +1 -1
  55. package/src/core/resources/datapack/dialog.ts +1 -1
  56. package/src/core/resources/datapack/enchantment.ts +2 -2
  57. package/src/core/resources/datapack/gametest.ts +2 -2
  58. package/src/core/resources/datapack/instrument.ts +1 -1
  59. package/src/core/resources/datapack/itemModifier.ts +1 -1
  60. package/src/core/resources/datapack/jukeboxSong.ts +1 -1
  61. package/src/core/resources/datapack/lootTable.ts +1 -1
  62. package/src/core/resources/datapack/mcfunction.ts +36 -17
  63. package/src/core/resources/datapack/predicate.ts +1 -1
  64. package/src/core/resources/datapack/recipe.ts +1 -1
  65. package/src/core/resources/datapack/structure.ts +1 -1
  66. package/src/core/resources/datapack/tag.ts +4 -4
  67. package/src/core/resources/datapack/timeline.ts +2 -2
  68. package/src/core/resources/datapack/trialSpawner.ts +1 -1
  69. package/src/core/resources/datapack/trimMaterial.ts +1 -1
  70. package/src/core/resources/datapack/trimPattern.ts +1 -1
  71. package/src/core/resources/datapack/variant.ts +2 -2
  72. package/src/core/resources/datapack/villagerTrade.ts +2 -2
  73. package/src/core/resources/resource.ts +22 -11
  74. package/src/core/resources/resourcepack/atlas.ts +1 -1
  75. package/src/core/resources/resourcepack/blockstate.ts +1 -1
  76. package/src/core/resources/resourcepack/equipment.ts +1 -1
  77. package/src/core/resources/resourcepack/font.ts +1 -1
  78. package/src/core/resources/resourcepack/itemDefinition.ts +1 -1
  79. package/src/core/resources/resourcepack/language.ts +1 -1
  80. package/src/core/resources/resourcepack/model.ts +1 -1
  81. package/src/core/resources/resourcepack/particle.ts +1 -1
  82. package/src/core/resources/resourcepack/postEffect.ts +1 -1
  83. package/src/core/resources/resourcepack/shader.ts +1 -1
  84. package/src/core/resources/resourcepack/sound.ts +1 -1
  85. package/src/core/resources/resourcepack/waypointStyle.ts +1 -1
  86. package/src/core/sandstoneCore.ts +9 -1
  87. package/src/flow/Flow.ts +58 -94
  88. package/src/flow/conditions/command.ts +1 -1
  89. package/src/flow/conditions/variables/dataPoint.ts +2 -2
  90. package/src/flow/if_else.ts +14 -3
  91. package/src/flow/index.ts +1 -0
  92. package/src/flow/loop.ts +10 -6
  93. package/src/flow/loops/for_i.ts +21 -17
  94. package/src/flow/loops/for_of.ts +43 -36
  95. package/src/flow/loops/staticAnalysis.ts +114 -0
  96. package/src/flow/loops/while.ts +8 -5
  97. package/src/flow/switch_case.ts +214 -13
  98. package/src/index.ts +6 -1
  99. package/src/pack/pack.ts +24 -19
  100. package/src/pack/visitors/containerCommandsToMCFunction.ts +12 -5
  101. package/src/pack/visitors/ifElseTransformationVisitor.ts +44 -16
  102. package/src/pack/visitors/index.ts +1 -0
  103. package/src/pack/visitors/initConstantsVisitor.ts +13 -11
  104. package/src/pack/visitors/loopTransformationVisitor.ts +30 -7
  105. package/src/pack/visitors/simplifyExecuteFunction.ts +43 -6
  106. package/src/pack/visitors/simplifyReturnRunFunction.ts +40 -17
  107. package/src/pack/visitors/switchTransformationVisitor.ts +452 -0
  108. package/src/pack/visitors/unifyChainedExecutes.ts +9 -1
  109. package/src/pack/visitors/visitor.ts +9 -1
  110. package/src/utils.ts +53 -12
  111. package/src/variables/Data.ts +20 -4
  112. package/src/variables/DataSets.ts +57 -23
  113. package/src/variables/JSONTextComponentClass.ts +6 -1
  114. package/src/variables/Label.ts +0 -3
  115. package/src/variables/Loop.ts +30 -1
  116. package/src/variables/Objective.ts +0 -1
  117. package/src/variables/ResolveNBT.ts +5 -3
  118. package/src/variables/Score.ts +238 -8
  119. package/src/variables/Sleep.ts +2 -2
  120. package/src/variables/UUID.ts +8 -6
  121. package/src/variables/nbt/NBTs.ts +14 -0
@@ -68,7 +68,7 @@ export type SinglePlayerArgument<MACRO extends boolean = false> = SinglePlayerSt
68
68
  * - Accepts: SelectorPickClass<true, boolean> (picked single entity)
69
69
  * - Accepts: UUIDClass<any> (entity UUID)
70
70
  */
71
- export type SingleEntityArgument<MACRO extends boolean = false> = SingleEntityStringArgument | SelectorClass<MACRO, true, true> | SelectorClass<MACRO, true, false> | SelectorPickClass<true, true> | SelectorPickClass<true, false> | SelectorPickClass<true, boolean> | UUIDClass<any> | _ShowAlias;
71
+ export type SingleEntityArgument<MACRO extends boolean = false> = SingleEntityStringArgument | SelectorClass<MACRO, true, true> | SelectorClass<MACRO, true, false> | SelectorClass<MACRO, true, boolean> | SelectorPickClass<true, true> | SelectorPickClass<true, false> | SelectorPickClass<true, boolean> | UUIDClass<any> | _ShowAlias;
72
72
  /**
73
73
  * Argument for commands that allow multiple players to be targeted.
74
74
  * - Accepts: '@a' | '@p' | '@r' | '@s' (player-targeting selectors)
@@ -76,7 +76,7 @@ export type SingleEntityArgument<MACRO extends boolean = false> = SingleEntitySt
76
76
  * - Accepts: SelectorClass<MACRO, boolean, true> (player-only selector, single or multiple)
77
77
  * - Accepts: SelectorPickClass<boolean, boolean> (picked entity - player not enforced at type level)
78
78
  */
79
- export type MultiplePlayersArgument<MACRO extends boolean = false> = MultiplePlayerStringArgument | SelectorClass<MACRO, true, true> | SelectorClass<MACRO, false, true> | SelectorPickClass<true, true> | SelectorPickClass<true, false> | SelectorPickClass<true, boolean> | SelectorPickClass<false, true> | SelectorPickClass<false, false> | SelectorPickClass<false, boolean> | SelectorPickClass<boolean, boolean> | _ShowAlias;
79
+ export type MultiplePlayersArgument<MACRO extends boolean = false> = MultiplePlayerStringArgument | SelectorClass<MACRO, true, true> | SelectorClass<MACRO, false, true> | SelectorClass<MACRO, boolean, true> | SelectorPickClass<true, true> | SelectorPickClass<true, false> | SelectorPickClass<true, boolean> | SelectorPickClass<false, true> | SelectorPickClass<false, false> | SelectorPickClass<false, boolean> | SelectorPickClass<boolean, boolean> | _ShowAlias;
80
80
  /**
81
81
  * Argument for commands that allow multiple entities of any type to be targeted.
82
82
  * - Accepts: All selector literals ('@e' | '@a' | '@s' | '@p' | '@n' | '@r')
@@ -84,7 +84,7 @@ export type MultiplePlayersArgument<MACRO extends boolean = false> = MultiplePla
84
84
  * - Accepts: SelectorClass<MACRO, boolean, boolean> (any selector)
85
85
  * - Accepts: SelectorPickClass<boolean, boolean> (any picked entity)
86
86
  */
87
- export type MultipleEntitiesArgument<MACRO extends boolean = false> = MultipleEntityStringArgument | SelectorClass<MACRO, true, true> | SelectorClass<MACRO, true, false> | SelectorClass<MACRO, false, true> | SelectorClass<MACRO, false, false> | SelectorPickClass<true, true> | SelectorPickClass<true, false> | SelectorPickClass<true, boolean> | SelectorPickClass<false, true> | SelectorPickClass<false, false> | SelectorPickClass<false, boolean> | SelectorPickClass<boolean, boolean> | _ShowAlias;
87
+ export type MultipleEntitiesArgument<MACRO extends boolean = false> = MultipleEntityStringArgument | SelectorClass<MACRO, true, true> | SelectorClass<MACRO, true, false> | SelectorClass<MACRO, true, boolean> | SelectorClass<MACRO, false, true> | SelectorClass<MACRO, false, false> | SelectorClass<MACRO, false, boolean> | SelectorClass<MACRO, boolean, true> | SelectorClass<MACRO, boolean, false> | SelectorClass<MACRO, boolean, boolean> | SelectorPickClass<true, true> | SelectorPickClass<true, false> | SelectorPickClass<true, boolean> | SelectorPickClass<false, true> | SelectorPickClass<false, false> | SelectorPickClass<false, boolean> | SelectorPickClass<boolean, boolean> | _ShowAlias;
88
88
  /**
89
89
  * Matches SelectorPickClass instances that are NOT SelectorClass.
90
90
  * SelectorClass has __selectorBrand, other SelectorPickClass subclasses (UUIDClass, EntityLabel) don't.
@@ -105,7 +105,7 @@ type PureSelectorPickClass<IsSingle extends boolean, IsPlayer extends boolean> =
105
105
  * foo('@e') // Error: '@e' is not assignable to 'never'
106
106
  * ```
107
107
  */
108
- export type SinglePlayerArgumentOf<MACRO extends boolean, T extends string> = ValidateSinglePlayerString<T> | SelectorClass<MACRO, true, true> | PureSelectorPickClass<true, true> | PureSelectorPickClass<true, false> | PureSelectorPickClass<true, boolean>;
108
+ export type SinglePlayerArgumentOf<MACRO extends boolean, T extends string> = ValidateSinglePlayerString<T> | SinglePlayerSelectorLiteral | SelectorClass<MACRO, true, true> | PureSelectorPickClass<true, true> | PureSelectorPickClass<true, false> | PureSelectorPickClass<true, boolean>;
109
109
  /**
110
110
  * Generic version of SingleEntityArgument that validates string literals.
111
111
  * Use this with a generic type parameter to reject invalid selectors like '@e' or '@a'.
@@ -117,10 +117,10 @@ export type SinglePlayerArgumentOf<MACRO extends boolean, T extends string> = Va
117
117
  * foo('@e') // Error: '@e' is not assignable to 'never'
118
118
  * ```
119
119
  */
120
- export type SingleEntityArgumentOf<MACRO extends boolean, T extends string> = ValidateSingleEntityString<T> | SelectorClass<MACRO, true, true> | SelectorClass<MACRO, true, false> | PureSelectorPickClass<true, true> | PureSelectorPickClass<true, false> | PureSelectorPickClass<true, boolean> | UUIDClass<any>;
120
+ export type SingleEntityArgumentOf<MACRO extends boolean, T extends string> = ValidateSingleEntityString<T> | SingleEntitySelectorLiteral | SelectorClass<MACRO, true, true> | SelectorClass<MACRO, true, false> | SelectorClass<MACRO, true, boolean> | PureSelectorPickClass<true, true> | PureSelectorPickClass<true, false> | PureSelectorPickClass<true, boolean> | UUIDClass<any>;
121
121
  /**
122
122
  * Generic version of MultiplePlayersArgument that validates string literals.
123
123
  * Use this with a generic type parameter to reject invalid selectors like '@e' or '@n'.
124
124
  */
125
- export type MultiplePlayersArgumentOf<MACRO extends boolean, T extends string> = ValidateMultiplePlayersString<T> | SelectorClass<MACRO, true, true> | SelectorClass<MACRO, false, true> | PureSelectorPickClass<true, true> | PureSelectorPickClass<true, false> | PureSelectorPickClass<true, boolean> | PureSelectorPickClass<false, true> | PureSelectorPickClass<false, false> | PureSelectorPickClass<false, boolean> | PureSelectorPickClass<boolean, boolean>;
125
+ export type MultiplePlayersArgumentOf<MACRO extends boolean, T extends string> = ValidateMultiplePlayersString<T> | MultiplePlayerSelectorLiteral | SelectorClass<MACRO, true, true> | SelectorClass<MACRO, false, true> | SelectorClass<MACRO, boolean, true> | PureSelectorPickClass<true, true> | PureSelectorPickClass<true, false> | PureSelectorPickClass<true, boolean> | PureSelectorPickClass<false, true> | PureSelectorPickClass<false, false> | PureSelectorPickClass<false, boolean> | PureSelectorPickClass<boolean, boolean>;
126
126
  export {};
@@ -3,18 +3,15 @@ import type { Macroable } from "../../../core/index.js";
3
3
  import { CommandNode } from "../../../core/nodes.js";
4
4
  import type { FinalCommandOutput } from "../../helpers.js";
5
5
  import { CommandArguments } from "../../helpers.js";
6
- import type { BLOCKS_SET } from "../../../arguments/generated/_registry/blocks.js";
7
- import type { NamespacedLiteralUnion, SetType } from "../../../utils.js";
6
+ import type { NamespacedLiteralUnion } from "../../../utils.js";
8
7
  /** Converts stringified boolean/numeric literals to actual booleans/numbers */
9
- export type ParseLiteral<T> = T extends 'true' | 'false' ? boolean : T extends `${infer N extends number}` ? N : T;
8
+ export type ParseLiteral<T> = (T extends 'true' | 'false' ? boolean : T extends `${infer N extends number}` ? N : T);
10
9
  /** Converts block state types from stringified literals to proper primitives */
11
10
  export type ParseBlockState<T> = {
12
11
  [K in keyof T]: ParseLiteral<T[K]>;
13
12
  };
14
- export type BlockEntityName = keyof SymbolBlock;
15
- export type BlockEntity = NamespacedLiteralUnion<BlockEntityName>;
16
- export type BlockStaticName = keyof Omit<Record<SetType<typeof BLOCKS_SET>, false>, BlockEntityName>;
17
- export type BlockStatic = (NamespacedLiteralUnion<BlockStaticName> | `minecraft:${BlockStaticName}`);
13
+ export type BlockEntity = NamespacedLiteralUnion<keyof SymbolBlock>;
14
+ export type BlockStatic = NamespacedLiteralUnion<Exclude<keyof SymbolMcdocBlockStates, keyof SymbolBlock>>;
18
15
  export declare class SetBlockCommandNode extends CommandNode {
19
16
  command: "setblock";
20
17
  }
@@ -67,7 +64,7 @@ export declare class SetBlockCommand<MACRO extends boolean> extends CommandArgum
67
64
  * setblock([spawn.x, spawn.y, spawn.z], 'minecraft:stone_brick_wall', { up: true }, 'strict')
68
65
  * ```
69
66
  */
70
- setblock<BLOCK extends Macroable<BlockStatic, MACRO>>(pos: Macroable<Coordinates<MACRO>, MACRO>, block: BLOCK, state?: Macroable<BLOCK extends keyof SymbolMcdocBlockStates ? ParseBlockState<NonNullable<SymbolMcdocBlockStates[BLOCK]>> : Record<string, string | boolean | number>, MACRO>, type?: 'destroy' | 'keep' | 'replace' | 'strict'): FinalCommandOutput;
67
+ setblock<BLOCK extends Macroable<BlockStatic, MACRO>>(pos: Macroable<Coordinates<MACRO>, MACRO>, block: BLOCK, state?: Macroable<BLOCK extends keyof SymbolMcdocBlockStates ? ParseBlockState<NonNullable<SymbolMcdocBlockStates[Extract<BLOCK, keyof SymbolMcdocBlockStates>]>> : Record<string, string | boolean | number>, MACRO>, type?: 'destroy' | 'keep' | 'replace' | 'strict'): FinalCommandOutput;
71
68
  /**
72
69
  * Place a block with NBT data at the specified coordinates.
73
70
  *
@@ -118,6 +115,6 @@ export declare class SetBlockCommand<MACRO extends boolean> extends CommandArgum
118
115
  * })
119
116
  * ```
120
117
  */
121
- setblock<BLOCK extends Macroable<BlockEntity, MACRO>>(pos: Macroable<Coordinates<MACRO>, MACRO>, block: BLOCK, state?: Macroable<BLOCK extends keyof SymbolMcdocBlockStates ? ParseBlockState<NonNullable<SymbolMcdocBlockStates[BLOCK]>> : Record<string, string | boolean | number>, MACRO>, nbt?: Macroable<BLOCK extends keyof SymbolBlock ? NonNullable<SymbolBlock[BLOCK]> : SymbolBlock<'%fallback'>, MACRO>, type?: 'destroy' | 'keep' | 'replace' | 'strict'): FinalCommandOutput;
118
+ setblock<BLOCK extends Macroable<BlockEntity, MACRO>>(pos: Macroable<Coordinates<MACRO>, MACRO>, block: BLOCK, state?: Macroable<BLOCK extends keyof SymbolMcdocBlockStates ? ParseBlockState<NonNullable<SymbolMcdocBlockStates[Extract<BLOCK, keyof SymbolMcdocBlockStates>]>> : Record<string, string | boolean | number>, MACRO>, nbt?: Macroable<BLOCK extends keyof SymbolBlock ? NonNullable<SymbolBlock[Extract<BLOCK, keyof SymbolBlock>]> : SymbolBlock<'%fallback'>, MACRO>, type?: 'destroy' | 'keep' | 'replace' | 'strict'): FinalCommandOutput;
122
119
  }
123
120
  export declare function blockStateStringifier(state: Record<string, string | number | boolean>): string;
@@ -1,5 +1,4 @@
1
1
  import type { ANCHORS, AXES, Registry, COMPARISON_OPERATORS, ContainerSlotSelector, Coordinates, EntitySlotSelector, MultipleEntitiesArgument, ObjectiveArgument, Range, Rotation, SingleEntityArgumentOf, SymbolBlock, SymbolMcdocBlockStates } from "../../../arguments/index.js";
2
- import type { BlockStatic, ParseBlockState } from "../block/setblock.js";
3
2
  import type { SandstoneCommands } from "../../../commands/index.js";
4
3
  import { type MacroArgument, type Macroable, type MCFunctionNode, type PredicateClass } from "../../../core/index.js";
5
4
  import type { Node } from "../../../core/nodes.js";
@@ -16,10 +15,13 @@ export type SubCommand = [
16
15
  subcommand: string,
17
16
  ...args: unknown[]
18
17
  ];
19
- type BlockEntityName = keyof SymbolBlock;
20
- type BlockEntity = NamespacedLiteralUnion<BlockEntityName>;
18
+ type ParseLiteral<T> = (T extends 'true' | 'false' ? boolean : T extends `${infer N extends number}` ? N : T);
19
+ type ParseBlockState<T> = {
20
+ [K in keyof T]: ParseLiteral<T[K]>;
21
+ };
22
+ type BlockEntity = NamespacedLiteralUnion<keyof SymbolBlock>;
23
+ type BlockStatic = NamespacedLiteralUnion<Exclude<keyof SymbolMcdocBlockStates, keyof SymbolBlock>>;
21
24
  export declare class ExecuteCommandPart<MACRO extends boolean> extends CommandArguments<typeof ExecuteCommandNode> {
22
- protected nestedExecute: (args: SubCommand, executable?: boolean) => ExecuteCommand<MACRO>;
23
25
  }
24
26
  export type StoreType = 'byte' | 'short' | 'int' | 'long' | 'float' | 'double';
25
27
  export type RelationType = 'attacker' | 'controller' | 'leasher' | 'origin' | 'owner' | 'passengers' | 'target' | 'vehicle';
@@ -43,13 +45,24 @@ export declare class ExecuteCommandNode extends ContainerCommandNode<SubCommand[
43
45
  * `function <name> with storage <macroStorage>`. This enables macro variables
44
46
  * from the storage to be used in the execute command.
45
47
  */
46
- macroStorage: string | undefined;
47
- constructor(sandstonePack: SandstonePack, args?: SubCommand[], { isFake, isSingleExecute, givenCallbackName, body, macroStorage, }?: {
48
+ macroStorage: DataPointClass | undefined;
49
+ /**
50
+ * If true, this execute node should be committed to its parent context after its body receives a command.
51
+ * This is set when .run is accessed and the execute hasn't been committed yet.
52
+ */
53
+ pendingCommit: boolean;
54
+ /**
55
+ * The MCFunction created by createMCFunction, if any.
56
+ * Used by LoopArgument to reference the loop function.
57
+ */
58
+ createdMCFunction: _RawMCFunctionClass<any, any> | null;
59
+ constructor(sandstonePack: SandstonePack, args?: SubCommand[], { isFake, isSingleExecute, givenCallbackName, body, macroStorage, pendingCommit, }?: {
48
60
  isFake?: boolean | undefined;
49
61
  isSingleExecute?: boolean | undefined;
50
62
  givenCallbackName?: string | undefined;
51
63
  body?: Node[] | undefined;
52
- macroStorage?: string | undefined;
64
+ macroStorage?: DataPointClass<any> | undefined;
65
+ pendingCommit?: boolean | undefined;
53
66
  });
54
67
  get callbackName(): string;
55
68
  append: (...nodes: Node[]) => any;
@@ -102,20 +115,13 @@ export declare class ExecuteStoreArgsCommand<MACRO extends boolean> extends Exec
102
115
  */
103
116
  entity: <T extends string>(target: Macroable<SingleEntityArgumentOf<MACRO, T>, MACRO>, path: Macroable<string, MACRO>, type: Macroable<StoreType, MACRO>, scale?: Macroable<number, MACRO>) => ExecuteCommand<MACRO>;
104
117
  /**
105
- * Overrides the given score with the final command's return value.
118
+ * Overrides the given scores with the final command's return value.
106
119
  *
107
120
  * @param targets Specifies score holder(s) whose score is to be overridden.
108
121
  *
109
122
  * @param objective A scoreboard objective.
110
- *
111
- * @param playerScore The player's score to override.
112
123
  */
113
- score(...args: [
114
- targets: Macroable<MultipleEntitiesArgument<MACRO>, MACRO>,
115
- objective: Macroable<ObjectiveArgument, MACRO>
116
- ] | [
117
- playerScore: Macroable<Score, MACRO>
118
- ]): ExecuteCommand<MACRO>;
124
+ score: (targets: Macroable<MultipleEntitiesArgument<MACRO>, MACRO>, objective: Macroable<ObjectiveArgument, MACRO>) => ExecuteCommand<MACRO>;
119
125
  /**
120
126
  * Uses the `path` within storage `target` to store the return value in.
121
127
  *
@@ -133,11 +139,20 @@ export declare class ExecuteStoreArgsCommand<MACRO extends boolean> extends Exec
133
139
  */
134
140
  storage: (target: Macroable<string, MACRO>, path: Macroable<string, MACRO>, type: Macroable<StoreType, MACRO>, scale?: Macroable<number, MACRO>) => ExecuteCommand<MACRO>;
135
141
  }
142
+ type DropFirstArg<T> = (T extends {
143
+ (first: any, ...args: infer A1): infer R1;
144
+ (first: any, ...args: infer A2): infer R2;
145
+ } ? {
146
+ (...args: A1): R1;
147
+ (...args: A2): R2;
148
+ } : never);
136
149
  export declare class ExecuteStoreCommand<MACRO extends boolean> extends ExecuteCommandPart<MACRO> {
150
+ _storeCallable(cmd: ExecuteStoreArgsCommand<MACRO>, score: Score): ExecuteCommand<MACRO>;
151
+ _storeCallable(cmd: ExecuteStoreArgsCommand<MACRO>, dataPoint: DataPointClass<'entity'> | DataPointClass<'block'> | DataPointClass<'storage'>, type?: Macroable<StoreType, MACRO>, scale?: Macroable<number, MACRO>): ExecuteCommand<MACRO>;
137
152
  /** Store the final command's result value. */
138
- get result(): ExecuteStoreArgsCommand<MACRO>;
153
+ get result(): ExecuteStoreArgsCommand<MACRO> & DropFirstArg<ExecuteStoreCommand<MACRO>["_storeCallable"]>;
139
154
  /** Store the final command's success value. */
140
- get success(): ExecuteStoreArgsCommand<MACRO>;
155
+ get success(): ExecuteStoreArgsCommand<MACRO> & DropFirstArg<ExecuteStoreCommand<MACRO>["_storeCallable"]>;
141
156
  }
142
157
  export declare class ExecuteDataArgsCommand<MACRO extends boolean> extends ExecuteCommandPart<MACRO> {
143
158
  /**
@@ -249,7 +264,7 @@ export declare class ExecuteIfUnlessCommand<MACRO extends boolean> extends Execu
249
264
  * execute.if.block(abs(0, 64, 0), 'minecraft:oak_log', { axis: 'y' })
250
265
  * ```
251
266
  */
252
- block<BLOCK extends Macroable<BlockStatic, MACRO>>(pos: Macroable<Coordinates<MACRO>, MACRO>, block: BLOCK, state?: Macroable<BLOCK extends keyof SymbolMcdocBlockStates ? ParseBlockState<NonNullable<SymbolMcdocBlockStates[BLOCK]>> : Record<string, string | boolean | number>, MACRO>): ExecuteCommand<MACRO>;
267
+ block<BLOCK extends Macroable<BlockStatic, MACRO>>(pos: Macroable<Coordinates<MACRO>, MACRO>, block: BLOCK, state?: Macroable<BLOCK extends keyof SymbolMcdocBlockStates ? ParseBlockState<NonNullable<SymbolMcdocBlockStates[Extract<BLOCK, keyof SymbolMcdocBlockStates>]>> : Record<string, string | boolean | number>, MACRO>): ExecuteCommand<MACRO>;
253
268
  /**
254
269
  * Compares the block at a given position to a given block with NBT data.
255
270
  *
@@ -267,7 +282,7 @@ export declare class ExecuteIfUnlessCommand<MACRO extends boolean> extends Execu
267
282
  * execute.if.block(['~', '~', '~1'], 'minecraft:command_block', {}, { Command: 'say Hello' })
268
283
  * ```
269
284
  */
270
- block<BLOCK extends Macroable<BlockEntity, MACRO>>(pos: Macroable<Coordinates<MACRO>, MACRO>, block: BLOCK, state: Macroable<BLOCK extends keyof SymbolMcdocBlockStates ? ParseBlockState<NonNullable<SymbolMcdocBlockStates[BLOCK]>> : Record<string, string | boolean | number> | undefined, MACRO>, nbt: Macroable<BLOCK extends keyof SymbolBlock ? NonNullable<SymbolBlock[BLOCK]> : SymbolBlock<'%fallback'>, MACRO>): ExecuteCommand<MACRO>;
285
+ block<BLOCK extends Macroable<BlockEntity, MACRO>>(pos: Macroable<Coordinates<MACRO>, MACRO>, block: BLOCK, state: Macroable<BLOCK extends keyof SymbolMcdocBlockStates ? ParseBlockState<NonNullable<SymbolMcdocBlockStates[Extract<BLOCK, keyof SymbolMcdocBlockStates>]>> : Record<string, string | boolean | number> | undefined, MACRO>, nbt: Macroable<BLOCK extends keyof SymbolBlock ? NonNullable<SymbolBlock[Extract<BLOCK, keyof SymbolBlock>]> : SymbolBlock<'%fallback'>, MACRO>): ExecuteCommand<MACRO>;
271
286
  /**
272
287
  * Compares the blocks in two equally sized volumes.
273
288
  * @param start Start position of the first volume.
@@ -469,7 +484,7 @@ export type DeferredMacroExecuteOptions = {
469
484
  macroStorage?: never;
470
485
  } | {
471
486
  /** Explicit storage to use for the macro function call (e.g., '__sandstone:temp') */
472
- macroStorage: string;
487
+ macroStorage: DataPointClass;
473
488
  env?: never;
474
489
  });
475
490
  /**
@@ -11,11 +11,18 @@ export declare class ReturnRunCommandNode extends ContainerCommandNode {
11
11
  * This is set to `false` if the execute is used as a function (execute.run(() => { stuff })).
12
12
  */
13
13
  isSingleExecute: boolean;
14
+ /**
15
+ * When true, this return run is needed for flow control (e.g., if/elseIf early exit).
16
+ * When false, the return run was added for function boundary semantics and can be
17
+ * unwrapped when the function is inlined.
18
+ */
19
+ isFlowControl: boolean;
14
20
  constructor(sandstonePack: SandstonePack, args?: [
15
21
  ...args: unknown[]
16
- ], { isSingleExecute, body }?: {
22
+ ], { isSingleExecute, body, isFlowControl }?: {
17
23
  isSingleExecute?: boolean | undefined;
18
24
  body?: Node[] | undefined;
25
+ isFlowControl?: boolean | undefined;
19
26
  });
20
27
  getValue: () => string;
21
28
  createMCFunction: (currentMCFunction: MCFunctionNode | null) => {
@@ -40,7 +47,7 @@ export declare class ReturnArgumentsCommand<MACRO extends boolean> extends Comma
40
47
  * - With a callback function: return.run(() => { commands })
41
48
  *
42
49
  * @example
43
- * return.run.execute.if.score('@p', 'health').matches([1, 10]).run.return(1)
50
+ * return.run.execute.if.score('@p', 'health').matches([1, 10]).run.returnCmd(1)
44
51
  */
45
52
  get run(): SandstoneCommands<MACRO> & ((callback: () => any) => FinalCommandOutput);
46
53
  }
@@ -68,8 +75,8 @@ export declare class ReturnCommand<MACRO extends boolean> extends CommandArgumen
68
75
  * return.return()
69
76
  *
70
77
  * // Return based on conditions
71
- * execute.if.entity('@p[tag=vip]').run.return(100) // VIP bonus
72
- * execute.unless.entity('@p[tag=vip]').run.return(50) // Regular bonus
78
+ * execute.if.entity('@p[tag=vip]').run.returnCmd(100) // VIP bonus
79
+ * execute.unless.entity('@p[tag=vip]').run.returnCmd(50) // Regular bonus
73
80
  * ```
74
81
  */
75
82
  get return(): {
@@ -88,13 +95,13 @@ export declare class ReturnCommand<MACRO extends boolean> extends CommandArgumen
88
95
  * @example
89
96
  * ```ts
90
97
  * // Early exit on invalid conditions
91
- * execute.unless.entity('@p').run.return.fail() // No player found
98
+ * execute.unless.entity('@p').run.returnCmd.fail() // No player found
92
99
  *
93
100
  * // Validation check
94
- * execute.if.score('@p', 'level').matches([..0]).run.return.fail() // Invalid level
101
+ * execute.if.score('@p', 'level').matches([..0]).run.returnCmd.fail() // Invalid level
95
102
  *
96
103
  * // Error handling
97
- * execute.unless.block('~ ~ ~', 'minecraft:chest').run.return.fail() // Expected chest not found
104
+ * execute.unless.block('~ ~ ~', 'minecraft:chest').run.returnCmd.fail() // Expected chest not found
98
105
  * ```
99
106
  */
100
107
  fail: () => FinalCommandOutput;
@@ -1,8 +1,8 @@
1
1
  import type { Coordinates, NBTObject, SingleEntityArgumentOf } from "../../../arguments/index.js";
2
2
  import { type Macroable } from "../../../core/index.js";
3
3
  import { CommandNode } from "../../../core/nodes.js";
4
- import type { DataPointClass } from "../../../variables/index.js";
5
- import { CommandArguments } from "../../helpers.js";
4
+ import { DataPointClass } from "../../../variables/index.js";
5
+ import { CommandArguments, type FinalCommandOutput } from "../../helpers.js";
6
6
  export declare class DataCommandNode extends CommandNode {
7
7
  command: "data";
8
8
  }
@@ -13,12 +13,13 @@ export declare class DataCommand<MACRO extends boolean> extends CommandArguments
13
13
  *
14
14
  * @example
15
15
  * ```ts
16
- * data.get.block(abs(100, 70, 200), 'Items[0]', 1) // Get block NBT
17
- * data.get.entity('@p', 'Health') // Get player health
18
- * data.get.storage('minecraft:temp', 'value') // Get storage data
16
+ * data.get(dataPoint, 1) // Get data point NBT with scale
17
+ * data.get.block(abs(100, 70, 200), 'Items[0]', 1) // Get block NBT
18
+ * data.get.entity('@p', 'Health') // Get player health
19
+ * data.get.storage('minecraft:temp', 'value') // Get storage data
19
20
  * ```
20
21
  */
21
- get get(): DataGetCommand<MACRO>;
22
+ get get(): DataGetCommand<MACRO> & ((dataPoint: DataPointClass<"entity"> | DataPointClass<"block"> | DataPointClass<"storage">, scale?: Macroable<number, MACRO>) => FinalCommandOutput);
22
23
  /**
23
24
  * Merge NBT data into blocks, entities, or storage.
24
25
  *
@@ -35,23 +36,25 @@ export declare class DataCommand<MACRO extends boolean> extends CommandArguments
35
36
  *
36
37
  * @example
37
38
  * ```ts
38
- * data.modify.entity('@p', 'Health').set.value(20) // Set health
39
+ * data.modify(dataPoint).set.value(20) // Modify data point
40
+ * data.modify.entity('@p', 'Health').set.value(20) // Set health
39
41
  * data.modify.block(abs(100, 70, 200), 'Items').append.value({id: 'stone'}) // Add item
40
42
  * data.modify.storage('minecraft:temp', 'list').prepend.from.entity('@p', 'Inventory[0]')
41
43
  * ```
42
44
  */
43
- get modify(): DataModifyCommand<MACRO>;
45
+ get modify(): DataModifyCommand<MACRO> & ((dataPoint: DataPointClass<"entity"> | DataPointClass<"block"> | DataPointClass<"storage">) => DataModifyTypeCommand<MACRO>);
44
46
  /**
45
47
  * Remove NBT data from blocks, entities, or storage.
46
48
  *
47
49
  * @example
48
50
  * ```ts
49
- * data.remove.block(abs(100, 70, 200), 'Items[0]') // Remove block NBT
50
- * data.remove.entity('@e[type=item]', 'Motion') // Remove entity motion
51
- * data.remove.storage('minecraft:temp', 'old_data') // Remove storage data
51
+ * data.remove(dataPoint) // Remove data point NBT
52
+ * data.remove.block(abs(100, 70, 200), 'Items[0]') // Remove block NBT
53
+ * data.remove.entity('@e[type=item]', 'Motion') // Remove entity motion
54
+ * data.remove.storage('minecraft:temp', 'old_data') // Remove storage data
52
55
  * ```
53
56
  */
54
- get remove(): DataRemoveCommand<MACRO>;
57
+ get remove(): DataRemoveCommand<MACRO> & ((dataPoint: DataPointClass<"entity"> | DataPointClass<"block"> | DataPointClass<"storage">) => FinalCommandOutput);
55
58
  }
56
59
  export declare class DataGetCommand<MACRO extends boolean> extends CommandArguments {
57
60
  /**
@@ -61,7 +64,7 @@ export declare class DataGetCommand<MACRO extends boolean> extends CommandArgume
61
64
  * @param path The path of the NBT to get.
62
65
  * @param scale The scale to multiply the NBT value by.
63
66
  */
64
- block: (targetPos: Macroable<Coordinates<MACRO>, MACRO>, path?: Macroable<string, MACRO>, scale?: Macroable<number, MACRO>) => import("../../index.js").FinalCommandOutput;
67
+ block: (targetPos: Macroable<Coordinates<MACRO>, MACRO>, path?: Macroable<string, MACRO>, scale?: Macroable<number, MACRO>) => FinalCommandOutput;
65
68
  /**
66
69
  * Get the NBT of a given entity.
67
70
  *
@@ -69,7 +72,7 @@ export declare class DataGetCommand<MACRO extends boolean> extends CommandArgume
69
72
  * @param path The path of the NBT to get.
70
73
  * @param scale The scale to multiply the NBT value by.
71
74
  */
72
- entity: <T extends string>(target: Macroable<SingleEntityArgumentOf<MACRO, T>, MACRO>, path?: Macroable<string, MACRO>, scale?: Macroable<number, MACRO>) => import("../../index.js").FinalCommandOutput;
75
+ entity: <T extends string>(target: Macroable<SingleEntityArgumentOf<MACRO, T>, MACRO>, path?: Macroable<string, MACRO>, scale?: Macroable<number, MACRO>) => FinalCommandOutput;
73
76
  /**
74
77
  * Get the NBT from a given storage path.
75
78
  *
@@ -77,7 +80,7 @@ export declare class DataGetCommand<MACRO extends boolean> extends CommandArgume
77
80
  * @param path The path of the NBT to get.
78
81
  * @param scale The scale to multiply the NBT value by.
79
82
  */
80
- storage: (target: Macroable<string, MACRO>, path?: Macroable<string, MACRO>, scale?: Macroable<number, MACRO>) => import("../../index.js").FinalCommandOutput;
83
+ storage: (target: Macroable<string, MACRO>, path?: Macroable<string, MACRO>, scale?: Macroable<number, MACRO>) => FinalCommandOutput;
81
84
  }
82
85
  export declare class DataMergeCommand<MACRO extends boolean> extends CommandArguments {
83
86
  /**
@@ -86,21 +89,21 @@ export declare class DataMergeCommand<MACRO extends boolean> extends CommandArgu
86
89
  * @param targetPos The coordinates of the block to merge the NBT with.
87
90
  * @param nbt The NBT to merge with.
88
91
  */
89
- block: (targetPos: Macroable<Coordinates<MACRO>, MACRO>, nbt: Macroable<NBTObject, MACRO>) => import("../../index.js").FinalCommandOutput;
92
+ block: (targetPos: Macroable<Coordinates<MACRO>, MACRO>, nbt: Macroable<NBTObject, MACRO>) => FinalCommandOutput;
90
93
  /**
91
94
  * Merge the NBT of the given entity, with the given NBT.
92
95
  *
93
96
  * @param target The entity to merge the NBT with.
94
97
  * @param nbt The NBT to merge with.
95
98
  */
96
- entity: <T extends string>(target: Macroable<SingleEntityArgumentOf<MACRO, T>, MACRO>, nbt: Macroable<NBTObject, MACRO>) => import("../../index.js").FinalCommandOutput;
99
+ entity: <T extends string>(target: Macroable<SingleEntityArgumentOf<MACRO, T>, MACRO>, nbt: Macroable<NBTObject, MACRO>) => FinalCommandOutput;
97
100
  /**
98
101
  * Merge the NBT of the given storage path, with the given NBT.
99
102
  *
100
103
  * @param target The storage to merge the NBT with.
101
104
  * @param nbt The NBT to merge with.
102
105
  */
103
- storage: (target: Macroable<string, MACRO>, nbt: Macroable<NBTObject, MACRO>) => import("../../index.js").FinalCommandOutput;
106
+ storage: (target: Macroable<string, MACRO>, nbt: Macroable<NBTObject, MACRO>) => FinalCommandOutput;
104
107
  }
105
108
  export declare class DataModifyFromCommand<MACRO extends boolean> extends CommandArguments {
106
109
  /**
@@ -109,30 +112,24 @@ export declare class DataModifyFromCommand<MACRO extends boolean> extends Comman
109
112
  * @param sourcePosition The coordinates of the block to modify the NBT with.
110
113
  * @param sourcePath The path of the NBT to modify with.
111
114
  */
112
- block: (sourcePosition: Macroable<Coordinates<MACRO>, MACRO>, sourcePath: Macroable<string, MACRO>) => import("../../index.js").FinalCommandOutput;
115
+ block: (sourcePosition: Macroable<Coordinates<MACRO>, MACRO>, sourcePath: Macroable<string, MACRO>) => FinalCommandOutput;
113
116
  /**
114
117
  * Modify with the NBT of a given entity.
115
118
  *
116
119
  * @param source The entity to modify the NBT with.
117
120
  * @param sourcePath The path of the NBT to modify with.
118
121
  */
119
- entity: <T extends string>(source: Macroable<SingleEntityArgumentOf<MACRO, T>, MACRO>, sourcePath: Macroable<string, MACRO>) => import("../../index.js").FinalCommandOutput;
120
- /**
121
- * Modify with the NBT of a given storage data point.
122
- *
123
- * @param source The storage data point to modify the NBT with.
124
- */
125
- storage(source: DataPointClass<'storage'>): void;
122
+ entity: <T extends string>(source: Macroable<SingleEntityArgumentOf<MACRO, T>, MACRO>, sourcePath: Macroable<string, MACRO>) => FinalCommandOutput;
126
123
  /**
127
124
  * Modify with the NBT of a given storage path.
128
125
  *
129
126
  * @param source The storage target to modify the NBT with.
130
127
  * @param sourcePath The path of the NBT to modify with.
131
128
  */
132
- storage(source: Macroable<string, MACRO>, sourcePath: Macroable<string, MACRO>): void;
129
+ storage: (source: Macroable<string, MACRO>, sourcePath: Macroable<string, MACRO>) => FinalCommandOutput;
133
130
  }
134
131
  export declare class DataModifyValuesCommand<MACRO extends boolean> extends CommandArguments {
135
- get from(): DataModifyFromCommand<MACRO>;
132
+ get from(): DataModifyFromCommand<MACRO> & ((dataPoint: DataPointClass<"entity"> | DataPointClass<"block"> | DataPointClass<"storage">) => FinalCommandOutput);
136
133
  string: {
137
134
  /**
138
135
  * Modify with the NBT String of a block at the given position.
@@ -165,7 +162,7 @@ export declare class DataModifyValuesCommand<MACRO extends boolean> extends Comm
165
162
  /**
166
163
  * Modify the NBT with the given value.
167
164
  */
168
- value: (value: Macroable<NBTObject, MACRO>) => import("../../index.js").FinalCommandOutput;
165
+ value: (value: Macroable<NBTObject, MACRO>) => FinalCommandOutput;
169
166
  }
170
167
  export declare class DataModifyTypeCommand<MACRO extends boolean> extends CommandArguments {
171
168
  /** Append the source data onto the end of the pointed-to list. */
@@ -213,19 +210,19 @@ export declare class DataRemoveCommand<MACRO extends boolean> extends CommandArg
213
210
  * @param targetPos The coordinates of the block to remove the NBT from.
214
211
  * @param path The path of the NBT to remove.
215
212
  */
216
- block: (targetPos: Macroable<Coordinates<MACRO>, MACRO>, targetPath: Macroable<string, MACRO>) => import("../../index.js").FinalCommandOutput;
213
+ block: (targetPos: Macroable<Coordinates<MACRO>, MACRO>, targetPath: Macroable<string, MACRO>) => FinalCommandOutput;
217
214
  /**
218
215
  * Remove the NBT of a given entity.
219
216
  *
220
217
  * @param target The entity to remove the NBT from.
221
218
  * @param path The path of the NBT to remove.
222
219
  */
223
- entity: <T extends string>(target: Macroable<SingleEntityArgumentOf<MACRO, T>, MACRO>, targetPath: Macroable<string, MACRO>) => import("../../index.js").FinalCommandOutput;
220
+ entity: <T extends string>(target: Macroable<SingleEntityArgumentOf<MACRO, T>, MACRO>, targetPath: Macroable<string, MACRO>) => FinalCommandOutput;
224
221
  /**
225
222
  * Remove the NBT from a given storage path.
226
223
  *
227
224
  * @param target The storage to remove the NBT from.
228
225
  * @param path The path of the NBT to remove.
229
226
  */
230
- storage: (target: Macroable<string, MACRO>, targetPath: Macroable<string, MACRO>) => import("../../index.js").FinalCommandOutput;
227
+ storage: (target: Macroable<string, MACRO>, targetPath: Macroable<string, MACRO>) => FinalCommandOutput;
231
228
  }