Commands
#
BasicsIn Sandstone, all commands can directly be imported from sandstone
:
When typing a command or a subcommand, there are two possibilities:
The command/subcommand has several subcommands, like
effect give|clear
. To access a subcommand, access it as a property:effect.give
oreffect.clear
The command/subcommand has no subcommands. It directly has argument, like
enchant
. To specify the arguments, call it as a normal function:enchant("@a", "minecraft:sharpness")
A command can have multiple subcommands, which all have arguments: effect.give('@a', 'minecraft:speed', 30, 2)
or effect.clear('@a', 'minecraft:night_vision')
.
caution
A command is only written to the datapack if it has been called. For example, some commands do not have any arguments, like /reload
. In Sandstone, you'd have to type reload()
. Only typing reload
will not call the command, and nothing will appear in your datapack.
#
ExamplesHere is the command to give 64 diamonds to all players:
Here is the command to give Speed II to all players:
Here is the command to grant all advancements to all players:
#
Try it out#
DocumentationUse VSCode autocompletion to show you what arguments/property should be used on each command.
Sandstone includes the Wiki documentation on each command, and for each parameter: you can look it up to understand what a command or a parameter does.
This example shows that Sandstone hints you what arguments are needed, and tell you what they actually do:
#
Optional argumentsIn Minecraft, some commands have optional arguments. Let's stay with the /effect give
command. According to the Wiki, It has 2 to 5 arguments:
/effect give <targets> <effect> [<seconds>] [<amplifier>] [<hideParticles>]
As you can see, the targets
and the effect
arguments are mandatory. Minecraft doesn't know what to do if you do not provide them. However, the seconds
, amplifier
and hideParticles
arguments are all optionals. If you do not specify them, Minecraft uses default values.
In this aspect, Sandstone is identical to Minecraft. When typing effect.give()
, your IDE will show you the possible arguments:
As you can see, the targets
and the effect
argument are not followed by a question mark ?
. It means they are mandatory, just like in Minecraft. However, the seconds
, amplifier
and hideParticles
arguments are followed by a question mark ?
: Sandstone does not require them.
This feature is very useful: you don't have to remember the syntax of all commands, Sandstone does that for you. Also, Sandstone gives you precise documentation on the behaviour of each command: you don't have to check the Wiki anymore!
#
Try it out#
Execute#
Single commandSandstone has a special syntax for the /execute
command. At its core, it looks just like Minecraft:
Calling a single command looks similar too:
This will result in execute as @a at @s run setblock ~ ~ ~ minecraft:dirt
.
#
Try it out:In Sandstone, run
is used to execute single and multiple commands.
Here is how you could execute multiple commands with run
:
Let's see a live example to understand what Sandstone does under the hood.
As you can see, Sandstone automatically created a new MCFunction for you (here, called main/execute_as
). It contains all your nested commands (all the setblocks), and is called by the execute
command. Therefore, you achieve the desired effect without managing several files youself.