You can use Sandstone to create any selector, in an easy and type-safe way.
To create a selector, you need to provide the target and the arguments to
The first part is the
targets: it can be
The second par is the
arguments. In this object, you can specify any property that would fit into a vanilla selector:
To use selectors, you need to assign them to a variable, and pass them to a command:
While most arguments work exactly like the vanilla ones, some of them have a few particularities.
scores argument, you can specify a whole number or a range. Ranges are made using an array:
[0, 7] becomes
0..7. If you need an open-ended range (like
..19), you can use
[8, +Infinity]both become
[-Infinity, 19]both become
Here is an exemple of a selector that checks if a player has more than 10 kills, less than 50 coins and exactly 0 deaths:
If you want to use an existing objective, you can use the following ES6 syntax:
Advancements arguments in Sandstone selectors work precisely like they would in-game, but their complicated syntax deserves a reminder.
To ensure the player has the
minecraft:story:/form_obsidian advancement, you would use the following syntax:
To select player who wore at least once a full iron armor, you would do:
To select players who wore at least once a iron helmet, you would do:
As you can see, matching a single (or several) advancements criteria is done using a nested object. In the end, the syntax could be defined as:
In order to use a Sandstone advancement in a selector, you can use the following ES6 syntax:
Entity tags can be either specified as a single string, or an array of strings.
Just like tags, you can match one or several predicates at once. This is done using a string or an array of strings.
In order to use a Sandstone predicate in a selector, you just need to use the variable like you would use a string:
team argument has the same syntax than the vanilla one, but has a built-in feature to check for the lack or the presence of a team. You can use
true to check for entities having a team, and
false for entities that are not inside a team.