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 +1 @@
|
|
|
1
|
-
export { AdvancementClassArguments, AdvancementNode, AtlasClassArguments, AtlasNode, AudibleVariantType, AwaitNode, BannerPatternClassArguments, BannerPatternNode,
|
|
1
|
+
export { AdvancementClassArguments, AdvancementNode, AtlasClassArguments, AtlasNode, AudibleVariantType, AwaitNode, BannerPatternClassArguments, BannerPatternNode, BlockStateDefinitionArguments, BlockStateDefinitionJSON, BlockStateDefinitionNode, BlockStateDefinitionType, CallableResourceClass, ChatTypeClassArguments, ChatTypeNode, CommandNode, ConditionalDataPointPickClass, ContainerCommandNode, ContainerNode, CustomResourceClass, CustomResourceClassArguments, CustomResourceNode, DamageTypeClassArguments, DamageTypeNode, DataPointPickClass, DialogClassArguments, DialogNode, EnchantmentClassArguments, EnchantmentNode, EnchantmentProviderClassArguments, EnchantmentProviderNode, EquipmentClassArguments, EquipmentNode, FontArguments, FontNode, HintedTagStringType, InstrumentClassArguments, InstrumentNode, ItemModelBuilder, ItemModelDefinitionClassArguments, ItemModelDefinitionInput, ItemModelDefinitionNode, ItemModifierClassArguments, ItemModifierNode, JukeboxSongClassArguments, JukeboxSongNode, LanguageArguments, LanguageNode, ListResource, LootTableClassArguments, LootTableNode, MCFunctionClassArguments, MCFunctionNode, MacroArgument, MacroLiteral, Macroable, ModelClassArguments, ModelNode, Node, ParticleClassArguments, ParticleNode, PlainTextArguments, PlainTextClass, PlainTextNode, PostEffectClassArguments, PostEffectNode, PredicateClassArguments, PredicateNode, RecipeClassArguments, RecipeNode, ResourceClass, ResourceClassArguments, ResourceNode, ResourceNodeConstructor, ResourceNodesMap, SandstoneCore, ShaderClass, ShaderClassArguments, ShaderNode, SoundEventArguments, SoundEventNode, SoundsIndexArguments, SoundsIndexNode, StructureClassArguments, StructureNode, SulfurCubeArchetypeClassArguments, SulfurCubeArchetypeNode, TagClassArguments, TagNode, TagSingleValue, TagValuesJSON, TestEnvironmentClassArguments, TestEnvironmentNode, TestInstanceClassArguments, TestInstanceNode, TextureArguments, TextureNode, TimelineClassArguments, TimelineNode, TradeSetClassArguments, TradeSetNode, TrialSpawnerClassArguments, TrialSpawnerNode, TrimMaterialClassArguments, TrimMaterialNode, TrimPatternClassArguments, TrimPatternNode, VariantClassArguments, VariantNode, VariantType, VillagerTradeClassArguments, VillagerTradeNode, WaypointStyleClassArguments, WaypointStyleNode, WorldClockClassArguments, WorldClockNode, _RawMCFunctionClass, isMacroArgument, jsonStringify } from '../../_internal/index.js'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { AdvancementNode, AtlasNode, AwaitNode, BannerPatternNode,
|
|
1
|
+
export { AdvancementNode, AtlasNode, AwaitNode, BannerPatternNode, BlockStateDefinitionNode, CallableResourceClass, ChatTypeNode, CommandNode, ConditionalDataPointPickClass, ContainerCommandNode, ContainerNode, CustomResourceClass, CustomResourceNode, DamageTypeNode, DataPointPickClass, DialogNode, EnchantmentNode, EnchantmentProviderNode, EquipmentNode, FontNode, InstrumentNode, ItemModelBuilder, ItemModelDefinitionNode, ItemModifierNode, JukeboxSongNode, LanguageNode, ListResource, LootTableNode, MCFunctionNode, MacroArgument, MacroLiteral, ModelNode, Node, ParticleNode, PlainTextClass, PlainTextNode, PostEffectNode, PredicateNode, RecipeNode, ResourceClass, ResourceNodesMap, SandstoneCore, ShaderClass, ShaderNode, SoundEventNode, SoundsIndexNode, StructureNode, SulfurCubeArchetypeNode, TagNode, TestEnvironmentNode, TestInstanceNode, TextureNode, TimelineNode, TradeSetNode, TrialSpawnerNode, TrimMaterialNode, TrimPatternNode, VariantNode, VillagerTradeNode, WaypointStyleNode, WorldClockNode, _RawMCFunctionClass, isMacroArgument, jsonStringify } from '../../_internal/index.js'
|
package/dist/exports/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Advancement, AdvancementClass, Atlas, AtlasClass, BannerPattern, BannerPatternClass,
|
|
1
|
+
export { Advancement, AdvancementClass, Atlas, AtlasClass, BannerPattern, BannerPatternClass, BlockStateDefinition, BlockStateDefinitionClass, ChatType, ChatTypeClass, Condition, ContentStrategyKind, DamageType, DamageTypeClass, Data, DataArray, DataIndexMap, DataPointClass, DataVariable, DatapackConfig, Dialog, DialogClass, Enchantment, EnchantmentClass, EnchantmentProvider, EnchantmentProviderClass, Equipment, EquipmentClass, Font, FontClass, HandlerFile, Instrument, InstrumentClass, ItemModelDefinition, ItemModelDefinitionClass, ItemModifier, ItemModifierClass, ItemPredicate, JukeboxSong, JukeboxSongClass, Label, LabelClass, Language, LanguageClass, LiteralUnion, LootTable, LootTableClass, MCFunction, MCFunctionClass, Macro, Model, ModelClass, NBT, NBTAllArrays, NBTAllNumberClasses, NBTAllNumbers, NBTAllPrimitives, NBTAllValues, NBTAnyValue, NBTByte, NBTByteArray, NBTClass, NBTDouble, NBTFloat, NBTInt, NBTIntArray, NBTList, NBTLong, NBTLongArray, NBTPrimitive, NBTRange, NBTShort, NBTSimpleClasses, NBTString, NBTTypedArray, NamespacedLiteralUnion, NotNBT, Objective, ObjectiveClass, ParticleClass, ParticleResource, PlainText, PostEffect, PostEffectClass, Predicate, PredicateClass, RawResource, Recipe, RecipeClass, ResolveNBT, ResolveNBTPart, ResolvedNBT, ResourcePackConfig, SandstoneConfig, SandstoneContext, SandstonePack, Score, Selector, SelectorClass, Set, SetType, Shader, SoundEvent, SoundEventClass, SoundsIndex, SoundsIndexClass, StructureClass, SulfurCubeArchetype, SulfurCubeArchetypeClass, Tag, TagClass, TestEnvironment, TestEnvironmentClass, TestInstance, TestInstanceClass, Texture, TextureClass, Timeline, TimelineClass, TradeSet, TradeSetClass, TrialSpawner, TrialSpawnerClass, Trigger, TrimMaterial, TrimMaterialClass, TrimPattern, TrimPatternClass, UUID, UUIDClass, Variable, Variant, VariantClass, VillagerTrade, VillagerTradeClass, WaypointStyle, WaypointStyleClass, WorldClock, WorldClockClass, _, abs, absolute, advancement, attribute, bossbar, clear, clone, comment, createSandstonePack, damage, data, datapack, debug, defaultNamespace, defaultgamemode, depend, dialog, difficulty, effect, enchant, execute, experience, fill, fillbiome, flowVariable, forceload, functionCmd, gamemode, gamerule, getExistingResource, getSandstoneContext, getTempStorage, getVanillaResource, give, hasContext, help, item, jfr, kill, list, loadTags, loc, local, locate, loot, makeCustomResource, mcMetaCache, me, msg, nbtResolver, particle, perf, place, playsound, random, randomUUID, raw, recipe, rel, relative, reload, resetContext, resetSandstonePack, returnCmd, ride, rotate, sandstonePack, say, schedule, scoreboard, seed, setSandstoneContext, setblock, setidletimeout, setworldspawn, sleep, spawnpoint, spectate, spreadplayers, stopsound, stopwatch, summon, swing, tag, team, teammsg, teleport, tell, tellraw, test, time, title, tm, tp, transfer, trigger, version, w, waypoint, weather, worldborder, xp } from '../_internal/index.js'
|
package/dist/exports/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Advancement, AdvancementClass, Atlas, AtlasClass, BannerPattern, BannerPatternClass,
|
|
1
|
+
export { Advancement, AdvancementClass, Atlas, AtlasClass, BannerPattern, BannerPatternClass, BlockStateDefinition, BlockStateDefinitionClass, ChatType, ChatTypeClass, DamageType, DamageTypeClass, Data, DataArray, DataIndexMap, DataPointClass, DataVariable, Dialog, DialogClass, Enchantment, EnchantmentClass, EnchantmentProvider, EnchantmentProviderClass, Equipment, EquipmentClass, Font, FontClass, Instrument, InstrumentClass, ItemModelDefinition, ItemModelDefinitionClass, ItemModifier, ItemModifierClass, ItemPredicate, JukeboxSong, JukeboxSongClass, Label, LabelClass, Language, LanguageClass, LootTable, LootTableClass, MCFunction, MCFunctionClass, Macro, Model, ModelClass, NBT, NBTAnyValue, NBTByte, NBTByteArray, NBTClass, NBTDouble, NBTFloat, NBTInt, NBTIntArray, NBTLong, NBTLongArray, NBTPrimitive, NBTShort, NBTString, NBTTypedArray, NotNBT, Objective, ObjectiveClass, ParticleClass, ParticleResource, PlainText, PostEffect, PostEffectClass, Predicate, PredicateClass, RawResource, Recipe, RecipeClass, ResolveNBT, ResolveNBTPart, ResolvedNBT, SandstonePack, Score, Selector, SelectorClass, Set, Shader, SoundEvent, SoundEventClass, SoundsIndex, SoundsIndexClass, StructureClass, SulfurCubeArchetype, SulfurCubeArchetypeClass, Tag, TagClass, TestEnvironment, TestEnvironmentClass, TestInstance, TestInstanceClass, Texture, TextureClass, Timeline, TimelineClass, TradeSet, TradeSetClass, TrialSpawner, TrialSpawnerClass, Trigger, TrimMaterial, TrimMaterialClass, TrimPattern, TrimPatternClass, UUID, UUIDClass, Variable, Variant, VariantClass, VillagerTrade, VillagerTradeClass, WaypointStyle, WaypointStyleClass, WorldClock, WorldClockClass, _, abs, absolute, advancement, attribute, bossbar, clear, clone, comment, createSandstonePack, damage, data, datapack, debug, defaultNamespace, defaultgamemode, depend, dialog, difficulty, effect, enchant, execute, experience, fill, fillbiome, flowVariable, forceload, functionCmd, gamemode, gamerule, getExistingResource, getSandstoneContext, getTempStorage, getVanillaResource, give, hasContext, help, item, jfr, kill, list, loadTags, loc, local, locate, loot, makeCustomResource, mcMetaCache, me, msg, nbtResolver, particle, perf, place, playsound, random, randomUUID, raw, recipe, rel, relative, reload, resetContext, resetSandstonePack, returnCmd, ride, rotate, sandstonePack, say, schedule, scoreboard, seed, setSandstoneContext, setblock, setidletimeout, setworldspawn, sleep, spawnpoint, spectate, spreadplayers, stopsound, stopwatch, summon, swing, tag, team, teammsg, teleport, tell, tellraw, test, time, title, tm, tp, transfer, trigger, version, w, waypoint, weather, worldborder, xp } from '../_internal/index.js'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ConditionClass, ConditionTextComponentClass, DATA_PATH, DATA_TARGET, DATA_TYPES, DataArrayClass, DataArrayInitial, DataClass, DataIndexMapClass, DataIndexMapInitial, EntityLabel, ItemPredicateClass, ItemPredicateItem, IterableDataClass, JSONTextComponentClass, LoopArgument, NBTpathToString, ResolveEntityValues, ResolveNBTClass, ResolveNBTPartClass, ScoreDisplay, SelectorEntityType, SelectorPickClass, SelectorProperties, SleepClass, StringDataPointClass, StructureMirror, StructureRotation, TargetFor, TargetlessDataClass, TargetlessDataPointClass, TextComponentClass, TriggerClass, TriggerHandler, UUIDOptions, UUIDSource, UUIDinNumber, UUIDinScore, VectorClass, _RawLabelClass, _RawObjectiveClass, coordinatesParser, parseJSONText, parseNBT, rangeParser, rotationParser, sanitizeValue, structureMirrorParser, structureRotationParser, targetParser } from '../../_internal/index.js'
|
|
1
|
+
export { ConditionClass, ConditionTextComponentClass, DATA_PATH, DATA_TARGET, DATA_TYPES, DataArrayClass, DataArrayInitial, DataArrayInternal, DataArrayType, DataClass, DataIndexMapClass, DataIndexMapInitial, DataIndexMapInternal, DataIndexMapType, EntityLabel, ItemPredicateClass, ItemPredicateItem, IterableDataClass, JSONTextComponentClass, LoopArgument, NBTpathToString, ResolveEntityValues, ResolveNBTClass, ResolveNBTPartClass, ScoreDisplay, SelectorEntityType, SelectorPickClass, SelectorProperties, SleepClass, StringDataPointClass, StructureMirror, StructureRotation, TargetFor, TargetlessDataClass, TargetlessDataPointClass, TextComponentClass, TriggerClass, TriggerHandler, UUIDOptions, UUIDSource, UUIDinNumber, UUIDinScore, VectorClass, _RawLabelClass, _RawObjectiveClass, coordinatesParser, parseJSONText, parseNBT, rangeParser, rotationParser, sanitizeValue, structureMirrorParser, structureRotationParser, targetParser } from '../../_internal/index.js'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ConditionClass, ConditionTextComponentClass, DataArrayClass, DataClass, DataIndexMapClass, EntityLabel, ItemPredicateClass, IterableDataClass, JSONTextComponentClass, LoopArgument, NBTpathToString, ResolveNBTClass, ResolveNBTPartClass, SelectorPickClass, SleepClass, StringDataPointClass, TargetlessDataClass, TargetlessDataPointClass, TextComponentClass, TriggerClass, VectorClass, _RawLabelClass, _RawObjectiveClass, coordinatesParser, parseJSONText, parseNBT, rangeParser, rotationParser, sanitizeValue, structureMirrorParser, structureRotationParser, targetParser } from '../../_internal/index.js'
|
|
1
|
+
export { ConditionClass, ConditionTextComponentClass, DataArrayClass, DataArrayInternal, DataClass, DataIndexMapClass, DataIndexMapInternal, EntityLabel, ItemPredicateClass, IterableDataClass, JSONTextComponentClass, LoopArgument, NBTpathToString, ResolveNBTClass, ResolveNBTPartClass, SelectorPickClass, SleepClass, StringDataPointClass, TargetlessDataClass, TargetlessDataPointClass, TextComponentClass, TriggerClass, VectorClass, _RawLabelClass, _RawObjectiveClass, coordinatesParser, parseJSONText, parseNBT, rangeParser, rotationParser, sanitizeValue, structureMirrorParser, structureRotationParser, targetParser } from '../../_internal/index.js'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sandstone",
|
|
3
3
|
"description": "Sandstone, a Typescript library for Minecraft datapacks & resource packs.",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.5",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
7
7
|
"name": "TheMrZZ - Florian ERNST",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@ampproject/remapping": "^2.3.0",
|
|
33
33
|
"@parcel/watcher": "^2.6.0",
|
|
34
|
-
"@sandstone-mc/mcdoc-ts-generator": "^0.3.
|
|
34
|
+
"@sandstone-mc/mcdoc-ts-generator": "^0.3.9",
|
|
35
35
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
36
36
|
"@types/fs-extra": "^11.0.4",
|
|
37
37
|
"@types/lodash": "^4.17.24",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"publishToNpm": "bun dev:build && bun publish",
|
|
72
72
|
"format": "bun oxlint src --fix",
|
|
73
73
|
"lint": "bun oxlint src",
|
|
74
|
-
"update-from-mcdoc": "
|
|
74
|
+
"update-from-mcdoc": "mcdoc-ts-generator --out-dir \"src/arguments/generated/\" --no-tsconfig"
|
|
75
75
|
},
|
|
76
76
|
"type": "module",
|
|
77
77
|
"main": "dist/exports/index.js",
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
VillagerTradeClass,
|
|
26
26
|
WorldClockClass,
|
|
27
27
|
AtlasClass,
|
|
28
|
-
|
|
28
|
+
BlockStateDefinitionClass,
|
|
29
29
|
EquipmentClass,
|
|
30
30
|
FontClass,
|
|
31
31
|
ItemModelDefinitionClass,
|
|
@@ -66,7 +66,7 @@ export const RESOURCE_CLASS_TYPES = [
|
|
|
66
66
|
[VillagerTradeClass, 'villager_trade'],
|
|
67
67
|
[WorldClockClass, 'world_clock'],
|
|
68
68
|
[AtlasClass, 'atlas'],
|
|
69
|
-
[
|
|
69
|
+
[BlockStateDefinitionClass, 'block_definition'],
|
|
70
70
|
[EquipmentClass, 'equipment'],
|
|
71
71
|
[FontClass, 'font'],
|
|
72
72
|
[ItemModelDefinitionClass, 'item_definition'],
|
|
@@ -26,7 +26,7 @@ export class PlaceCommand<MACRO extends boolean> extends CommandArguments {
|
|
|
26
26
|
* @param pos Optional. Where the placement should be tried.
|
|
27
27
|
*/
|
|
28
28
|
feature = (
|
|
29
|
-
feature: Macroable<Registry['minecraft:worldgen/
|
|
29
|
+
feature: Macroable<Registry['minecraft:worldgen/feature'], MACRO>,
|
|
30
30
|
pos: Macroable<Coordinates<MACRO>, MACRO> = '~ ~ ~' as Coordinates<MACRO>,
|
|
31
31
|
) => this.finalCommand(['feature', feature, coordinatesParser(pos)])
|
|
32
32
|
|
|
@@ -63,7 +63,7 @@ export class ItemModifierClass extends ResourceClass<ItemModifierNode> implement
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
for (const modifier of modifiers) {
|
|
66
|
-
let modifierJSON:
|
|
66
|
+
let modifierJSON: any
|
|
67
67
|
if (modifier instanceof ItemModifierClass) {
|
|
68
68
|
modifierJSON = modifier.itemModifierJSON
|
|
69
69
|
} else {
|
|
@@ -83,7 +83,7 @@ export class ItemModifierClass extends ResourceClass<ItemModifierNode> implement
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
for (const modifier of modifiers) {
|
|
86
|
-
let modifierJSON:
|
|
86
|
+
let modifierJSON: any
|
|
87
87
|
if (modifier instanceof ItemModifierClass) {
|
|
88
88
|
modifierJSON = modifier.itemModifierJSON
|
|
89
89
|
} else {
|
|
@@ -6,115 +6,115 @@ import type { ListResource, ResourceClassArguments, ResourceNode } from '../reso
|
|
|
6
6
|
import { ResourceClass, jsonStringify } from '../resource'
|
|
7
7
|
import type { AllKeys } from 'sandstone/utils'
|
|
8
8
|
|
|
9
|
-
export type
|
|
10
|
-
export type
|
|
9
|
+
export type BlockStateDefinitionJSON = NonNullable<MCDocToJSON<SymbolResource['block_definition']>>
|
|
10
|
+
export type BlockStateDefinitionType = AllKeys<BlockStateDefinitionJSON>
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* A node representing a Minecraft block state.
|
|
13
|
+
* A node representing a Minecraft block state definition.
|
|
14
14
|
*/
|
|
15
|
-
export class
|
|
15
|
+
export class BlockStateDefinitionNode<JSON extends BlockStateDefinitionJSON>
|
|
16
16
|
extends ContainerNode
|
|
17
|
-
implements ResourceNode<
|
|
17
|
+
implements ResourceNode<BlockStateDefinitionClass<JSON>> {
|
|
18
18
|
constructor(
|
|
19
19
|
sandstoneCore: SandstoneCore,
|
|
20
|
-
public resource:
|
|
20
|
+
public resource: BlockStateDefinitionClass<JSON>,
|
|
21
21
|
) {
|
|
22
22
|
super(sandstoneCore)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
getValue = () => jsonStringify(this.resource.
|
|
25
|
+
getValue = () => jsonStringify(this.resource.blockStateDefinitionJSON, this.resource._resourceType as keyof typeof RESOURCE_PATHS)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export type
|
|
28
|
+
export type BlockStateDefinitionArguments<JSON extends BlockStateDefinitionJSON> = {
|
|
29
29
|
/**
|
|
30
|
-
* The block state's JSON.
|
|
30
|
+
* The block state definition's JSON.
|
|
31
31
|
*/
|
|
32
32
|
json: JSON
|
|
33
33
|
} & ResourceClassArguments<'list'>
|
|
34
34
|
|
|
35
|
-
export class
|
|
36
|
-
extends ResourceClass<
|
|
35
|
+
export class BlockStateDefinitionClass<JSON extends BlockStateDefinitionJSON, Type = Extract<AllKeys<JSON>, BlockStateDefinitionType>>
|
|
36
|
+
extends ResourceClass<BlockStateDefinitionNode<JSON>>
|
|
37
37
|
implements ListResource {
|
|
38
38
|
static readonly resourceType = 'block_definition'
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
blockStateDefinitionJSON: JSON
|
|
41
41
|
|
|
42
42
|
type: Type
|
|
43
43
|
|
|
44
44
|
constructor(
|
|
45
45
|
core: SandstoneCore,
|
|
46
46
|
name: string,
|
|
47
|
-
args:
|
|
47
|
+
args: BlockStateDefinitionArguments<JSON>,
|
|
48
48
|
) {
|
|
49
49
|
super(
|
|
50
50
|
core,
|
|
51
51
|
{ packType: core.pack.resourcePack() },
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
core.pack.resourceToPath(name, RESOURCE_PATHS[
|
|
52
|
+
BlockStateDefinitionNode,
|
|
53
|
+
BlockStateDefinitionClass.resourceType,
|
|
54
|
+
core.pack.resourceToPath(name, RESOURCE_PATHS[BlockStateDefinitionClass.resourceType].path),
|
|
55
55
|
args,
|
|
56
56
|
)
|
|
57
57
|
|
|
58
|
-
this.
|
|
58
|
+
this.blockStateDefinitionJSON = args.json
|
|
59
59
|
|
|
60
|
-
this.type = Object.keys(this.
|
|
60
|
+
this.type = Object.keys(this.blockStateDefinitionJSON)[0] as Type
|
|
61
61
|
|
|
62
62
|
this.handleConflicts()
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
push(...states:
|
|
65
|
+
push(...states: BlockStateDefinitionClass<any, Type>[] | BlockStateDefinitionJSON[]) {
|
|
66
66
|
if (this.type === 'variants') {
|
|
67
|
-
if (states[0] instanceof
|
|
67
|
+
if (states[0] instanceof BlockStateDefinitionClass) {
|
|
68
68
|
for (const state of states) {
|
|
69
69
|
/** @ts-ignore */
|
|
70
|
-
this.
|
|
70
|
+
this.blockStateDefinitionJSON.variants = { ...this.blockStateDefinitionJSON.variants, ...state.blockStateDefinitionJSON.variants }
|
|
71
71
|
}
|
|
72
72
|
} else {
|
|
73
73
|
for (const state of states) {
|
|
74
74
|
/** @ts-ignore */
|
|
75
|
-
this.
|
|
75
|
+
this.blockStateDefinitionJSON.variants = { ...this.blockStateDefinitionJSON.variants, ...state.variants }
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
if (this.type === 'multipart') {
|
|
80
|
-
if (states[0] instanceof
|
|
80
|
+
if (states[0] instanceof BlockStateDefinitionClass) {
|
|
81
81
|
for (const state of states) {
|
|
82
82
|
/** @ts-ignore */
|
|
83
|
-
this.
|
|
83
|
+
this.blockStateDefinitionJSON.multipart.push(...state.blockStateDefinitionJSON.multipart)
|
|
84
84
|
}
|
|
85
85
|
} else {
|
|
86
86
|
for (const state of states) {
|
|
87
87
|
/** @ts-ignore */
|
|
88
|
-
this.
|
|
88
|
+
this.blockStateDefinitionJSON.multipart.push(...state.multipart)
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
unshift(...states:
|
|
94
|
+
unshift(...states: BlockStateDefinitionClass<any, Type>[] | BlockStateDefinitionJSON[]) {
|
|
95
95
|
if (this.type === 'variants') {
|
|
96
|
-
if (states[0] instanceof
|
|
96
|
+
if (states[0] instanceof BlockStateDefinitionClass) {
|
|
97
97
|
for (const state of states) {
|
|
98
98
|
/** @ts-ignore */
|
|
99
|
-
this.
|
|
99
|
+
this.blockStateDefinitionJSON.variants = { ...state.blockStateDefinitionJSON.variants, ...this.blockStateDefinitionJSON.variants }
|
|
100
100
|
}
|
|
101
101
|
} else {
|
|
102
102
|
for (const state of states) {
|
|
103
103
|
/** @ts-ignore */
|
|
104
|
-
this.
|
|
104
|
+
this.blockStateDefinitionJSON.variants = { ...state.variants, ...this.blockStateDefinitionJSON.variants }
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
if (this.type === 'multipart') {
|
|
109
|
-
if (states[0] instanceof
|
|
109
|
+
if (states[0] instanceof BlockStateDefinitionClass) {
|
|
110
110
|
for (const state of states) {
|
|
111
111
|
/** @ts-ignore */
|
|
112
|
-
this.
|
|
112
|
+
this.blockStateDefinitionJSON.multipart.unshift(...state.blockStateDefinitionJSON.multipart)
|
|
113
113
|
}
|
|
114
114
|
} else {
|
|
115
115
|
for (const state of states) {
|
|
116
116
|
/** @ts-ignore */
|
|
117
|
-
this.
|
|
117
|
+
this.blockStateDefinitionJSON.multipart.unshift(...state.multipart)
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
}
|
package/src/flow/Flow.ts
CHANGED
|
@@ -58,17 +58,37 @@ export class Flow {
|
|
|
58
58
|
if = (condition: Condition, callback: () => void) =>
|
|
59
59
|
new IfStatement(this.sandstoneCore, conditionToNode(condition), callback)
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Combine conditions with AND.
|
|
63
|
+
*
|
|
64
|
+
* Accepts either variadic conditions (`_.and(a, b, c)`) or a single array
|
|
65
|
+
* (`_.and([a, b, c])`, useful for `Array.prototype.map` results).
|
|
66
|
+
*/
|
|
67
|
+
and(...conditions: Condition[]): AndNode
|
|
68
|
+
and(conditions: Condition[]): AndNode
|
|
69
|
+
and(...args: any[]): AndNode {
|
|
70
|
+
const conditions = (args[0] instanceof Array ? args[0] : args) as Condition[]
|
|
71
|
+
return new AndNode(
|
|
63
72
|
this.sandstoneCore,
|
|
64
73
|
conditions.map((condition) => conditionToNode(condition)),
|
|
65
74
|
)
|
|
75
|
+
}
|
|
66
76
|
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Combine conditions with OR.
|
|
79
|
+
*
|
|
80
|
+
* Accepts either variadic conditions (`_.or(a, b, c)`) or a single array
|
|
81
|
+
* (`_.or([a, b, c])`, useful for `Array.prototype.map` results).
|
|
82
|
+
*/
|
|
83
|
+
or(...conditions: Condition[]): OrNode
|
|
84
|
+
or(conditions: Condition[]): OrNode
|
|
85
|
+
or(...args: any[]): OrNode {
|
|
86
|
+
const conditions = (args[0] instanceof Array ? args[0] : args) as Condition[]
|
|
87
|
+
return new OrNode(
|
|
69
88
|
this.sandstoneCore,
|
|
70
89
|
conditions.map((condition) => conditionToNode(condition)),
|
|
71
90
|
)
|
|
91
|
+
}
|
|
72
92
|
|
|
73
93
|
not = (condition: Condition) => new NotNode(this.sandstoneCore, conditionToNode(condition))
|
|
74
94
|
|
|
@@ -20,7 +20,14 @@ export class CommandConditionNode extends SingleConditionNode {
|
|
|
20
20
|
const store = sandstoneCore.pack.commands.execute.store[type]
|
|
21
21
|
this.variable = sandstoneCore.pack.Variable(undefined, 'condition')
|
|
22
22
|
|
|
23
|
+
// Snapshot before/after so commands the callback commits land in `preNodes` instead of
|
|
24
|
+
// staying on the user MCFunction body, where they'd be stranded when visitor extraction
|
|
25
|
+
// moves the surrounding condition chain elsewhere.
|
|
26
|
+
const mcFunction = sandstoneCore.getCurrentMCFunctionOrThrow()
|
|
27
|
+
const before = mcFunction.body.length
|
|
23
28
|
command(store(this.variable))
|
|
29
|
+
const after = mcFunction.body.length
|
|
30
|
+
this.preNodes = mcFunction.body.splice(before, after - before)
|
|
24
31
|
}
|
|
25
32
|
|
|
26
33
|
getCondition(): unknown[] {
|
|
@@ -18,6 +18,15 @@ export type GenericConditionType = {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export abstract class ConditionNode extends Node {
|
|
21
|
+
/**
|
|
22
|
+
* Optional commands that must run before this condition's predicate is evaluated.
|
|
23
|
+
* Conditions that emit side-effect commands at construction time (e.g. `data.equals`
|
|
24
|
+
* building an `execute store result ...`) capture them here so the visitor pass can
|
|
25
|
+
* re-emit them at the correct location — inline before the IfNode, or inside the
|
|
26
|
+
* child MCFunction when AND/OR extracts. Pure predicates leave it unset.
|
|
27
|
+
*/
|
|
28
|
+
preNodes?: Node[]
|
|
29
|
+
|
|
21
30
|
abstract getValue: (negated?: boolean) => string
|
|
22
31
|
}
|
|
23
32
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NBTObject } from 'sandstone/arguments/nbt'
|
|
2
|
-
import type { DataPointPickClass, SandstoneCore } from 'sandstone/core'
|
|
2
|
+
import type { DataPointPickClass, Node, SandstoneCore } from 'sandstone/core'
|
|
3
3
|
import type { DataPointClass, Score } from 'sandstone/variables'
|
|
4
4
|
import { SingleConditionNode } from '../condition'
|
|
5
5
|
|
|
@@ -29,11 +29,19 @@ export class DataPointEqualsConditionNode extends SingleConditionNode {
|
|
|
29
29
|
const { DataVariable, Variable, commands } = sandstoneCore.pack
|
|
30
30
|
const { execute } = commands
|
|
31
31
|
|
|
32
|
+
// Snapshot the user MCFunction body length before/after the entire side-effecting
|
|
33
|
+
// sequence — both the `data modify ... set from <source>` emitted by DataVariable (which
|
|
34
|
+
// copies the source into the anonymous storage) AND the `execute store result ... set
|
|
35
|
+
// value` written by `execute.store.result().run()`. They belong together: the first
|
|
36
|
+
// loads the data, the second overwrites it with `value`, and the subsequent
|
|
37
|
+
// `if score matches 0..` only makes sense after both have run.
|
|
38
|
+
const mcFunction = sandstoneCore.getCurrentMCFunctionOrThrow()
|
|
39
|
+
const before = mcFunction.body.length
|
|
32
40
|
const anon = DataVariable(this.dataPoint)
|
|
33
|
-
|
|
34
41
|
this.conditional = Variable()
|
|
35
|
-
|
|
36
42
|
execute.store.result(this.conditional).run(() => anon.set(this.value as unknown as DataPointClass))
|
|
43
|
+
const after = mcFunction.body.length
|
|
44
|
+
this.preNodes = mcFunction.body.splice(before, after - before)
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
getValue = (negated?: boolean) =>
|
package/src/pack/pack.ts
CHANGED
|
@@ -24,12 +24,11 @@ import type {
|
|
|
24
24
|
AdvancementClassArguments,
|
|
25
25
|
AtlasClassArguments,
|
|
26
26
|
BannerPatternClassArguments,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
BlockStateDefinitionArguments,
|
|
28
|
+
BlockStateDefinitionJSON,
|
|
29
29
|
ChatTypeClassArguments,
|
|
30
30
|
DamageTypeClassArguments,
|
|
31
31
|
DataPointPickClass,
|
|
32
|
-
// DecoratedPotPatternClassArguments,
|
|
33
32
|
DialogClassArguments,
|
|
34
33
|
EnchantmentClassArguments,
|
|
35
34
|
EnchantmentProviderClassArguments,
|
|
@@ -52,7 +51,6 @@ import type {
|
|
|
52
51
|
PredicateClassArguments,
|
|
53
52
|
RecipeClassArguments,
|
|
54
53
|
ShaderClassArguments,
|
|
55
|
-
// SlotSourceClassArguments,
|
|
56
54
|
SoundEventArguments,
|
|
57
55
|
SoundsIndexArguments,
|
|
58
56
|
SulfurCubeArchetypeClassArguments,
|
|
@@ -76,10 +74,9 @@ import {
|
|
|
76
74
|
AdvancementClass,
|
|
77
75
|
AtlasClass,
|
|
78
76
|
BannerPatternClass,
|
|
79
|
-
|
|
77
|
+
BlockStateDefinitionClass,
|
|
80
78
|
ChatTypeClass,
|
|
81
79
|
DamageTypeClass,
|
|
82
|
-
// DecoratedPotPatternClass,
|
|
83
80
|
DialogClass,
|
|
84
81
|
EnchantmentClass,
|
|
85
82
|
EnchantmentProviderClass,
|
|
@@ -102,7 +99,6 @@ import {
|
|
|
102
99
|
RecipeClass,
|
|
103
100
|
SandstoneCore,
|
|
104
101
|
ShaderClass,
|
|
105
|
-
// SlotSourceClass,
|
|
106
102
|
SoundEventClass,
|
|
107
103
|
SoundsIndexClass,
|
|
108
104
|
SulfurCubeArchetypeClass,
|
|
@@ -140,9 +136,11 @@ import type {
|
|
|
140
136
|
} from 'sandstone/variables'
|
|
141
137
|
import {
|
|
142
138
|
coordinatesParser,
|
|
143
|
-
|
|
139
|
+
DataArrayType,
|
|
140
|
+
DataArrayInternal,
|
|
144
141
|
DataClass,
|
|
145
|
-
|
|
142
|
+
DataIndexMapType,
|
|
143
|
+
DataIndexMapInternal,
|
|
146
144
|
DataPointClass,
|
|
147
145
|
ItemPredicateClass,
|
|
148
146
|
LabelClass,
|
|
@@ -316,11 +314,11 @@ export class SandstonePack {
|
|
|
316
314
|
}
|
|
317
315
|
return {
|
|
318
316
|
datapack: {
|
|
319
|
-
packFormat:
|
|
317
|
+
packFormat: 111,
|
|
320
318
|
description: 'A Sandstone datapack',
|
|
321
319
|
},
|
|
322
320
|
resourcepack: {
|
|
323
|
-
packFormat:
|
|
321
|
+
packFormat: 92,
|
|
324
322
|
description: 'A Sandstone resource pack',
|
|
325
323
|
},
|
|
326
324
|
}
|
|
@@ -446,7 +444,7 @@ export class SandstonePack {
|
|
|
446
444
|
let pack = this.packTypes.get('datapack') as DataPack
|
|
447
445
|
|
|
448
446
|
if (!pack) {
|
|
449
|
-
const options = this.packOptions.datapack ?? { packFormat:
|
|
447
|
+
const options = this.packOptions.datapack ?? { packFormat: 111, description: 'A Sandstone datapack' }
|
|
450
448
|
pack = this.packTypes.set('datapack', new DataPack(false, options)).get('datapack') as DataPack
|
|
451
449
|
}
|
|
452
450
|
|
|
@@ -457,7 +455,7 @@ export class SandstonePack {
|
|
|
457
455
|
let pack = this.packTypes.get('resourcepack') as ResourcePack
|
|
458
456
|
|
|
459
457
|
if (!pack) {
|
|
460
|
-
const options = this.packOptions.resourcepack ?? { packFormat:
|
|
458
|
+
const options = this.packOptions.resourcepack ?? { packFormat: 92, description: 'A Sandstone resource pack' }
|
|
461
459
|
pack = this.packTypes
|
|
462
460
|
.set('resourcepack', new ResourcePack(options))
|
|
463
461
|
.get('resourcepack') as ResourcePack
|
|
@@ -467,11 +465,12 @@ export class SandstonePack {
|
|
|
467
465
|
}
|
|
468
466
|
|
|
469
467
|
setupLantern = () => {
|
|
470
|
-
const loadStatus = this.Objective.create('load.status', 'dummy', undefined, { useDefaultNamespace: false })
|
|
468
|
+
const loadStatus = this.Objective.create('load.status', 'dummy', undefined, { useDefaultNamespace: false, alreadyExists: true })
|
|
471
469
|
|
|
472
470
|
const privateInit = this.Tag('function', 'load:_private/init', [
|
|
473
471
|
this.MCFunction('load:_private/init', () => {
|
|
474
472
|
this.commands.comment('Reset scoreboards so packs can set values accurate for current load.')
|
|
473
|
+
this.commands.scoreboard.objectives.add(loadStatus.name, 'dummy')
|
|
475
474
|
loadStatus.reset()
|
|
476
475
|
}),
|
|
477
476
|
])
|
|
@@ -832,14 +831,14 @@ export class SandstonePack {
|
|
|
832
831
|
initialize: INITIAL,
|
|
833
832
|
dataPoint?: DataPointClass<'storage'>,
|
|
834
833
|
) {
|
|
835
|
-
return
|
|
834
|
+
return DataIndexMapInternal(this, initialize, dataPoint) as DataIndexMapType<INITIAL>
|
|
836
835
|
}
|
|
837
836
|
|
|
838
837
|
DataArray<INITIAL extends readonly NBTObject[] | readonly [string, DataPointClass | DataPointPickClass]>(
|
|
839
838
|
initialize: INITIAL,
|
|
840
839
|
dataPoint?: DataPointClass<'storage'>,
|
|
841
840
|
) {
|
|
842
|
-
return
|
|
841
|
+
return DataArrayInternal(this, initialize, dataPoint) as DataArrayType<INITIAL>
|
|
843
842
|
}
|
|
844
843
|
|
|
845
844
|
getTempStorage = (name: string) => {
|
|
@@ -1123,15 +1122,6 @@ export class SandstonePack {
|
|
|
1123
1122
|
...options,
|
|
1124
1123
|
})
|
|
1125
1124
|
|
|
1126
|
-
// DecoratedPotPattern = (name: string, decoratedPotPattern: NonNullable<SymbolResource['decorated_pot_pattern']>, options?: Partial<DecoratedPotPatternClassArguments>) =>
|
|
1127
|
-
// new DecoratedPotPatternClass(this.core, name, {
|
|
1128
|
-
// json: decoratedPotPattern,
|
|
1129
|
-
// creator: 'user',
|
|
1130
|
-
// addToSandstoneCore: true,
|
|
1131
|
-
// onConflict: conflictDefaults('decorated_pot_pattern') as DecoratedPotPatternClassArguments['onConflict'],
|
|
1132
|
-
// ...options,
|
|
1133
|
-
// })
|
|
1134
|
-
|
|
1135
1125
|
ItemModifier = (name: string, itemModifier: ItemModifierClassArguments['json'], options?: Omit<Partial<ItemModifierClassArguments>, 'json'>) =>
|
|
1136
1126
|
new ItemModifierClass(this.core, name, {
|
|
1137
1127
|
json: itemModifier,
|
|
@@ -1172,15 +1162,6 @@ export class SandstonePack {
|
|
|
1172
1162
|
...options,
|
|
1173
1163
|
})
|
|
1174
1164
|
|
|
1175
|
-
// SlotSource = (name: string, slotSource: NonNullable<SymbolResource['slot_source']>, options?: Partial<SlotSourceClassArguments>) =>
|
|
1176
|
-
// new SlotSourceClass(this.core, name, {
|
|
1177
|
-
// json: slotSource,
|
|
1178
|
-
// creator: 'user',
|
|
1179
|
-
// addToSandstoneCore: true,
|
|
1180
|
-
// onConflict: conflictDefaults('slot_source') as SlotSourceClassArguments['onConflict'],
|
|
1181
|
-
// ...options,
|
|
1182
|
-
// })
|
|
1183
|
-
|
|
1184
1165
|
SulfurCubeArchetype = (name: string, sulfurCubeArchetype: SulfurCubeArchetypeClassArguments['json'], options?: Omit<Partial<SulfurCubeArchetypeClassArguments>, 'json'>) =>
|
|
1185
1166
|
new SulfurCubeArchetypeClass(this.core, name, {
|
|
1186
1167
|
json: sulfurCubeArchetype,
|
|
@@ -1366,16 +1347,16 @@ export class SandstonePack {
|
|
|
1366
1347
|
...options,
|
|
1367
1348
|
})
|
|
1368
1349
|
|
|
1369
|
-
|
|
1350
|
+
BlockStateDefinition<JSON extends BlockStateDefinitionJSON>(
|
|
1370
1351
|
name: string,
|
|
1371
1352
|
json: JSON,
|
|
1372
|
-
options?: Omit<Partial<
|
|
1353
|
+
options?: Omit<Partial<BlockStateDefinitionArguments<JSON>>, 'json'>,
|
|
1373
1354
|
) {
|
|
1374
|
-
return new
|
|
1355
|
+
return new BlockStateDefinitionClass(this.core, name, {
|
|
1375
1356
|
json,
|
|
1376
1357
|
creator: 'user',
|
|
1377
1358
|
addToSandstoneCore: true,
|
|
1378
|
-
onConflict: conflictDefaults('
|
|
1359
|
+
onConflict: conflictDefaults('block_definition') as BlockStateDefinitionArguments<JSON>['onConflict'],
|
|
1379
1360
|
...options,
|
|
1380
1361
|
})
|
|
1381
1362
|
}
|