sandstone 1.1.4 → 1.1.6
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 +3 -3
- package/dist/_internal/index.js +185 -35
- package/dist/_internal/index.js.map +1 -1
- package/dist/_internal/types/flow/Flow.d.ts +16 -2
- 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/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/utils.d.ts +1 -1
- package/dist/_internal/types/utils.d.ts.map +1 -1
- 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 +185 -35
- package/dist/browser/sandstone.esm.js.map +1 -1
- package/package.json +2 -2
- 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 +2 -1
- package/src/pack/visitors/orTransformationVisitor.ts +311 -37
- package/src/utils.ts +1 -1
- package/src/variables/abstractClasses.ts +10 -0
|
@@ -3,7 +3,7 @@ import { SandstoneContext, setSandstoneContext, getSandstoneContext, hasContext,
|
|
|
3
3
|
import type { FillCommand, GiveCommand, SetBlockCommand, AdvancementCommand, AttributeOperationCommand, BossBarCommand, FinalCommandOutput, CloneOptionsCommand, CloneFromDimensionCommand, DamageSourceCommand, DataCommand, DataPackCommand, DebugCommand, DialogCommand, EffectCommand, ExecuteCommand, ExperienceCommand, ForceLoadCommand, ExtractNBTIntRange, LocateCommand, LootCommand, PerfCommand, PlaceCommand, RandomCommand, RecipeCommand, SandstoneCommands, RotateFacingArguments, RideArgumentsCommand, ItemCommand, JFRCommand, ScheduleCommand, ScoreboardCommand, StopwatchCommand, TagArgumentsCommand, TeamCommand, TeleportFacingCommand, TestCommand, TimeCommand, TitleArgumentsCommand, TriggerArgumentsCommand, WaypointCommand, WeatherCommand, WorldBorderCommand, StoreType } from "./types/commands/index.js";
|
|
4
4
|
import { AdvancementClassArguments, AtlasClassArguments, BannerPatternClassArguments, BlockStateDefinitionArguments, ChatTypeClassArguments, DamageTypeClassArguments, DialogClassArguments, EnchantmentClassArguments, EnchantmentProviderClassArguments, EquipmentClassArguments, FontArguments, InstrumentClassArguments, ItemModelDefinitionClassArguments, ItemModifierClassArguments, JukeboxSongClassArguments, LanguageArguments, LootTableClassArguments, MCFunctionClassArguments, ModelClassArguments, ParticleClassArguments, PlainTextArguments, PostEffectClassArguments, PredicateClassArguments, RecipeClassArguments, ShaderClassArguments, SoundEventArguments, SoundsIndexArguments, SulfurCubeArchetypeClassArguments, TagClassArguments, TestEnvironmentClassArguments, TestInstanceClassArguments, TextureArguments, TimelineClassArguments, TradeSetClassArguments, TrialSpawnerClassArguments, TrimMaterialClassArguments, TrimPatternClassArguments, VariantClassArguments, VillagerTradeClassArguments, WaypointStyleClassArguments, WorldClockClassArguments, MCFunctionClass, DataPointPickClass, CustomResourceClass, MacroArgument, TagValuesJSON, VariantType, BlockStateDefinitionJSON, BlockStateDefinitionType, ItemModelDefinitionInput, ShaderClass, PlainTextClass, MacroLiteral, SandstoneCore, ResourceClass } from "./types/core/index.js";
|
|
5
5
|
import { Flow, Condition } from "./types/flow/index.js";
|
|
6
|
-
import type { BASIC_CONFLICT_STRATEGIES, LiteralUnion, NamespacedLiteralUnion, SetType, AllKeys, MakeInstanceCallable } from "./types/utils.js";
|
|
6
|
+
import type { BASIC_CONFLICT_STRATEGIES, LiteralUnion, NamespacedLiteralUnion, SetType, AllowConst, AllKeys, MakeInstanceCallable } from "./types/utils.js";
|
|
7
7
|
import { ObjectiveClass, Score, SelectorClass, LabelClass, UUIDClass, DataPointClass, ItemPredicateClass, DATA_TYPES, TriggerHandler, TriggerClass, _RawLabelClass, TargetlessDataClass, TargetFor, DataClass, DATA_PATH, TargetlessDataPointClass, ResolveNBTClass, DataIndexMapType, DataArrayType, SelectorEntityType, SelectorProperties, UUIDinNumber, UUIDOptions, UUIDinScore, SelectorPickClass, ItemPredicateItem, SleepClass } from "./types/variables/index.js";
|
|
8
8
|
import { AdvancementClass, BannerPatternClass, ChatTypeClass, DamageTypeClass, DialogClass, EnchantmentClass, EnchantmentProviderClass, InstrumentClass, ItemModifierClass, JukeboxSongClass, LootTableClass, PredicateClass, RecipeClass, StructureClass, SulfurCubeArchetypeClass, TagClass, TestEnvironmentClass, TestInstanceClass, TimelineClass, TradeSetClass, TrialSpawnerClass, TrimMaterialClass, TrimPatternClass, VariantClass, VillagerTradeClass, WorldClockClass, AtlasClass, BlockStateDefinitionClass, EquipmentClass, FontClass, ItemModelDefinitionClass, LanguageClass, ModelClass, ParticleClass, PostEffectClass, SoundEventClass, SoundsIndexClass, TextureClass, WaypointStyleClass } from "./types/core/resources/index.js";
|
|
9
9
|
import type { SingleEntityArgumentOf, MultiplePlayersArgumentOf, Coordinates, GAMEMODES, DIFFICULTIES, MultipleEntitiesArgument, RootNBT, MessageOrSelector, AbsoluteCoordinates, SOUND_SOURCES, Rotation, SinglePlayerArgumentOf, ColumnCoordinates, ObjectiveArgument, MCDocToJSON, SymbolResource, RecipeJSON, REGISTRIES, SOUND_TYPES, TEXTURE_TYPES, OBJECTIVE_CRITERIA, NBTObject, TimeArgument } from "./types/arguments/index.js";
|
|
@@ -1273,7 +1273,7 @@ export declare const advancement: AdvancementCommand<false>, attribute: <T exten
|
|
|
1273
1273
|
}, ride: <T extends string>(target: SingleEntityArgumentOf<false, T>) => RideArgumentsCommand<boolean>, item: ItemCommand<false>, jfr: JFRCommand, say: (message: string) => FinalCommandOutput, schedule: ScheduleCommand<false>, scoreboard: ScoreboardCommand<false>, seed: () => FinalCommandOutput, setidletimeout: (minutes: number) => FinalCommandOutput, setworldspawn: (pos?: Coordinates<false> | undefined, angle?: Rotation<false> | undefined) => FinalCommandOutput, spawnpoint: <T extends string>(targets?: MultiplePlayersArgumentOf<false, T> | undefined, pos?: Coordinates<false> | undefined, angle?: Rotation<false> | undefined) => FinalCommandOutput, spectate: <T extends string, P extends string>(target: SingleEntityArgumentOf<false, T>, player?: SinglePlayerArgumentOf<false, P> | undefined) => FinalCommandOutput, spreadplayers: {
|
|
1274
1274
|
(center: ColumnCoordinates<false>, spreadDistance: number, maxRange: number, respectTeams: boolean, targets: MultipleEntitiesArgument<false>): FinalCommandOutput;
|
|
1275
1275
|
(center: ColumnCoordinates<false>, spreadDistance: number, maxRange: number, under: "under", height: number, respectTeams: boolean, targets: MultipleEntitiesArgument<false>): FinalCommandOutput;
|
|
1276
|
-
}, stopsound: <T extends string>(targets: MultiplePlayersArgumentOf<false, T>, source?: "*" | SOUND_SOURCES | undefined, sound?: SOUND_EVENTS | undefined) => FinalCommandOutput, stopwatch: StopwatchCommand<false>, summon: <ENTITY extends ENTITY_TYPES>(entity: ENTITY, pos?: Coordinates<false> | undefined, nbt?:
|
|
1276
|
+
}, stopsound: <T extends string>(targets: MultiplePlayersArgumentOf<false, T>, source?: "*" | SOUND_SOURCES | undefined, sound?: SOUND_EVENTS | undefined) => FinalCommandOutput, stopwatch: StopwatchCommand<false>, summon: <ENTITY extends ENTITY_TYPES>(entity: ENTITY, pos?: Coordinates<false> | undefined, nbt?: AllowConst<ENTITY extends keyof {
|
|
1277
1277
|
acacia_boat: EntityBase;
|
|
1278
1278
|
'minecraft:acacia_boat': EntityBase;
|
|
1279
1279
|
acacia_chest_boat: ChestBoat;
|
|
@@ -1935,7 +1935,7 @@ export declare const advancement: AdvancementCommand<false>, attribute: <T exten
|
|
|
1935
1935
|
'minecraft:zombie_villager': ZombieVillager;
|
|
1936
1936
|
zombified_piglin: ZombiePigman;
|
|
1937
1937
|
'minecraft:zombified_piglin': ZombiePigman;
|
|
1938
|
-
}[ENTITY]> : RootNBT
|
|
1938
|
+
}[ENTITY]> : RootNBT> | undefined) => FinalCommandOutput, swing: (targets?: MultipleEntitiesArgument<false>, hand?: "mainhand" | "offhand") => FinalCommandOutput, tag: (targets: MultipleEntitiesArgument<false>) => TagArgumentsCommand<false>, team: TeamCommand<false>, teammsg: (messages_0: MessageOrSelector, ...messages: MessageOrSelector[]) => FinalCommandOutput, teleport: {
|
|
1939
1939
|
<T extends string>(destinationEntity: SingleEntityArgumentOf<false, T>): void;
|
|
1940
1940
|
(location: Coordinates<false>): void;
|
|
1941
1941
|
<T extends string>(targets: MultipleEntitiesArgument<false>, destinationEntity: SingleEntityArgumentOf<false, T>): void;
|
package/dist/_internal/index.js
CHANGED
|
@@ -4408,6 +4408,7 @@ WorldBorderCommand = class WorldBorderCommand extends CommandArguments {
|
|
|
4408
4408
|
};
|
|
4409
4409
|
};
|
|
4410
4410
|
ConditionNode = class ConditionNode extends Node {
|
|
4411
|
+
preNodes;
|
|
4411
4412
|
};
|
|
4412
4413
|
SingleConditionNode = class SingleConditionNode extends ConditionNode {
|
|
4413
4414
|
getValue = (negated = false) => {
|
|
@@ -4564,9 +4565,13 @@ DataPointEqualsConditionNode = class DataPointEqualsConditionNode extends Single
|
|
|
4564
4565
|
this.value = value;
|
|
4565
4566
|
const { DataVariable, Variable, commands: commands2 } = sandstoneCore2.pack;
|
|
4566
4567
|
const { execute: execute2 } = commands2;
|
|
4568
|
+
const mcFunction = sandstoneCore2.getCurrentMCFunctionOrThrow();
|
|
4569
|
+
const before = mcFunction.body.length;
|
|
4567
4570
|
const anon = DataVariable(this.dataPoint);
|
|
4568
4571
|
this.conditional = Variable();
|
|
4569
4572
|
execute2.store.result(this.conditional).run(() => anon.set(this.value));
|
|
4573
|
+
const after = mcFunction.body.length;
|
|
4574
|
+
this.preNodes = mcFunction.body.splice(before, after - before);
|
|
4570
4575
|
}
|
|
4571
4576
|
getValue = (negated) => (negated ? ["if", ...this.getCondition()] : ["unless", ...this.getCondition()]).join(" ");
|
|
4572
4577
|
getCondition() {
|
|
@@ -4631,7 +4636,11 @@ CommandConditionNode = class CommandConditionNode extends SingleConditionNode {
|
|
|
4631
4636
|
this.result = result;
|
|
4632
4637
|
const store = sandstoneCore2.pack.commands.execute.store[type];
|
|
4633
4638
|
this.variable = sandstoneCore2.pack.Variable(undefined, "condition");
|
|
4639
|
+
const mcFunction = sandstoneCore2.getCurrentMCFunctionOrThrow();
|
|
4640
|
+
const before = mcFunction.body.length;
|
|
4634
4641
|
command(store(this.variable));
|
|
4642
|
+
const after = mcFunction.body.length;
|
|
4643
|
+
this.preNodes = mcFunction.body.splice(before, after - before);
|
|
4635
4644
|
}
|
|
4636
4645
|
getCondition() {
|
|
4637
4646
|
if (this.type === "success") {
|
|
@@ -5128,54 +5137,186 @@ LoopTransformationVisitor = class LoopTransformationVisitor extends GenericSands
|
|
|
5128
5137
|
visitForINode = this.visitLoopNode;
|
|
5129
5138
|
visitForOfNode = this.visitLoopNode;
|
|
5130
5139
|
};
|
|
5140
|
+
FunctionReturnConditionNode = class FunctionReturnConditionNode extends ConditionNode {
|
|
5141
|
+
sandstoneCore;
|
|
5142
|
+
functionName;
|
|
5143
|
+
constructor(sandstoneCore2, functionName) {
|
|
5144
|
+
super(sandstoneCore2);
|
|
5145
|
+
this.sandstoneCore = sandstoneCore2;
|
|
5146
|
+
this.functionName = functionName;
|
|
5147
|
+
}
|
|
5148
|
+
getValue = () => `if function ${this.functionName}`;
|
|
5149
|
+
};
|
|
5131
5150
|
OrTransformationVisitor = class OrTransformationVisitor extends GenericSandstoneVisitor {
|
|
5132
5151
|
visitIfNode = (node_) => {
|
|
5133
|
-
const { preNodes, conditionNode } = this.parseConditionNode(node_.condition);
|
|
5152
|
+
const { preNodes, conditionNode } = this.parseConditionNode(node_.condition, node_.parentMCFunction);
|
|
5134
5153
|
node_.condition = conditionNode;
|
|
5135
5154
|
return [...preNodes, this.genericVisit(node_)];
|
|
5136
5155
|
};
|
|
5137
|
-
parseConditionNode = (node) => {
|
|
5156
|
+
parseConditionNode = (node, parentMCFunction) => {
|
|
5138
5157
|
if (node instanceof OrNode) {
|
|
5139
|
-
return this.parseOrNode(node);
|
|
5158
|
+
return this.parseOrNode(node, parentMCFunction);
|
|
5140
5159
|
}
|
|
5141
5160
|
if (node instanceof AndNode) {
|
|
5142
|
-
return this.parseAndNode(node);
|
|
5161
|
+
return this.parseAndNode(node, parentMCFunction);
|
|
5143
5162
|
}
|
|
5144
5163
|
if (node instanceof NotNode) {
|
|
5145
|
-
return this.parseNotNode(node);
|
|
5164
|
+
return this.parseNotNode(node, parentMCFunction);
|
|
5146
5165
|
}
|
|
5147
|
-
return { preNodes: [], conditionNode: node };
|
|
5166
|
+
return { preNodes: [...node.preNodes ?? []], conditionNode: node };
|
|
5148
5167
|
};
|
|
5149
|
-
parseOrNode = (node) => {
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
const
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
return ifNode;
|
|
5168
|
+
parseOrNode = (node, parentMCFunction) => {
|
|
5169
|
+
if (node.conditions.length === 1) {
|
|
5170
|
+
return this.parseConditionNode(node.conditions[0], parentMCFunction);
|
|
5171
|
+
}
|
|
5172
|
+
const parentName = parentMCFunction?.resource.name ?? "__sandstone";
|
|
5173
|
+
const orMCFunction = new MCFunctionClass(this.core, `${parentName}/or_check`, {
|
|
5174
|
+
addToSandstoneCore: true,
|
|
5175
|
+
creator: "sandstone",
|
|
5176
|
+
onConflict: "rename"
|
|
5159
5177
|
});
|
|
5178
|
+
this.core.enterMCFunction(orMCFunction);
|
|
5179
|
+
try {
|
|
5180
|
+
for (const condition2 of node.conditions) {
|
|
5181
|
+
this.pushCheckBranch(orMCFunction.node, this.parseConditionNode(condition2, orMCFunction.node), false, new ReturnCommandNode(this.pack, [1]));
|
|
5182
|
+
}
|
|
5183
|
+
orMCFunction.node.body.push(new ReturnCommandNode(this.pack, [0]));
|
|
5184
|
+
} finally {
|
|
5185
|
+
this.core.exitMCFunction();
|
|
5186
|
+
}
|
|
5160
5187
|
return {
|
|
5161
|
-
preNodes: [
|
|
5162
|
-
conditionNode
|
|
5188
|
+
preNodes: [],
|
|
5189
|
+
conditionNode: new FunctionReturnConditionNode(this.core, orMCFunction.name)
|
|
5163
5190
|
};
|
|
5164
5191
|
};
|
|
5165
|
-
parseAndNode = (node) => {
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5192
|
+
parseAndNode = (node, parentMCFunction) => {
|
|
5193
|
+
if (node.conditions.length === 1) {
|
|
5194
|
+
return this.parseConditionNode(node.conditions[0], parentMCFunction);
|
|
5195
|
+
}
|
|
5196
|
+
const parsed = node.conditions.map((condition2) => this.parseConditionNode(condition2, parentMCFunction));
|
|
5197
|
+
const anyHasCommands = parsed.some((p) => (p.preNodes ?? []).length > 0);
|
|
5198
|
+
if (!anyHasCommands) {
|
|
5199
|
+
const finalPreNodes = [];
|
|
5200
|
+
const conditionNode = new AndNode(node.sandstoneCore, parsed.map((p) => {
|
|
5201
|
+
finalPreNodes.push(...p.preNodes);
|
|
5202
|
+
return p.conditionNode;
|
|
5203
|
+
}));
|
|
5204
|
+
return { preNodes: finalPreNodes, conditionNode };
|
|
5205
|
+
}
|
|
5206
|
+
const parentName = parentMCFunction?.resource.name ?? "__sandstone";
|
|
5207
|
+
const andMCFunction = new MCFunctionClass(this.core, `${parentName}/and_check`, {
|
|
5208
|
+
addToSandstoneCore: true,
|
|
5209
|
+
creator: "sandstone",
|
|
5210
|
+
onConflict: "rename"
|
|
5211
|
+
});
|
|
5212
|
+
this.core.enterMCFunction(andMCFunction);
|
|
5213
|
+
try {
|
|
5214
|
+
let batch = { preNodes: [], conditionNodes: [] };
|
|
5215
|
+
const flushBatch = () => {
|
|
5216
|
+
if (batch.conditionNodes.length === 0 && batch.preNodes.every((pn) => pn.length === 0)) {
|
|
5217
|
+
batch = { preNodes: [], conditionNodes: [] };
|
|
5218
|
+
return;
|
|
5219
|
+
}
|
|
5220
|
+
const tracker = this.core.pack.Variable(undefined, "and_batch");
|
|
5221
|
+
this.pushBatchedCheckBranch(andMCFunction.node, batch.preNodes.flat(), batch.conditionNodes, tracker);
|
|
5222
|
+
batch = { preNodes: [], conditionNodes: [] };
|
|
5223
|
+
};
|
|
5224
|
+
for (const p of parsed) {
|
|
5225
|
+
if (p.preNodes.length === 0) {
|
|
5226
|
+
batch.preNodes.push(p.preNodes);
|
|
5227
|
+
batch.conditionNodes.push(p.conditionNode);
|
|
5228
|
+
} else {
|
|
5229
|
+
flushBatch();
|
|
5230
|
+
this.pushFailFastBranch(andMCFunction.node, p, new ReturnCommandNode(this.pack, [0]));
|
|
5231
|
+
}
|
|
5232
|
+
}
|
|
5233
|
+
flushBatch();
|
|
5234
|
+
andMCFunction.node.body.push(new ReturnCommandNode(this.pack, [1]));
|
|
5235
|
+
} finally {
|
|
5236
|
+
this.core.exitMCFunction();
|
|
5237
|
+
}
|
|
5172
5238
|
return {
|
|
5173
|
-
preNodes:
|
|
5174
|
-
conditionNode
|
|
5239
|
+
preNodes: [],
|
|
5240
|
+
conditionNode: new FunctionReturnConditionNode(this.core, andMCFunction.name)
|
|
5175
5241
|
};
|
|
5176
5242
|
};
|
|
5177
|
-
|
|
5178
|
-
const
|
|
5243
|
+
pushBatchedCheckBranch = (targetMCFunction, preNodes, conditionNodes, tracker) => {
|
|
5244
|
+
for (const n of preNodes) {
|
|
5245
|
+
targetMCFunction.body.push(n);
|
|
5246
|
+
}
|
|
5247
|
+
targetMCFunction.body.push(new ScoreboardCommandNode(this.pack, "players", "reset", tracker));
|
|
5248
|
+
const args = [];
|
|
5249
|
+
for (const c of conditionNodes) {
|
|
5250
|
+
const condStr = c.getValue(false);
|
|
5251
|
+
const match = condStr.match(/^(if|unless)\s+([\s\S]+)$/);
|
|
5252
|
+
if (!match) {
|
|
5253
|
+
throw new Error(`OrTransformationVisitor: unexpected condition getValue() shape: ${condStr}`);
|
|
5254
|
+
}
|
|
5255
|
+
const [, keyword, condBody] = match;
|
|
5256
|
+
args.push([keyword, condBody]);
|
|
5257
|
+
}
|
|
5258
|
+
if (args.length === 0) {
|
|
5259
|
+
targetMCFunction.body.push(new ScoreboardCommandNode(this.pack, "players", "set", tracker, 1));
|
|
5260
|
+
} else {
|
|
5261
|
+
const executeNode = new ExecuteCommandNode(this.pack, args, {
|
|
5262
|
+
isSingleExecute: true,
|
|
5263
|
+
body: []
|
|
5264
|
+
});
|
|
5265
|
+
targetMCFunction.enterContext(executeNode, false);
|
|
5266
|
+
executeNode.body = [new ScoreboardCommandNode(this.pack, "players", "set", tracker, 1)];
|
|
5267
|
+
targetMCFunction.body.push(executeNode);
|
|
5268
|
+
targetMCFunction.exitContext();
|
|
5269
|
+
}
|
|
5270
|
+
const failCheckNode = new ExecuteCommandNode(this.pack, [["unless", `score ${tracker} matches 1`]], {
|
|
5271
|
+
isSingleExecute: true,
|
|
5272
|
+
body: []
|
|
5273
|
+
});
|
|
5274
|
+
targetMCFunction.enterContext(failCheckNode, false);
|
|
5275
|
+
failCheckNode.body = [new ReturnCommandNode(this.pack, [0])];
|
|
5276
|
+
targetMCFunction.body.push(failCheckNode);
|
|
5277
|
+
targetMCFunction.exitContext();
|
|
5278
|
+
};
|
|
5279
|
+
pushCheckBranch = (targetMCFunction, parsed, negated, bodyNode) => {
|
|
5280
|
+
for (const n of parsed.preNodes) {
|
|
5281
|
+
targetMCFunction.body.push(n);
|
|
5282
|
+
}
|
|
5283
|
+
const condStr = parsed.conditionNode.getValue(negated);
|
|
5284
|
+
const match = condStr.match(/^(if|unless)\s+([\s\S]+)$/);
|
|
5285
|
+
if (!match) {
|
|
5286
|
+
throw new Error(`OrTransformationVisitor: unexpected condition getValue() shape: ${condStr}`);
|
|
5287
|
+
}
|
|
5288
|
+
const [, keyword, condBody] = match;
|
|
5289
|
+
const executeNode = new ExecuteCommandNode(this.pack, [[keyword, condBody]], {
|
|
5290
|
+
isSingleExecute: true,
|
|
5291
|
+
body: []
|
|
5292
|
+
});
|
|
5293
|
+
targetMCFunction.enterContext(executeNode, false);
|
|
5294
|
+
executeNode.body = [bodyNode];
|
|
5295
|
+
targetMCFunction.body.push(executeNode);
|
|
5296
|
+
targetMCFunction.exitContext();
|
|
5297
|
+
};
|
|
5298
|
+
pushFailFastBranch = (targetMCFunction, parsed, bodyNode) => {
|
|
5299
|
+
for (const n of parsed.preNodes) {
|
|
5300
|
+
targetMCFunction.body.push(n);
|
|
5301
|
+
}
|
|
5302
|
+
const condStr = parsed.conditionNode.getValue(true);
|
|
5303
|
+
const match = condStr.match(/^(if|unless)\s+([\s\S]+)$/);
|
|
5304
|
+
if (!match) {
|
|
5305
|
+
throw new Error(`OrTransformationVisitor: unexpected condition getValue() shape: ${condStr}`);
|
|
5306
|
+
}
|
|
5307
|
+
const flippedKeyword = match[1] === "if" ? "unless" : "if";
|
|
5308
|
+
const condBody = match[2];
|
|
5309
|
+
const executeNode = new ExecuteCommandNode(this.pack, [[flippedKeyword, condBody]], {
|
|
5310
|
+
isSingleExecute: true,
|
|
5311
|
+
body: []
|
|
5312
|
+
});
|
|
5313
|
+
targetMCFunction.enterContext(executeNode, false);
|
|
5314
|
+
executeNode.body = [bodyNode];
|
|
5315
|
+
targetMCFunction.body.push(executeNode);
|
|
5316
|
+
targetMCFunction.exitContext();
|
|
5317
|
+
};
|
|
5318
|
+
parseNotNode = (node, parentMCFunction) => {
|
|
5319
|
+
const { preNodes, conditionNode } = this.parseConditionNode(node.condition, parentMCFunction);
|
|
5179
5320
|
return {
|
|
5180
5321
|
preNodes,
|
|
5181
5322
|
conditionNode: new NotNode(node.sandstoneCore, conditionNode)
|
|
@@ -6429,6 +6570,7 @@ SleepClass = class SleepClass extends AwaitNode {
|
|
|
6429
6570
|
// src/variables/abstractClasses.ts
|
|
6430
6571
|
|
|
6431
6572
|
class ConditionClass {
|
|
6573
|
+
preNodes;
|
|
6432
6574
|
_toMinecraftCondition() {
|
|
6433
6575
|
throw new Error("Not implemented");
|
|
6434
6576
|
}
|
|
@@ -10255,8 +10397,14 @@ class Flow {
|
|
|
10255
10397
|
this.sandstoneCore = sandstoneCore2;
|
|
10256
10398
|
}
|
|
10257
10399
|
if = (condition2, callback) => new IfStatement(this.sandstoneCore, conditionToNode(condition2), callback);
|
|
10258
|
-
and
|
|
10259
|
-
|
|
10400
|
+
and(...args) {
|
|
10401
|
+
const conditions = args[0] instanceof Array ? args[0] : args;
|
|
10402
|
+
return new AndNode(this.sandstoneCore, conditions.map((condition2) => conditionToNode(condition2)));
|
|
10403
|
+
}
|
|
10404
|
+
or(...args) {
|
|
10405
|
+
const conditions = args[0] instanceof Array ? args[0] : args;
|
|
10406
|
+
return new OrNode(this.sandstoneCore, conditions.map((condition2) => conditionToNode(condition2)));
|
|
10407
|
+
}
|
|
10260
10408
|
not = (condition2) => new NotNode(this.sandstoneCore, conditionToNode(condition2));
|
|
10261
10409
|
get return() {
|
|
10262
10410
|
return this.sandstoneCore.pack.commands.returnCmd;
|
|
@@ -10516,12 +10664,13 @@ var init_loopTransformationVisitor = __esm(() => {
|
|
|
10516
10664
|
});
|
|
10517
10665
|
|
|
10518
10666
|
// src/pack/visitors/orTransformationVisitor.ts
|
|
10519
|
-
var OrTransformationVisitor;
|
|
10667
|
+
var FunctionReturnConditionNode, OrTransformationVisitor;
|
|
10520
10668
|
var init_orTransformationVisitor = __esm(() => {
|
|
10521
10669
|
init_commands2();
|
|
10670
|
+
init_core();
|
|
10522
10671
|
init_flow();
|
|
10523
10672
|
init_visitor();
|
|
10524
|
-
|
|
10673
|
+
});
|
|
10525
10674
|
|
|
10526
10675
|
// src/pack/visitors/optimizeMacroTemporaries.ts
|
|
10527
10676
|
var flattenArgs = (args) => args.flatMap((arg) => Array.isArray(arg) ? flattenArgs(arg) : [arg]), referencesStoragePoint = (node, point) => {
|
|
@@ -10763,10 +10912,11 @@ class SandstonePack {
|
|
|
10763
10912
|
return pack;
|
|
10764
10913
|
}
|
|
10765
10914
|
setupLantern = () => {
|
|
10766
|
-
const loadStatus = this.Objective.create("load.status", "dummy", undefined, { useDefaultNamespace: false });
|
|
10915
|
+
const loadStatus = this.Objective.create("load.status", "dummy", undefined, { useDefaultNamespace: false, alreadyExists: true });
|
|
10767
10916
|
const privateInit = this.Tag("function", "load:_private/init", [
|
|
10768
10917
|
this.MCFunction("load:_private/init", () => {
|
|
10769
10918
|
this.commands.comment("Reset scoreboards so packs can set values accurate for current load.");
|
|
10919
|
+
this.commands.scoreboard.objectives.add(loadStatus.name, "dummy");
|
|
10770
10920
|
loadStatus.reset();
|
|
10771
10921
|
})
|
|
10772
10922
|
]);
|
|
@@ -54082,5 +54232,5 @@ export {
|
|
|
54082
54232
|
ACTIVITIES_SET
|
|
54083
54233
|
};
|
|
54084
54234
|
|
|
54085
|
-
//# debugId=
|
|
54235
|
+
//# debugId=4AE8B281EBDAB42264756E2164756E21
|
|
54086
54236
|
//# sourceMappingURL=index.js.map
|