Selectors
You can use Sandstone to create any selector, in an easy and type-safe way.
#
The basics#
General SyntaxTo create a selector, you need to provide the target and the arguments to Selector
:
The first part is the targets
: it can be @s
, @r
, @p
, @a
or @e
.
The second par is the arguments
. In this object, you can specify any property that would fit into a vanilla selector:
#
UsageTo use selectors, you need to assign them to a variable, and pass them to a command:
#
Special ArgumentsWhile most arguments work exactly like the vanilla ones, some of them have a few particularities.
#
Scores#
General syntaxFor the 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 8..
or ..19
), you can use null
or Infinity
:
[8, null]
and[8, +Infinity]
both become8..
[null, 19]
and[-Infinity, 19]
both become..19
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:
#
Matching a Sandstone objectiveIf you want to use an existing objective, you can use the following ES6 syntax:
#
Advancements#
General syntaxAdvancements 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:
#
Matching a criteriaTo 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:
#
Matching a Sandstone AdvancementIn order to use a Sandstone advancement in a selector, you can use the following ES6 syntax:
#
TagsEntity tags can be either specified as a single string, or an array of strings.
#
Predicates#
General SyntaxJust like tags, you can match one or several predicates at once. This is done using a string or an array of strings.
#
Matching a Sandstone PredicateIn order to use a Sandstone predicate in a selector, you just need to use the variable like you would use a string:
#
TeamThe 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.