Target Selectors
Usage
Minecraft target selectors can be created and used using the minecraft:target type. minecraft:target is stored internally as strings and can be used in macro scenerios. Currently target selectors are WIP and are missing key features. More uses for them will be added over time.
Target selectors can be implicitly created using the same syntax as they do in commands:
var target = @e[x=8,dx=9,name="Steve"];
But they can also have dynamic values like so:
int my_number = 7;
var target = @e[x=my_number];
String arguments like name and type must be quoted strings or else Amethyst will look for a variable with that name.
Many of the arguments have not been implemented.
Negation
Some arguments can be negated by putting a ! after the equal sign. Additionally, multiple arguments of the same name can exist.
// The ! has to go outside the quotes
var target = @e[type=!"player"];
var target = @e[type="!item"]; // Error
Variables can be negated as well.
var foo = "player";
var bar = "item";
var target = @e[type=!foo, type=!bar];
Some arguments allow empty values which are internally represented as empty strings, so the following is possible:
var foo = "";
var target = @e[tag=, team=!foo];
Few checks have been implemented for invalid combinations of arguments. Check the Minecraft logs for errors generated on /reload. Adding -c to your build command dumps the compiled .mcfunctions to the console for easy viewing. Running with Daemon Mode will give helpful error messages.
Existence Checks
Target selectors can be put in if Execute Statement clauses which effectively use execute if entity to determine if the entity exists:
if (@s[type="minecraft:player"]) {
@/say I am a player!
}
Target selectors can also be converted to boolean values. The result is true if execute if entity is successful.
Unsafe Strings
Some target selector arguments, like tag and team, only accept alphanumeric strings. To support this, a special unsafe_string type is available that does not have any of the safeguards that normal strings have. See the Minecraft Wiki for valid strings.
unsafe_string tag = "womp";
@/summon wither
@/tag @e[type=wither] add $(tag)
if (@e[tag=tag]) {
print("yay");
}
@/kill @e[type=wither]
As such, unsafe_string can be used in macro arguments without restrictions.