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.
- package/CLAUDE.md +315 -16
- package/bun.lock +18 -22
- package/dist/arguments/index.js +1093 -367
- package/dist/arguments/selector.d.ts +6 -6
- package/dist/commands/implementations/block/setblock.d.ts +6 -9
- package/dist/commands/implementations/entity/execute.d.ts +36 -21
- package/dist/commands/implementations/server/return.d.ts +14 -7
- package/dist/commands/implementations/world/data.d.ts +29 -32
- package/dist/commands/index.js +1102 -364
- package/dist/core/index.js +2207 -1481
- package/dist/core/resources/datapack/mcfunction.d.ts +1 -1
- package/dist/core/resources/datapack/variant.d.ts +1 -1
- package/dist/core/resources/resource.d.ts +4 -4
- package/dist/flow/Flow.d.ts +21 -22
- package/dist/flow/if_else.d.ts +8 -3
- package/dist/flow/index.d.ts +1 -0
- package/dist/flow/index.js +2196 -1451
- package/dist/flow/loop.d.ts +5 -4
- package/dist/flow/loops/for_i.d.ts +1 -1
- package/dist/flow/loops/for_of.d.ts +4 -3
- package/dist/flow/loops/staticAnalysis.d.ts +26 -0
- package/dist/flow/loops/while.d.ts +1 -1
- package/dist/flow/switch_case.d.ts +94 -12
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1093 -367
- package/dist/pack/index.js +1103 -364
- package/dist/pack/pack.d.ts +12 -12
- package/dist/pack/visitors/index.d.ts +1 -0
- package/dist/pack/visitors/loopTransformationVisitor.d.ts +13 -6
- package/dist/pack/visitors/simplifyExecuteFunction.d.ts +3 -2
- package/dist/pack/visitors/simplifyReturnRunFunction.d.ts +2 -1
- package/dist/pack/visitors/switchTransformationVisitor.d.ts +31 -0
- package/dist/pack/visitors/unifyChainedExecutes.d.ts +3 -2
- package/dist/pack/visitors/visitor.d.ts +5 -1
- package/dist/utils.d.ts +34 -3
- package/dist/variables/Data.d.ts +7 -5
- package/dist/variables/DataSets.d.ts +17 -14
- package/dist/variables/Label.d.ts +1 -0
- package/dist/variables/Loop.d.ts +10 -2
- package/dist/variables/ResolveNBT.d.ts +4 -3
- package/dist/variables/Score.d.ts +49 -3
- package/dist/variables/index.js +1066 -328
- package/package.json +1 -1
- package/src/arguments/selector.ts +12 -0
- package/src/commands/implementations/block/setblock.ts +8 -12
- package/src/commands/implementations/entity/damage.ts +2 -2
- package/src/commands/implementations/entity/execute.ts +103 -34
- package/src/commands/implementations/server/return.ts +15 -7
- package/src/commands/implementations/world/data.ts +96 -48
- package/src/core/Macro.ts +18 -1
- package/src/core/resources/datapack/advancement.ts +1 -1
- package/src/core/resources/datapack/bannerPattern.ts +1 -1
- package/src/core/resources/datapack/chatType.ts +1 -1
- package/src/core/resources/datapack/damageType.ts +1 -1
- package/src/core/resources/datapack/dialog.ts +1 -1
- package/src/core/resources/datapack/enchantment.ts +2 -2
- package/src/core/resources/datapack/gametest.ts +2 -2
- package/src/core/resources/datapack/instrument.ts +1 -1
- package/src/core/resources/datapack/itemModifier.ts +1 -1
- package/src/core/resources/datapack/jukeboxSong.ts +1 -1
- package/src/core/resources/datapack/lootTable.ts +1 -1
- package/src/core/resources/datapack/mcfunction.ts +36 -17
- package/src/core/resources/datapack/predicate.ts +1 -1
- package/src/core/resources/datapack/recipe.ts +1 -1
- package/src/core/resources/datapack/structure.ts +1 -1
- package/src/core/resources/datapack/tag.ts +4 -4
- package/src/core/resources/datapack/timeline.ts +2 -2
- package/src/core/resources/datapack/trialSpawner.ts +1 -1
- package/src/core/resources/datapack/trimMaterial.ts +1 -1
- package/src/core/resources/datapack/trimPattern.ts +1 -1
- package/src/core/resources/datapack/variant.ts +2 -2
- package/src/core/resources/datapack/villagerTrade.ts +2 -2
- package/src/core/resources/resource.ts +22 -11
- package/src/core/resources/resourcepack/atlas.ts +1 -1
- package/src/core/resources/resourcepack/blockstate.ts +1 -1
- package/src/core/resources/resourcepack/equipment.ts +1 -1
- package/src/core/resources/resourcepack/font.ts +1 -1
- package/src/core/resources/resourcepack/itemDefinition.ts +1 -1
- package/src/core/resources/resourcepack/language.ts +1 -1
- package/src/core/resources/resourcepack/model.ts +1 -1
- package/src/core/resources/resourcepack/particle.ts +1 -1
- package/src/core/resources/resourcepack/postEffect.ts +1 -1
- package/src/core/resources/resourcepack/shader.ts +1 -1
- package/src/core/resources/resourcepack/sound.ts +1 -1
- package/src/core/resources/resourcepack/waypointStyle.ts +1 -1
- package/src/core/sandstoneCore.ts +9 -1
- package/src/flow/Flow.ts +58 -94
- package/src/flow/conditions/command.ts +1 -1
- package/src/flow/conditions/variables/dataPoint.ts +2 -2
- package/src/flow/if_else.ts +14 -3
- package/src/flow/index.ts +1 -0
- package/src/flow/loop.ts +10 -6
- package/src/flow/loops/for_i.ts +21 -17
- package/src/flow/loops/for_of.ts +43 -36
- package/src/flow/loops/staticAnalysis.ts +114 -0
- package/src/flow/loops/while.ts +8 -5
- package/src/flow/switch_case.ts +214 -13
- package/src/index.ts +6 -1
- package/src/pack/pack.ts +24 -19
- package/src/pack/visitors/containerCommandsToMCFunction.ts +12 -5
- package/src/pack/visitors/ifElseTransformationVisitor.ts +44 -16
- package/src/pack/visitors/index.ts +1 -0
- package/src/pack/visitors/initConstantsVisitor.ts +13 -11
- package/src/pack/visitors/loopTransformationVisitor.ts +30 -7
- package/src/pack/visitors/simplifyExecuteFunction.ts +43 -6
- package/src/pack/visitors/simplifyReturnRunFunction.ts +40 -17
- package/src/pack/visitors/switchTransformationVisitor.ts +452 -0
- package/src/pack/visitors/unifyChainedExecutes.ts +9 -1
- package/src/pack/visitors/visitor.ts +9 -1
- package/src/utils.ts +53 -12
- package/src/variables/Data.ts +20 -4
- package/src/variables/DataSets.ts +57 -23
- package/src/variables/JSONTextComponentClass.ts +6 -1
- package/src/variables/Label.ts +0 -3
- package/src/variables/Loop.ts +30 -1
- package/src/variables/Objective.ts +0 -1
- package/src/variables/ResolveNBT.ts +5 -3
- package/src/variables/Score.ts +238 -8
- package/src/variables/Sleep.ts +2 -2
- package/src/variables/UUID.ts +8 -6
- package/src/variables/nbt/NBTs.ts +14 -0
|
@@ -62,7 +62,7 @@ export declare class MCFunctionNode extends ContainerNode implements ResourceNod
|
|
|
62
62
|
*/
|
|
63
63
|
exitContext: () => ContainerNode | ContainerCommandNode<unknown[]> | undefined;
|
|
64
64
|
getValue: () => string;
|
|
65
|
-
[util.inspect.custom](
|
|
65
|
+
[util.inspect.custom](_depth: number, options: any): string;
|
|
66
66
|
}
|
|
67
67
|
export type MCFunctionClassArguments = {
|
|
68
68
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type SymbolResource } from "../../../arguments/index.js";
|
|
2
2
|
import { ContainerNode } from "../../nodes.js";
|
|
3
3
|
import type { SandstoneCore } from "../../sandstoneCore.js";
|
|
4
4
|
import type { ResourceClassArguments, ResourceNode } from "../resource.js";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type fs from 'fs-extra';
|
|
2
2
|
import type { SandstoneCommands } from "../../commands/commands.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type Node, type SandstoneCore } from "../../core/index.js";
|
|
4
4
|
import type { ResourcePath, SandstonePack } from "../../pack/index.js";
|
|
5
5
|
import type { PackType } from "../../pack/packType.js";
|
|
6
6
|
import type { BASIC_CONFLICT_STRATEGIES, LiteralUnion, MakeInstanceCallable } from "../../utils.js";
|
|
7
7
|
import type { NBTSerializable } from "../../arguments/nbt.js";
|
|
8
|
+
import { RESOURCE_PATHS } from "../../arguments/index.js";
|
|
8
9
|
export type ResourceClassArguments<ConflictType extends 'default' | 'list' | 'function'> = {
|
|
9
10
|
/**
|
|
10
11
|
* Whether the associated Node should be added to Sandstone Core.
|
|
@@ -36,7 +37,7 @@ export type ResourceNode<T = ResourceClass<any>> = Node & {
|
|
|
36
37
|
export type ResourceNodeConstructor<N extends Node> = new (sandstoneCore: SandstoneCore, resource: any) => N;
|
|
37
38
|
export declare abstract class ResourceClass<N extends ResourceNode = ResourceNode<any>> implements NBTSerializable {
|
|
38
39
|
protected core: SandstoneCore;
|
|
39
|
-
|
|
40
|
+
readonly _resourceType: string;
|
|
40
41
|
node: N;
|
|
41
42
|
packType: PackType;
|
|
42
43
|
fileExtension: string;
|
|
@@ -59,7 +60,6 @@ export declare abstract class ResourceClass<N extends ResourceNode = ResourceNod
|
|
|
59
60
|
get namespace(): string;
|
|
60
61
|
generate: () => void;
|
|
61
62
|
toString(): string;
|
|
62
|
-
toNBT(): string;
|
|
63
63
|
}
|
|
64
64
|
export declare abstract class CallableResourceClass<N extends ResourceNode = ResourceNode<any>> extends ResourceClass<N> {
|
|
65
65
|
private _that;
|
|
@@ -91,4 +91,4 @@ export declare class ResourceNodesMap<T extends ResourceNode = ResourceNode> {
|
|
|
91
91
|
*/
|
|
92
92
|
get(node: T): T | undefined;
|
|
93
93
|
}
|
|
94
|
-
export declare function jsonStringify(json: any): string;
|
|
94
|
+
export declare function jsonStringify(json: any, resourceType: keyof typeof RESOURCE_PATHS): string;
|
package/dist/flow/Flow.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Registry, ContainerSlotSelector, Coordinates, EntitySlotSelector, JSONTextComponent, MultipleEntitiesArgument, MultiplePlayersArgument, NBTObject, SymbolBlock, SymbolMcdocBlockStates } from "../arguments/index.js";
|
|
2
2
|
import type { BlockEntity, BlockStatic, ParseBlockState } from "../commands/implementations/block/setblock.js";
|
|
3
|
-
import type { ConditionClass,
|
|
3
|
+
import type { ConditionClass, DataPointClass, IterableDataClass, JSONTextComponentClass, StringDataPointClass } from "../variables/index.js";
|
|
4
4
|
import { Score } from "../variables/index.js";
|
|
5
5
|
import type { DataPointPickClass, MCFunctionClass, PredicateClass, SandstoneCore } from "../core/index.js";
|
|
6
6
|
import type { LiteralUnion } from "../utils.js";
|
|
@@ -8,13 +8,13 @@ import { AndNode, ConditionNode, NotNode, OrNode, type BlockConditionNode, type
|
|
|
8
8
|
import type { ItemPredicate } from "./conditions/variables/items.js";
|
|
9
9
|
import { IfStatement } from "./if_else.js";
|
|
10
10
|
import { ForIStatement, ForOfStatement, WhileStatement } from "./loops/index.js";
|
|
11
|
-
import type { DefaultType } from "./switch_case.js";
|
|
11
|
+
import type { ConditionCallback, DefaultType, SwitchCase } from "./switch_case.js";
|
|
12
12
|
import { CaseStatement } from "./switch_case.js";
|
|
13
13
|
export type Condition = ConditionNode | ConditionClass;
|
|
14
|
+
export declare function conditionToNode(condition: Condition): ConditionNode;
|
|
14
15
|
export declare class Flow {
|
|
15
16
|
sandstoneCore: SandstoneCore;
|
|
16
17
|
constructor(sandstoneCore: SandstoneCore);
|
|
17
|
-
conditionToNode(condition: Condition): ConditionNode;
|
|
18
18
|
if: (condition: Condition, callback: () => void) => IfStatement;
|
|
19
19
|
and: (...conditions: Condition[]) => AndNode;
|
|
20
20
|
or: (...conditions: Condition[]) => OrNode;
|
|
@@ -39,9 +39,9 @@ export declare class Flow {
|
|
|
39
39
|
* @param broadcast Whether to scope the broadcast of the error (from `@a`) or disable it.
|
|
40
40
|
* @param dataPoint Disable storing to data point.
|
|
41
41
|
*
|
|
42
|
-
* @returns The full error text component
|
|
42
|
+
* @returns The full error text component.
|
|
43
43
|
*/
|
|
44
|
-
throw(error: JSONTextComponent | undefined, broadcast: MultiplePlayersArgument<false> | false | undefined, dataPoint: false):
|
|
44
|
+
throw(error: JSONTextComponent | undefined, broadcast: MultiplePlayersArgument<false> | false | undefined, dataPoint: false): JSONTextComponentClass;
|
|
45
45
|
/**
|
|
46
46
|
* Logs an error in data storage and chat by default and `return fail`'s from the context.
|
|
47
47
|
*
|
|
@@ -59,18 +59,13 @@ export declare class Flow {
|
|
|
59
59
|
start: number | Score,
|
|
60
60
|
end: number | Score
|
|
61
61
|
], type: 'iterate', callback: (iterator: Score, _continue: () => void) => any): ForIStatement;
|
|
62
|
-
for(
|
|
63
|
-
start: number | Score,
|
|
64
|
-
end: number | Score,
|
|
65
|
-
maximum?: number
|
|
66
|
-
], type: 'binary', callback: (num: number) => any): void;
|
|
67
|
-
for(type: 'entry', _: 'of', iterable: IterableDataClass, callback: (entry: DataPointClass) => any): ForOfStatement<'entry', [
|
|
62
|
+
for(type: 'entry', _: 'of' | 'of-reverse', iterable: IterableDataClass<'list' | 'map'>, callback: (entry: DataPointClass) => any): ForOfStatement<'entry', [
|
|
68
63
|
entry: DataPointClass
|
|
69
64
|
]>;
|
|
70
65
|
for(type: [
|
|
71
66
|
'key',
|
|
72
67
|
'value'
|
|
73
|
-
], _: 'of', iterable:
|
|
68
|
+
], _: 'of' | 'of-reverse', iterable: IterableDataClass<'map'>, callback: (key: StringDataPointClass, value: DataPointClass) => any): ForOfStatement<[
|
|
74
69
|
'key',
|
|
75
70
|
'value'
|
|
76
71
|
], [
|
|
@@ -80,23 +75,27 @@ export declare class Flow {
|
|
|
80
75
|
for(type: [
|
|
81
76
|
'i',
|
|
82
77
|
'entry'
|
|
83
|
-
], _: 'of', iterable:
|
|
78
|
+
], _: 'of' | 'of-reverse', iterable: IterableDataClass<'list' | 'map'>, callback: (i: Score, entry: DataPointClass) => any): ForOfStatement<[
|
|
84
79
|
'i',
|
|
85
80
|
'entry'
|
|
86
81
|
], [
|
|
87
82
|
i: Score,
|
|
88
83
|
entry: DataPointClass
|
|
89
84
|
]>;
|
|
90
|
-
switch<ValueType extends DataPointClass | DataPointPickClass | Score, CheckType extends ValueType extends Score ? number : NBTObject>(value: ValueType, cases: CaseStatement<CheckType> | DefaultType<CheckType>): void;
|
|
91
|
-
switch<ValueType extends DataPointClass | DataPointPickClass | Score, CheckType extends ValueType extends Score ? number : NBTObject>(value: ValueType, cases: [
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
() => any
|
|
85
|
+
switch<ValueType extends DataPointClass | DataPointPickClass | Score, CheckType extends ValueType extends Score ? number : NBTObject>(value: ValueType, cases: CaseStatement<CheckType, ValueType> | DefaultType<CheckType, ValueType>): void;
|
|
86
|
+
switch<ValueType extends DataPointClass | DataPointPickClass | Score, CheckType extends ValueType extends Score ? number : NBTObject>(value: ValueType, cases: SwitchCase<ValueType, CheckType>[] | [
|
|
87
|
+
...SwitchCase<ValueType, CheckType>[],
|
|
88
|
+
[
|
|
89
|
+
'default',
|
|
90
|
+
() => any
|
|
91
|
+
]
|
|
98
92
|
]): void;
|
|
99
|
-
|
|
93
|
+
/** Create a static value case for switch statements */
|
|
94
|
+
case(value: number, callback: () => any): CaseStatement<number>;
|
|
95
|
+
/** Create a static value case for switch statements */
|
|
96
|
+
case(value: NBTObject, callback: () => any): CaseStatement<NBTObject>;
|
|
97
|
+
/** Create a condition case for switch statements - checked after static cases fail */
|
|
98
|
+
case<SwitchValueType>(condition: ConditionCallback<SwitchValueType>, callback: () => any): CaseStatement<never, SwitchValueType>;
|
|
100
99
|
/**
|
|
101
100
|
* Checks for a specific biome in a given position.
|
|
102
101
|
* @param coordinates Position to test.
|
package/dist/flow/if_else.d.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import * as util from 'util';
|
|
2
|
-
import type { SandstoneCore } from "../core/index.js";
|
|
2
|
+
import type { MCFunctionNode, SandstoneCore } from "../core/index.js";
|
|
3
3
|
import { ContainerNode } from "../core/index.js";
|
|
4
4
|
import type { ConditionNode } from "./conditions/index.js";
|
|
5
|
-
import type
|
|
5
|
+
import { type Condition } from "./Flow.js";
|
|
6
6
|
export declare class IfNode extends ContainerNode {
|
|
7
7
|
condition: ConditionNode;
|
|
8
8
|
callback?: (() => void) | undefined;
|
|
9
9
|
nextFlowNode?: IfNode | ElseNode;
|
|
10
10
|
_isElseIf: boolean;
|
|
11
|
-
|
|
11
|
+
parentMCFunction: MCFunctionNode;
|
|
12
|
+
/** Optional callback name override (e.g., 'loop' for loop transformations) */
|
|
13
|
+
givenCallbackName?: string;
|
|
14
|
+
/** Set by IfElseTransformationVisitor to the resulting ExecuteCommandNode */
|
|
15
|
+
resultingExecuteNode?: import("../commands/index.js").ExecuteCommandNode;
|
|
16
|
+
constructor(sandstoneCore: SandstoneCore, condition: ConditionNode, callback?: (() => void) | undefined, parentMCFunction?: MCFunctionNode);
|
|
12
17
|
getValue: () => never;
|
|
13
18
|
[util.inspect.custom](depth: number, options: any): string;
|
|
14
19
|
}
|
package/dist/flow/index.d.ts
CHANGED