sandstone 1.1.3 → 1.1.5
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/dist/_internal/index.d.ts +7 -15
- package/dist/_internal/index.d.ts.map +1 -1
- package/dist/_internal/index.js +227 -75
- package/dist/_internal/index.js.map +1 -1
- package/dist/_internal/types/arguments/generated/resources.d.ts +2 -2
- package/dist/_internal/types/arguments/generated/resources.d.ts.map +1 -1
- package/dist/_internal/types/commands/implementations/block/place.d.ts +1 -1
- package/dist/_internal/types/commands/implementations/block/place.d.ts.map +1 -1
- package/dist/_internal/types/commands/implementations/server/schedule.d.ts +1 -1
- package/dist/_internal/types/core/resources/index.d.ts +1 -1
- package/dist/_internal/types/core/resources/resourcepack/blockstate.d.ts +13 -13
- package/dist/_internal/types/core/resources/resourcepack/blockstate.d.ts.map +1 -1
- package/dist/_internal/types/flow/Flow.d.ts +27 -13
- package/dist/_internal/types/flow/Flow.d.ts.map +1 -1
- package/dist/_internal/types/flow/conditions/command.d.ts.map +1 -1
- package/dist/_internal/types/flow/conditions/condition.d.ts +8 -0
- package/dist/_internal/types/flow/conditions/condition.d.ts.map +1 -1
- package/dist/_internal/types/flow/conditions/variables/dataPoint.d.ts.map +1 -1
- package/dist/_internal/types/flow/loop.d.ts +1 -1
- package/dist/_internal/types/pack/index.d.ts +1 -1
- package/dist/_internal/types/pack/pack.d.ts +7 -7
- package/dist/_internal/types/pack/pack.d.ts.map +1 -1
- package/dist/_internal/types/pack/visitors/orTransformationVisitor.d.ts +41 -6
- package/dist/_internal/types/pack/visitors/orTransformationVisitor.d.ts.map +1 -1
- package/dist/_internal/types/variables/Data.d.ts +1 -1
- package/dist/_internal/types/variables/DataSets.d.ts +4 -4
- package/dist/_internal/types/variables/DataSets.d.ts.map +1 -1
- package/dist/_internal/types/variables/ResolveNBT.d.ts +2 -2
- package/dist/_internal/types/variables/abstractClasses.d.ts +9 -0
- package/dist/_internal/types/variables/abstractClasses.d.ts.map +1 -1
- package/dist/browser/sandstone.esm.js +227 -75
- package/dist/browser/sandstone.esm.js.map +1 -1
- package/dist/exports/core/index.d.ts +1 -1
- package/dist/exports/core/index.js +1 -1
- package/dist/exports/index.d.ts +1 -1
- package/dist/exports/index.js +1 -1
- package/dist/exports/variables/index.d.ts +1 -1
- package/dist/exports/variables/index.js +1 -1
- package/package.json +3 -3
- package/src/arguments/generated/resources.ts +2 -2
- package/src/commands/implementations/block/place.ts +1 -1
- package/src/core/resources/datapack/itemModifier.ts +2 -2
- package/src/core/resources/resourcepack/blockstate.ts +32 -32
- package/src/flow/Flow.ts +24 -4
- package/src/flow/conditions/command.ts +7 -0
- package/src/flow/conditions/condition.ts +9 -0
- package/src/flow/conditions/variables/dataPoint.ts +11 -3
- package/src/pack/pack.ts +19 -38
- package/src/pack/visitors/orTransformationVisitor.ts +311 -37
- package/src/sandstone.ts +4 -20
- package/src/variables/DataSets.ts +4 -4
- package/src/variables/abstractClasses.ts +10 -0
- package/src/core/resources/datapack/decoratedPotPattern.ts.disable +0 -47
- package/src/core/resources/datapack/slotSource.ts.disable +0 -47
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Node } from '../core/index.js';
|
|
1
2
|
import type { NBTSerializable } from '../arguments/index.js';
|
|
2
3
|
export declare class TextComponentClass {
|
|
3
4
|
/**
|
|
@@ -12,6 +13,14 @@ export declare class ConditionClass {
|
|
|
12
13
|
* (and subclasses). Does not exist at runtime.
|
|
13
14
|
*/
|
|
14
15
|
readonly __conditionClassBrand: true;
|
|
16
|
+
/**
|
|
17
|
+
* Optional commands that must run before this condition's predicate is evaluated.
|
|
18
|
+
* Conditions that emit side-effect commands at construction (e.g. `data.equals`
|
|
19
|
+
* building `execute store result ...`) capture them here so the visitor pass can
|
|
20
|
+
* re-emit them at the right location — inline before the IfNode, or inside the
|
|
21
|
+
* child MCFunction when AND/OR extracts. Optional; pure predicates leave it unset.
|
|
22
|
+
*/
|
|
23
|
+
preNodes?: Node[];
|
|
15
24
|
}
|
|
16
25
|
export declare class SelectorPickClass<IsSingle extends boolean, IsPlayer extends boolean> implements NBTSerializable, TextComponentClass {
|
|
17
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstractClasses.d.ts","sourceRoot":"","sources":["../../../../src/variables/abstractClasses.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"abstractClasses.d.ts","sourceRoot":"","sources":["../../../../src/variables/abstractClasses.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAG1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE1D,qBAAa,kBAAkB;IAC7B;;;OAGG;IACH,SAAiB,yBAAyB,EAAE,IAAI,CAAA;CAQjD;AACD,qBAAa,cAAc;IACzB;;;OAGG;IACH,SAAiB,qBAAqB,EAAE,IAAI,CAAA;IAE5C;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAA;CAQlB;AAED,qBAAa,iBAAiB,CAAC,QAAQ,SAAS,OAAO,EAAE,QAAQ,SAAS,OAAO,CAAE,YAAW,eAAe,EAAE,kBAAkB;IAC/H;;;OAGG;IACH,SAAiB,mBAAmB,EAAE;QAAE,MAAM,EAAE,QAAQ,CAAC;QAAC,MAAM,EAAE,QAAQ,CAAA;KAAE,CAAA;IAE5E;;;OAGG;IACH,SAAiB,yBAAyB,EAAE,IAAI,CAAA;CAoBjD;AAED,qBAAa,2BAA4B,SAAQ,kBAAmB,YAAW,cAAc;IAC3F;;;OAGG;IACH,SAAiB,yBAAyB,EAAE,IAAI,CAAA;IAEhD;;;OAGG;IACH,SAAiB,qBAAqB,EAAE,IAAI,CAAA;CAe7C"}
|
|
@@ -2538,68 +2538,68 @@ AtlasClass = class AtlasClass extends ResourceClass {
|
|
|
2538
2538
|
}
|
|
2539
2539
|
}
|
|
2540
2540
|
};
|
|
2541
|
-
|
|
2541
|
+
BlockStateDefinitionNode = class BlockStateDefinitionNode extends ContainerNode {
|
|
2542
2542
|
resource;
|
|
2543
2543
|
constructor(sandstoneCore, resource) {
|
|
2544
2544
|
super(sandstoneCore);
|
|
2545
2545
|
this.resource = resource;
|
|
2546
2546
|
}
|
|
2547
|
-
getValue = () => jsonStringify(this.resource.
|
|
2547
|
+
getValue = () => jsonStringify(this.resource.blockStateDefinitionJSON, this.resource._resourceType);
|
|
2548
2548
|
};
|
|
2549
|
-
|
|
2549
|
+
BlockStateDefinitionClass = class BlockStateDefinitionClass extends ResourceClass {
|
|
2550
2550
|
static resourceType = "block_definition";
|
|
2551
|
-
|
|
2551
|
+
blockStateDefinitionJSON;
|
|
2552
2552
|
type;
|
|
2553
2553
|
constructor(core, name, args) {
|
|
2554
|
-
super(core, { packType: core.pack.resourcePack() },
|
|
2555
|
-
this.
|
|
2556
|
-
this.type = Object.keys(this.
|
|
2554
|
+
super(core, { packType: core.pack.resourcePack() }, BlockStateDefinitionNode, BlockStateDefinitionClass.resourceType, core.pack.resourceToPath(name, RESOURCE_PATHS[BlockStateDefinitionClass.resourceType].path), args);
|
|
2555
|
+
this.blockStateDefinitionJSON = args.json;
|
|
2556
|
+
this.type = Object.keys(this.blockStateDefinitionJSON)[0];
|
|
2557
2557
|
this.handleConflicts();
|
|
2558
2558
|
}
|
|
2559
2559
|
push(...states) {
|
|
2560
2560
|
if (this.type === "variants") {
|
|
2561
|
-
if (states[0] instanceof
|
|
2561
|
+
if (states[0] instanceof BlockStateDefinitionClass) {
|
|
2562
2562
|
for (const state of states) {
|
|
2563
|
-
this.
|
|
2563
|
+
this.blockStateDefinitionJSON.variants = { ...this.blockStateDefinitionJSON.variants, ...state.blockStateDefinitionJSON.variants };
|
|
2564
2564
|
}
|
|
2565
2565
|
} else {
|
|
2566
2566
|
for (const state of states) {
|
|
2567
|
-
this.
|
|
2567
|
+
this.blockStateDefinitionJSON.variants = { ...this.blockStateDefinitionJSON.variants, ...state.variants };
|
|
2568
2568
|
}
|
|
2569
2569
|
}
|
|
2570
2570
|
}
|
|
2571
2571
|
if (this.type === "multipart") {
|
|
2572
|
-
if (states[0] instanceof
|
|
2572
|
+
if (states[0] instanceof BlockStateDefinitionClass) {
|
|
2573
2573
|
for (const state of states) {
|
|
2574
|
-
this.
|
|
2574
|
+
this.blockStateDefinitionJSON.multipart.push(...state.blockStateDefinitionJSON.multipart);
|
|
2575
2575
|
}
|
|
2576
2576
|
} else {
|
|
2577
2577
|
for (const state of states) {
|
|
2578
|
-
this.
|
|
2578
|
+
this.blockStateDefinitionJSON.multipart.push(...state.multipart);
|
|
2579
2579
|
}
|
|
2580
2580
|
}
|
|
2581
2581
|
}
|
|
2582
2582
|
}
|
|
2583
2583
|
unshift(...states) {
|
|
2584
2584
|
if (this.type === "variants") {
|
|
2585
|
-
if (states[0] instanceof
|
|
2585
|
+
if (states[0] instanceof BlockStateDefinitionClass) {
|
|
2586
2586
|
for (const state of states) {
|
|
2587
|
-
this.
|
|
2587
|
+
this.blockStateDefinitionJSON.variants = { ...state.blockStateDefinitionJSON.variants, ...this.blockStateDefinitionJSON.variants };
|
|
2588
2588
|
}
|
|
2589
2589
|
} else {
|
|
2590
2590
|
for (const state of states) {
|
|
2591
|
-
this.
|
|
2591
|
+
this.blockStateDefinitionJSON.variants = { ...state.variants, ...this.blockStateDefinitionJSON.variants };
|
|
2592
2592
|
}
|
|
2593
2593
|
}
|
|
2594
2594
|
}
|
|
2595
2595
|
if (this.type === "multipart") {
|
|
2596
|
-
if (states[0] instanceof
|
|
2596
|
+
if (states[0] instanceof BlockStateDefinitionClass) {
|
|
2597
2597
|
for (const state of states) {
|
|
2598
|
-
this.
|
|
2598
|
+
this.blockStateDefinitionJSON.multipart.unshift(...state.blockStateDefinitionJSON.multipart);
|
|
2599
2599
|
}
|
|
2600
2600
|
} else {
|
|
2601
2601
|
for (const state of states) {
|
|
2602
|
-
this.
|
|
2602
|
+
this.blockStateDefinitionJSON.multipart.unshift(...state.multipart);
|
|
2603
2603
|
}
|
|
2604
2604
|
}
|
|
2605
2605
|
}
|
|
@@ -4438,6 +4438,7 @@ WorldBorderCommand = class WorldBorderCommand extends CommandArguments {
|
|
|
4438
4438
|
};
|
|
4439
4439
|
};
|
|
4440
4440
|
ConditionNode = class ConditionNode extends Node {
|
|
4441
|
+
preNodes;
|
|
4441
4442
|
};
|
|
4442
4443
|
SingleConditionNode = class SingleConditionNode extends ConditionNode {
|
|
4443
4444
|
getValue = (negated = false) => {
|
|
@@ -4594,9 +4595,13 @@ DataPointEqualsConditionNode = class DataPointEqualsConditionNode extends Single
|
|
|
4594
4595
|
this.value = value2;
|
|
4595
4596
|
const { DataVariable, Variable, commands: commands2 } = sandstoneCore2.pack;
|
|
4596
4597
|
const { execute: execute2 } = commands2;
|
|
4598
|
+
const mcFunction = sandstoneCore2.getCurrentMCFunctionOrThrow();
|
|
4599
|
+
const before = mcFunction.body.length;
|
|
4597
4600
|
const anon = DataVariable(this.dataPoint);
|
|
4598
4601
|
this.conditional = Variable();
|
|
4599
4602
|
execute2.store.result(this.conditional).run(() => anon.set(this.value));
|
|
4603
|
+
const after = mcFunction.body.length;
|
|
4604
|
+
this.preNodes = mcFunction.body.splice(before, after - before);
|
|
4600
4605
|
}
|
|
4601
4606
|
getValue = (negated) => (negated ? ["if", ...this.getCondition()] : ["unless", ...this.getCondition()]).join(" ");
|
|
4602
4607
|
getCondition() {
|
|
@@ -4661,7 +4666,11 @@ CommandConditionNode = class CommandConditionNode extends SingleConditionNode {
|
|
|
4661
4666
|
this.result = result;
|
|
4662
4667
|
const store = sandstoneCore2.pack.commands.execute.store[type4];
|
|
4663
4668
|
this.variable = sandstoneCore2.pack.Variable(undefined, "condition");
|
|
4669
|
+
const mcFunction = sandstoneCore2.getCurrentMCFunctionOrThrow();
|
|
4670
|
+
const before = mcFunction.body.length;
|
|
4664
4671
|
command(store(this.variable));
|
|
4672
|
+
const after = mcFunction.body.length;
|
|
4673
|
+
this.preNodes = mcFunction.body.splice(before, after - before);
|
|
4665
4674
|
}
|
|
4666
4675
|
getCondition() {
|
|
4667
4676
|
if (this.type === "success") {
|
|
@@ -5158,54 +5167,186 @@ LoopTransformationVisitor = class LoopTransformationVisitor extends GenericSands
|
|
|
5158
5167
|
visitForINode = this.visitLoopNode;
|
|
5159
5168
|
visitForOfNode = this.visitLoopNode;
|
|
5160
5169
|
};
|
|
5170
|
+
FunctionReturnConditionNode = class FunctionReturnConditionNode extends ConditionNode {
|
|
5171
|
+
sandstoneCore;
|
|
5172
|
+
functionName;
|
|
5173
|
+
constructor(sandstoneCore2, functionName) {
|
|
5174
|
+
super(sandstoneCore2);
|
|
5175
|
+
this.sandstoneCore = sandstoneCore2;
|
|
5176
|
+
this.functionName = functionName;
|
|
5177
|
+
}
|
|
5178
|
+
getValue = () => `if function ${this.functionName}`;
|
|
5179
|
+
};
|
|
5161
5180
|
OrTransformationVisitor = class OrTransformationVisitor extends GenericSandstoneVisitor {
|
|
5162
5181
|
visitIfNode = (node_) => {
|
|
5163
|
-
const { preNodes, conditionNode } = this.parseConditionNode(node_.condition);
|
|
5182
|
+
const { preNodes, conditionNode } = this.parseConditionNode(node_.condition, node_.parentMCFunction);
|
|
5164
5183
|
node_.condition = conditionNode;
|
|
5165
5184
|
return [...preNodes, this.genericVisit(node_)];
|
|
5166
5185
|
};
|
|
5167
|
-
parseConditionNode = (node) => {
|
|
5186
|
+
parseConditionNode = (node, parentMCFunction) => {
|
|
5168
5187
|
if (node instanceof OrNode) {
|
|
5169
|
-
return this.parseOrNode(node);
|
|
5188
|
+
return this.parseOrNode(node, parentMCFunction);
|
|
5170
5189
|
}
|
|
5171
5190
|
if (node instanceof AndNode) {
|
|
5172
|
-
return this.parseAndNode(node);
|
|
5191
|
+
return this.parseAndNode(node, parentMCFunction);
|
|
5173
5192
|
}
|
|
5174
5193
|
if (node instanceof NotNode) {
|
|
5175
|
-
return this.parseNotNode(node);
|
|
5194
|
+
return this.parseNotNode(node, parentMCFunction);
|
|
5176
5195
|
}
|
|
5177
|
-
return { preNodes: [], conditionNode: node };
|
|
5196
|
+
return { preNodes: [...node.preNodes ?? []], conditionNode: node };
|
|
5178
5197
|
};
|
|
5179
|
-
parseOrNode = (node) => {
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
const
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
return ifNode;
|
|
5198
|
+
parseOrNode = (node, parentMCFunction) => {
|
|
5199
|
+
if (node.conditions.length === 1) {
|
|
5200
|
+
return this.parseConditionNode(node.conditions[0], parentMCFunction);
|
|
5201
|
+
}
|
|
5202
|
+
const parentName = parentMCFunction?.resource.name ?? "__sandstone";
|
|
5203
|
+
const orMCFunction = new MCFunctionClass(this.core, `${parentName}/or_check`, {
|
|
5204
|
+
addToSandstoneCore: true,
|
|
5205
|
+
creator: "sandstone",
|
|
5206
|
+
onConflict: "rename"
|
|
5189
5207
|
});
|
|
5208
|
+
this.core.enterMCFunction(orMCFunction);
|
|
5209
|
+
try {
|
|
5210
|
+
for (const condition2 of node.conditions) {
|
|
5211
|
+
this.pushCheckBranch(orMCFunction.node, this.parseConditionNode(condition2, orMCFunction.node), false, new ReturnCommandNode(this.pack, [1]));
|
|
5212
|
+
}
|
|
5213
|
+
orMCFunction.node.body.push(new ReturnCommandNode(this.pack, [0]));
|
|
5214
|
+
} finally {
|
|
5215
|
+
this.core.exitMCFunction();
|
|
5216
|
+
}
|
|
5190
5217
|
return {
|
|
5191
|
-
preNodes: [
|
|
5192
|
-
conditionNode
|
|
5218
|
+
preNodes: [],
|
|
5219
|
+
conditionNode: new FunctionReturnConditionNode(this.core, orMCFunction.name)
|
|
5193
5220
|
};
|
|
5194
5221
|
};
|
|
5195
|
-
parseAndNode = (node) => {
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5222
|
+
parseAndNode = (node, parentMCFunction) => {
|
|
5223
|
+
if (node.conditions.length === 1) {
|
|
5224
|
+
return this.parseConditionNode(node.conditions[0], parentMCFunction);
|
|
5225
|
+
}
|
|
5226
|
+
const parsed = node.conditions.map((condition2) => this.parseConditionNode(condition2, parentMCFunction));
|
|
5227
|
+
const anyHasCommands = parsed.some((p) => (p.preNodes ?? []).length > 0);
|
|
5228
|
+
if (!anyHasCommands) {
|
|
5229
|
+
const finalPreNodes = [];
|
|
5230
|
+
const conditionNode = new AndNode(node.sandstoneCore, parsed.map((p) => {
|
|
5231
|
+
finalPreNodes.push(...p.preNodes);
|
|
5232
|
+
return p.conditionNode;
|
|
5233
|
+
}));
|
|
5234
|
+
return { preNodes: finalPreNodes, conditionNode };
|
|
5235
|
+
}
|
|
5236
|
+
const parentName = parentMCFunction?.resource.name ?? "__sandstone";
|
|
5237
|
+
const andMCFunction = new MCFunctionClass(this.core, `${parentName}/and_check`, {
|
|
5238
|
+
addToSandstoneCore: true,
|
|
5239
|
+
creator: "sandstone",
|
|
5240
|
+
onConflict: "rename"
|
|
5241
|
+
});
|
|
5242
|
+
this.core.enterMCFunction(andMCFunction);
|
|
5243
|
+
try {
|
|
5244
|
+
let batch = { preNodes: [], conditionNodes: [] };
|
|
5245
|
+
const flushBatch = () => {
|
|
5246
|
+
if (batch.conditionNodes.length === 0 && batch.preNodes.every((pn) => pn.length === 0)) {
|
|
5247
|
+
batch = { preNodes: [], conditionNodes: [] };
|
|
5248
|
+
return;
|
|
5249
|
+
}
|
|
5250
|
+
const tracker = this.core.pack.Variable(undefined, "and_batch");
|
|
5251
|
+
this.pushBatchedCheckBranch(andMCFunction.node, batch.preNodes.flat(), batch.conditionNodes, tracker);
|
|
5252
|
+
batch = { preNodes: [], conditionNodes: [] };
|
|
5253
|
+
};
|
|
5254
|
+
for (const p of parsed) {
|
|
5255
|
+
if (p.preNodes.length === 0) {
|
|
5256
|
+
batch.preNodes.push(p.preNodes);
|
|
5257
|
+
batch.conditionNodes.push(p.conditionNode);
|
|
5258
|
+
} else {
|
|
5259
|
+
flushBatch();
|
|
5260
|
+
this.pushFailFastBranch(andMCFunction.node, p, new ReturnCommandNode(this.pack, [0]));
|
|
5261
|
+
}
|
|
5262
|
+
}
|
|
5263
|
+
flushBatch();
|
|
5264
|
+
andMCFunction.node.body.push(new ReturnCommandNode(this.pack, [1]));
|
|
5265
|
+
} finally {
|
|
5266
|
+
this.core.exitMCFunction();
|
|
5267
|
+
}
|
|
5202
5268
|
return {
|
|
5203
|
-
preNodes:
|
|
5204
|
-
conditionNode
|
|
5269
|
+
preNodes: [],
|
|
5270
|
+
conditionNode: new FunctionReturnConditionNode(this.core, andMCFunction.name)
|
|
5205
5271
|
};
|
|
5206
5272
|
};
|
|
5207
|
-
|
|
5208
|
-
const
|
|
5273
|
+
pushBatchedCheckBranch = (targetMCFunction, preNodes, conditionNodes, tracker) => {
|
|
5274
|
+
for (const n of preNodes) {
|
|
5275
|
+
targetMCFunction.body.push(n);
|
|
5276
|
+
}
|
|
5277
|
+
targetMCFunction.body.push(new ScoreboardCommandNode(this.pack, "players", "reset", tracker));
|
|
5278
|
+
const args = [];
|
|
5279
|
+
for (const c of conditionNodes) {
|
|
5280
|
+
const condStr = c.getValue(false);
|
|
5281
|
+
const match = condStr.match(/^(if|unless)\s+([\s\S]+)$/);
|
|
5282
|
+
if (!match) {
|
|
5283
|
+
throw new Error(`OrTransformationVisitor: unexpected condition getValue() shape: ${condStr}`);
|
|
5284
|
+
}
|
|
5285
|
+
const [, keyword, condBody] = match;
|
|
5286
|
+
args.push([keyword, condBody]);
|
|
5287
|
+
}
|
|
5288
|
+
if (args.length === 0) {
|
|
5289
|
+
targetMCFunction.body.push(new ScoreboardCommandNode(this.pack, "players", "set", tracker, 1));
|
|
5290
|
+
} else {
|
|
5291
|
+
const executeNode = new ExecuteCommandNode(this.pack, args, {
|
|
5292
|
+
isSingleExecute: true,
|
|
5293
|
+
body: []
|
|
5294
|
+
});
|
|
5295
|
+
targetMCFunction.enterContext(executeNode, false);
|
|
5296
|
+
executeNode.body = [new ScoreboardCommandNode(this.pack, "players", "set", tracker, 1)];
|
|
5297
|
+
targetMCFunction.body.push(executeNode);
|
|
5298
|
+
targetMCFunction.exitContext();
|
|
5299
|
+
}
|
|
5300
|
+
const failCheckNode = new ExecuteCommandNode(this.pack, [["unless", `score ${tracker} matches 1`]], {
|
|
5301
|
+
isSingleExecute: true,
|
|
5302
|
+
body: []
|
|
5303
|
+
});
|
|
5304
|
+
targetMCFunction.enterContext(failCheckNode, false);
|
|
5305
|
+
failCheckNode.body = [new ReturnCommandNode(this.pack, [0])];
|
|
5306
|
+
targetMCFunction.body.push(failCheckNode);
|
|
5307
|
+
targetMCFunction.exitContext();
|
|
5308
|
+
};
|
|
5309
|
+
pushCheckBranch = (targetMCFunction, parsed, negated, bodyNode) => {
|
|
5310
|
+
for (const n of parsed.preNodes) {
|
|
5311
|
+
targetMCFunction.body.push(n);
|
|
5312
|
+
}
|
|
5313
|
+
const condStr = parsed.conditionNode.getValue(negated);
|
|
5314
|
+
const match = condStr.match(/^(if|unless)\s+([\s\S]+)$/);
|
|
5315
|
+
if (!match) {
|
|
5316
|
+
throw new Error(`OrTransformationVisitor: unexpected condition getValue() shape: ${condStr}`);
|
|
5317
|
+
}
|
|
5318
|
+
const [, keyword, condBody] = match;
|
|
5319
|
+
const executeNode = new ExecuteCommandNode(this.pack, [[keyword, condBody]], {
|
|
5320
|
+
isSingleExecute: true,
|
|
5321
|
+
body: []
|
|
5322
|
+
});
|
|
5323
|
+
targetMCFunction.enterContext(executeNode, false);
|
|
5324
|
+
executeNode.body = [bodyNode];
|
|
5325
|
+
targetMCFunction.body.push(executeNode);
|
|
5326
|
+
targetMCFunction.exitContext();
|
|
5327
|
+
};
|
|
5328
|
+
pushFailFastBranch = (targetMCFunction, parsed, bodyNode) => {
|
|
5329
|
+
for (const n of parsed.preNodes) {
|
|
5330
|
+
targetMCFunction.body.push(n);
|
|
5331
|
+
}
|
|
5332
|
+
const condStr = parsed.conditionNode.getValue(true);
|
|
5333
|
+
const match = condStr.match(/^(if|unless)\s+([\s\S]+)$/);
|
|
5334
|
+
if (!match) {
|
|
5335
|
+
throw new Error(`OrTransformationVisitor: unexpected condition getValue() shape: ${condStr}`);
|
|
5336
|
+
}
|
|
5337
|
+
const flippedKeyword = match[1] === "if" ? "unless" : "if";
|
|
5338
|
+
const condBody = match[2];
|
|
5339
|
+
const executeNode = new ExecuteCommandNode(this.pack, [[flippedKeyword, condBody]], {
|
|
5340
|
+
isSingleExecute: true,
|
|
5341
|
+
body: []
|
|
5342
|
+
});
|
|
5343
|
+
targetMCFunction.enterContext(executeNode, false);
|
|
5344
|
+
executeNode.body = [bodyNode];
|
|
5345
|
+
targetMCFunction.body.push(executeNode);
|
|
5346
|
+
targetMCFunction.exitContext();
|
|
5347
|
+
};
|
|
5348
|
+
parseNotNode = (node, parentMCFunction) => {
|
|
5349
|
+
const { preNodes, conditionNode } = this.parseConditionNode(node.condition, parentMCFunction);
|
|
5209
5350
|
return {
|
|
5210
5351
|
preNodes,
|
|
5211
5352
|
conditionNode: new NotNode(node.sandstoneCore, conditionNode)
|
|
@@ -6459,6 +6600,7 @@ SleepClass = class SleepClass extends AwaitNode {
|
|
|
6459
6600
|
// src/variables/abstractClasses.ts
|
|
6460
6601
|
|
|
6461
6602
|
class ConditionClass {
|
|
6603
|
+
preNodes;
|
|
6462
6604
|
_toMinecraftCondition() {
|
|
6463
6605
|
throw new Error("Not implemented");
|
|
6464
6606
|
}
|
|
@@ -17564,7 +17706,7 @@ var init_atlas = __esm(() => {
|
|
|
17564
17706
|
});
|
|
17565
17707
|
|
|
17566
17708
|
// src/core/resources/resourcepack/blockstate.ts
|
|
17567
|
-
var
|
|
17709
|
+
var BlockStateDefinitionNode, BlockStateDefinitionClass;
|
|
17568
17710
|
var init_blockstate = __esm(() => {
|
|
17569
17711
|
init_arguments();
|
|
17570
17712
|
init_nodes();
|
|
@@ -19661,8 +19803,14 @@ class Flow {
|
|
|
19661
19803
|
this.sandstoneCore = sandstoneCore2;
|
|
19662
19804
|
}
|
|
19663
19805
|
if = (condition2, callback) => new IfStatement(this.sandstoneCore, conditionToNode(condition2), callback);
|
|
19664
|
-
and
|
|
19665
|
-
|
|
19806
|
+
and(...args) {
|
|
19807
|
+
const conditions = args[0] instanceof Array ? args[0] : args;
|
|
19808
|
+
return new AndNode(this.sandstoneCore, conditions.map((condition2) => conditionToNode(condition2)));
|
|
19809
|
+
}
|
|
19810
|
+
or(...args) {
|
|
19811
|
+
const conditions = args[0] instanceof Array ? args[0] : args;
|
|
19812
|
+
return new OrNode(this.sandstoneCore, conditions.map((condition2) => conditionToNode(condition2)));
|
|
19813
|
+
}
|
|
19666
19814
|
not = (condition2) => new NotNode(this.sandstoneCore, conditionToNode(condition2));
|
|
19667
19815
|
get return() {
|
|
19668
19816
|
return this.sandstoneCore.pack.commands.returnCmd;
|
|
@@ -19922,12 +20070,13 @@ var init_loopTransformationVisitor = __esm(() => {
|
|
|
19922
20070
|
});
|
|
19923
20071
|
|
|
19924
20072
|
// src/pack/visitors/orTransformationVisitor.ts
|
|
19925
|
-
var OrTransformationVisitor;
|
|
20073
|
+
var FunctionReturnConditionNode, OrTransformationVisitor;
|
|
19926
20074
|
var init_orTransformationVisitor = __esm(() => {
|
|
19927
20075
|
init_commands2();
|
|
20076
|
+
init_core();
|
|
19928
20077
|
init_flow();
|
|
19929
20078
|
init_visitor();
|
|
19930
|
-
|
|
20079
|
+
});
|
|
19931
20080
|
|
|
19932
20081
|
// src/pack/visitors/optimizeMacroTemporaries.ts
|
|
19933
20082
|
var flattenArgs = (args) => args.flatMap((arg) => Array.isArray(arg) ? flattenArgs(arg) : [arg]), referencesStoragePoint = (node, point) => {
|
|
@@ -20074,11 +20223,11 @@ class SandstonePack {
|
|
|
20074
20223
|
}
|
|
20075
20224
|
return {
|
|
20076
20225
|
datapack: {
|
|
20077
|
-
packFormat:
|
|
20226
|
+
packFormat: 111,
|
|
20078
20227
|
description: "A Sandstone datapack"
|
|
20079
20228
|
},
|
|
20080
20229
|
resourcepack: {
|
|
20081
|
-
packFormat:
|
|
20230
|
+
packFormat: 92,
|
|
20082
20231
|
description: "A Sandstone resource pack"
|
|
20083
20232
|
}
|
|
20084
20233
|
};
|
|
@@ -20155,7 +20304,7 @@ class SandstonePack {
|
|
|
20155
20304
|
dataPack() {
|
|
20156
20305
|
let pack = this.packTypes.get("datapack");
|
|
20157
20306
|
if (!pack) {
|
|
20158
|
-
const options = this.packOptions.datapack ?? { packFormat:
|
|
20307
|
+
const options = this.packOptions.datapack ?? { packFormat: 111, description: "A Sandstone datapack" };
|
|
20159
20308
|
pack = this.packTypes.set("datapack", new DataPack(false, options)).get("datapack");
|
|
20160
20309
|
}
|
|
20161
20310
|
return pack;
|
|
@@ -20163,16 +20312,17 @@ class SandstonePack {
|
|
|
20163
20312
|
resourcePack() {
|
|
20164
20313
|
let pack = this.packTypes.get("resourcepack");
|
|
20165
20314
|
if (!pack) {
|
|
20166
|
-
const options = this.packOptions.resourcepack ?? { packFormat:
|
|
20315
|
+
const options = this.packOptions.resourcepack ?? { packFormat: 92, description: "A Sandstone resource pack" };
|
|
20167
20316
|
pack = this.packTypes.set("resourcepack", new ResourcePack(options)).get("resourcepack");
|
|
20168
20317
|
}
|
|
20169
20318
|
return pack;
|
|
20170
20319
|
}
|
|
20171
20320
|
setupLantern = () => {
|
|
20172
|
-
const loadStatus = this.Objective.create("load.status", "dummy", undefined, { useDefaultNamespace: false });
|
|
20321
|
+
const loadStatus = this.Objective.create("load.status", "dummy", undefined, { useDefaultNamespace: false, alreadyExists: true });
|
|
20173
20322
|
const privateInit = this.Tag("function", "load:_private/init", [
|
|
20174
20323
|
this.MCFunction("load:_private/init", () => {
|
|
20175
20324
|
this.commands.comment("Reset scoreboards so packs can set values accurate for current load.");
|
|
20325
|
+
this.commands.scoreboard.objectives.add(loadStatus.name, "dummy");
|
|
20176
20326
|
loadStatus.reset();
|
|
20177
20327
|
})
|
|
20178
20328
|
]);
|
|
@@ -20309,10 +20459,10 @@ class SandstonePack {
|
|
|
20309
20459
|
return anonymousData;
|
|
20310
20460
|
}
|
|
20311
20461
|
DataIndexMap(initialize, dataPoint2) {
|
|
20312
|
-
return
|
|
20462
|
+
return DataIndexMapInternal(this, initialize, dataPoint2);
|
|
20313
20463
|
}
|
|
20314
20464
|
DataArray(initialize, dataPoint2) {
|
|
20315
|
-
return
|
|
20465
|
+
return DataArrayInternal(this, initialize, dataPoint2);
|
|
20316
20466
|
}
|
|
20317
20467
|
getTempStorage = (name) => {
|
|
20318
20468
|
if (tempStorage) {
|
|
@@ -20619,12 +20769,12 @@ class SandstonePack {
|
|
|
20619
20769
|
onConflict: conflictDefaults("atlas"),
|
|
20620
20770
|
...options
|
|
20621
20771
|
});
|
|
20622
|
-
|
|
20623
|
-
return new
|
|
20772
|
+
BlockStateDefinition(name, json, options) {
|
|
20773
|
+
return new BlockStateDefinitionClass(this.core, name, {
|
|
20624
20774
|
json,
|
|
20625
20775
|
creator: "user",
|
|
20626
20776
|
addToSandstoneCore: true,
|
|
20627
|
-
onConflict: conflictDefaults("
|
|
20777
|
+
onConflict: conflictDefaults("block_definition"),
|
|
20628
20778
|
...options
|
|
20629
20779
|
});
|
|
20630
20780
|
}
|
|
@@ -61929,7 +62079,7 @@ var init_resources3 = __esm(() => {
|
|
|
61929
62079
|
[VillagerTradeClass, "villager_trade"],
|
|
61930
62080
|
[WorldClockClass, "world_clock"],
|
|
61931
62081
|
[AtlasClass, "atlas"],
|
|
61932
|
-
[
|
|
62082
|
+
[BlockStateDefinitionClass, "block_definition"],
|
|
61933
62083
|
[EquipmentClass, "equipment"],
|
|
61934
62084
|
[FontClass, "font"],
|
|
61935
62085
|
[ItemModelDefinitionClass, "item_definition"],
|
|
@@ -61983,7 +62133,7 @@ var init_ItemPredicate = __esm(() => {
|
|
|
61983
62133
|
});
|
|
61984
62134
|
|
|
61985
62135
|
// src/variables/DataSets.ts
|
|
61986
|
-
function
|
|
62136
|
+
function DataIndexMapInternal(pack2, initialize, dataPoint2) {
|
|
61987
62137
|
const indexMap = new DataIndexMapClass(pack2, initialize, dataPoint2);
|
|
61988
62138
|
return new Proxy(indexMap, {
|
|
61989
62139
|
get(target, p, receiver) {
|
|
@@ -62001,7 +62151,7 @@ function DataIndexMap(pack2, initialize, dataPoint2) {
|
|
|
62001
62151
|
}
|
|
62002
62152
|
});
|
|
62003
62153
|
}
|
|
62004
|
-
function
|
|
62154
|
+
function DataArrayInternal(pack2, initialize, dataPoint2) {
|
|
62005
62155
|
const array3 = new DataArrayClass(pack2, initialize, dataPoint2);
|
|
62006
62156
|
return new Proxy(array3, {
|
|
62007
62157
|
get(target, p, receiver) {
|
|
@@ -62692,7 +62842,7 @@ var {
|
|
|
62692
62842
|
VillagerTrade,
|
|
62693
62843
|
WorldClock,
|
|
62694
62844
|
Atlas,
|
|
62695
|
-
|
|
62845
|
+
BlockStateDefinition,
|
|
62696
62846
|
Equipment,
|
|
62697
62847
|
Font,
|
|
62698
62848
|
ItemModelDefinition,
|
|
@@ -62716,8 +62866,8 @@ var {
|
|
|
62716
62866
|
DataVariable,
|
|
62717
62867
|
getTempStorage,
|
|
62718
62868
|
ResolveNBT: ResolveNBT2,
|
|
62719
|
-
DataIndexMap
|
|
62720
|
-
DataArray
|
|
62869
|
+
DataIndexMap,
|
|
62870
|
+
DataArray,
|
|
62721
62871
|
Selector: Selector2,
|
|
62722
62872
|
UUID: UUID2,
|
|
62723
62873
|
ItemPredicate: ItemPredicate2,
|
|
@@ -63379,14 +63529,16 @@ export {
|
|
|
63379
63529
|
DataModifyFromCommand,
|
|
63380
63530
|
DataModifyCommand,
|
|
63381
63531
|
DataMergeCommand,
|
|
63532
|
+
DataIndexMapInternal,
|
|
63382
63533
|
DataIndexMapClass,
|
|
63383
|
-
|
|
63534
|
+
DataIndexMap,
|
|
63384
63535
|
DataGetCommand,
|
|
63385
63536
|
DataCommandNode,
|
|
63386
63537
|
DataCommand,
|
|
63387
63538
|
DataClass,
|
|
63539
|
+
DataArrayInternal,
|
|
63388
63540
|
DataArrayClass,
|
|
63389
|
-
|
|
63541
|
+
DataArray,
|
|
63390
63542
|
Data2 as Data,
|
|
63391
63543
|
DamageTypeNode,
|
|
63392
63544
|
DamageTypeClass,
|
|
@@ -63450,9 +63602,9 @@ export {
|
|
|
63450
63602
|
BossBarCommandNode,
|
|
63451
63603
|
BossBarCommand,
|
|
63452
63604
|
BlocksConditionNode,
|
|
63453
|
-
|
|
63454
|
-
|
|
63455
|
-
|
|
63605
|
+
BlockStateDefinitionNode,
|
|
63606
|
+
BlockStateDefinitionClass,
|
|
63607
|
+
BlockStateDefinition,
|
|
63456
63608
|
BlockConditionNode,
|
|
63457
63609
|
BiomeConditionNode,
|
|
63458
63610
|
BannerPatternNode,
|
|
@@ -63486,5 +63638,5 @@ export {
|
|
|
63486
63638
|
ACTIVITIES_SET
|
|
63487
63639
|
};
|
|
63488
63640
|
|
|
63489
|
-
//# debugId=
|
|
63641
|
+
//# debugId=D77F3F3DCD4BFA5364756E2164756E21
|
|
63490
63642
|
//# sourceMappingURL=sandstone.esm.js.map
|