-
Notifications
You must be signed in to change notification settings - Fork 0
Selector Usage
For info about the selector expression syntax, go here
After writing a selector as the start of a statement, you can use it as a target to minecraft commands that need a selector.
So if you have the following code:
tick {
@a.kill()
}
The output will be kill @a.
Selector commands are used by accessing the selector with a dot, like the /kill example above.
Additionally, a dot after a selector can access an objective to change its value for that entity. More info in Objectives.
effect(effect: TieredEffect, duration?: Duration, hide?: 'hide')
- Gives the specified effect to the entity/s.
-
effect: The effect ID + tier to give. Written in the format of [tier]. The tier can be an integer or a roman number. (Examples: jump_boost II, regeneration, haste IV, etc.) -
duration(optional): The duration to give the effect for. A duration expression is any combination of integer+time unit. (Examples: 10s, 2m 40s, 2h 5m, 3d 4h 10m, 400t). The time units dont have to be adjacent to the number. -
hide(optional): Simply add the 'hide' keyword to hide the effect particles. - Example:
@a.effect(speed II, 30s, hide) // => /effect give @a speed 30 1 true
cure(*)
- Clears all effects from the target entities
cure(effectId: identifier)
- Clears the specified effect type from the target entities
-
effectId: The ID of the effect to remove - Example:
@creeper.cure(poison)
gamemode = <gamemodeId>
- Changes the gamemode of the player
-
gamemodeId: A gamemode ID can be the identifier of the gamemode or its index (survival = 0, creative = 1, adventure = 2, spectator = 3) - Example:
@a.gamemode = 0 // => /gamemode survival @a
kill()
- Kills the selected entities
grant(*)
- Grants/Revokes all advancements from the selected players
grant(advancement: Advancement)
- Grants/Revokes only the specified advancement from the players
-
advancement: The advancement ID, story/root, minecraft:end/kill_dragon, etc. - You can add . after the advancement ID to grant/revoke only a specific criterion in the advancement.
- Example:
@a.grant(story/mine_stone)
@a.revoke(adventure/adventuring_time.mountains)
grant({from | until | through} <Advancement>)
- Grants/Revokes a range of advancements
-
from: Grants/Revokes the specified advancement and all of its children -
until: Grants/Revokes the specified advancement and all of its ancestors up to the root advancement -
through: Grants/Revokes the specified advancement, all of its ancestors and all of its children. - Example:
@a.grant(from story/mine_stone)
@a.grant(through end/the_next_generation)
@a.revoke(until nether/uneasy_alliance)
give(item: Item, count?: int)
- Gives the specified item to the target player/s
-
item: The item ID + optional NBT to give -
count(optional): The amount of that item to give - Example:
@a.give(diamond{name:"Blue Shiny Rock"}, 64)
clear(item?: TaggableItem, count?: int)
- Clears items from the inventory of the player.
-
item(optional): The item predicate to clear. If unspecified, clears all items from the inventory. -
count(optional): The maximum number of items to clear from the inventory - Example:
@a.clear(#wool,24)
count(item: TaggableItem)
- Works similar to
clear(), but the count is set to 0, so no items are being cleared, but the number of items in the inventory are returned (and can be stored in scores, NBTs, and bossbars) - Example:
@s.stoneInInv = result(@s.count(stone))