You are viewing the Target Selectors tutorial
Tutorial Selection
Tutorial Contents
A "target selector" is the intended target for the command you're trying to run. Commands that require a target selector are asking for the entity you intend to run the command as, from or on. This tutorial will discuss everything from the different target selectors to each individual target selector filter available.
Note: There is a lot of information throughout this tutorial, if you'd like to search through it quicker, there are some methods that you can use. If you're using a computer, you can search for information using [Ctrl] + [F]. For mobile devices, some browsers have a "Find in page" or "Find on page" option (usually located in the top right).
If at any point during this tutorial, you see information contained in less than and greater than symbols, it is a space in which you must enter that information. For example, if you see <username>, you'd replace that with the username in the command. The symbols themselves should also be replaced and not included in your command.
The most basic form of target selection is using a player's username/gamertag instead of a selector. When inputting a username as opposed to a selector, you do not need to use the @ symbol. If the username you are trying to input as the target contains spaces, you'll need to use quotation marks. Some examples:
You may whisper to a specific user by typing any of the below commands
/w <username> <message>
/msg <username> <message>
/tell <username> <message>
Aside from using a username/gamertag as the target, you may use what is called a "target selector". Information regarding these are below.
Selecting the nearest player (@p)
The "@p" target selector will select the nearest player entity based on where or who the command is executed from. If the command is executed from a player, the closest player will always be the player who the command is executed from. If the command is executed from a location, the closest player to that location will become the target of the command. In Bedrock Edition, the "@p" target selector will only select players who are alive. Here is an example use of this selector:
This command will whisper your given message to the nearest player to you
/w @p <message>
Note: If there are multiple users detected as the "nearest player" (multiple players are at the exact same distance from the command executor or command's execution point), the player who joined most recently will be selected.
Selecting the nearest player (@n)
The "@n" target selector will select the nearest entity based on where or who the command is executed from. If the command is executed from an entity, the closest entity (any kind) will always be the entity who the command is executed from. If the command is executed from a location, the closest entity (any kind) to that location will become the target of the command. In Bedrock Edition, the "@n" target selector will only select entities who are alive. Here is an example use of this selector:
This command will kill the entity closest to the command executor or the command execution point
/kill @n
Selecting a random player (@r)
The "@r" target selector will select a random player entity. In Bedrock Edition, the "@r" target selector can be used for non-player entities, if they're specified using a target selector filter such as type or family. Additionally, in Bedrock Edition, the "@r" target selector will only select players who are alive. Here are some example uses of this selector:
This command will whisper your given message to a randomly chosen player
/w @r <message>
This command will kill a randomly chosen entity based on the type you provide
/kill @r[type=<entity>]
Selecting all players (@a)
The "@a" target selector will select ALL player entities. This target selector will select players regardless of whether or not they are dead. This selector will target everyone unless target selector filters are used. Here are some example uses of this selector:
This command will whisper your given message to every player entity
/w @a <message>
This command will teleport every player entity to the specified coordinates
/tp @a <x> <y> <z>
Selecting all entities (@e)
The "@e" target selector will select ALL entities (this includes players) in any rendered chunks. This selector will target every entity unless target selector filters are used. Here are some example uses of this selector:
This command will kill every existing entity within any chunks that are rendered
/kill @e
This command will teleport every entity within any chunks that are rendered to the specified coordinates
/tp @e <x> <y> <z>
Selecting the command executor (@s)
The "@s" target selector will select the command executor. The command executor is the entity or command block that the command is run as but not from. If a command uses the "@s" target selector in a command block and the command doesn't specifically run as an entity, the "command executor" is the command block. Here is an example use of this selector:
Here is a command to give the command executor a single item
/give @s <item>
If a player runs this command, the command will give the specified item to that player
If a command block runs this command, the command will fail as command blocks can't receive items
Selecting the NPC command executor (@initiator)
The "@initiator" target selector is used only inside of an NPC GUI. This target selector can not be used by commands run as the player or a command block. The "@initiator" target selector will target the player who presses a button inside of an NPC GUI. Here are some example uses of this selector:
If the following command is assigned to a button inside of an NPC's GUI, the player who presses the button will receive the specified item
/give @initiator <item>
If the following command is assigned to a button inside of an NPC's GUI, the player who pressed the button will be teleported to the specified coordinates
/tp @initiator <x> <y> <z>
Positional target selector filters can be used to narrow down target selection based on location. The types of positional target selector filters include coordinates (x, y and z), distance (otherwise referred to as radius) and volume (otherwise referred to as difference values, distance values or d-values). Positional target selector filters can not be duplicated, they may only be entered once per target selector.
A "coordinate" positional target selector filter will define a starting position in the target selector. To define a starting position using "coordinate" position target selector filters, you would enter an x-axis, y-axis or z-axis value. Please note that coordinate filters are double variables. Coordinate values can be found in the top left corner of your screen once enabled through commands (using /gamerule) or in the game settings menu. Coordinates are shown in the order of x, y and z and start at an entity's feet, not head. Distance and volume positional target selector filters as well as the count target selector filter will use the coordinate filters as a start position. You would type the coordinate filters as x=<value>, y=<value> and z=<value>. Tilde notation (~) may also be used with coordinate filters but caret notation (^) may not. Coordinate target selector filters may not be duplicated in the same target selector.
Note: In Bedrock Edition, if a user inputs an integer value, the value will automatically be centre-corrected; this means that a value such as x=0 would become x=0.5.
This teleport command defines coordinate positional filters using 0, 0, 0 as the values and a distance positional filter using a value of 5. The command will teleport all players within a 5-block spherical radius of 0, 0, 0 to the entity or command block that runs the command.
/tp @a[x=0,y=0,z=0,r=5] @s
This effect command defines coordinate positional filters using 27, 5, 19 as the values and a distance positional filter using a value of 3. The coordinate positional filters have been centre-corrected. The command will apply the speed 2 effect to all players within a 3-block spherical radius of 27.5, 5.5, 19.5 for 5 seconds when an entity or command block runs the command.
/effect @a[x=27,y=5,z=19,r=3] speed 5 1
This kill command defines coordinate positional filters using -12, 7, -25 as the values and volume positional filters all using values of 5. The coordinate positional filters have been adapted so they are not centre-corrected. The command will kill all players within a 5 by 5 by 5 cubic volume with the starting corner being at coordinates -12.0, 7.0, -25.0 and following each axis positively when an entity or command block runs the command.
/kill @a[x=-12.0,y=7.0,z=-25.0,dx=4,dy=4,dz=4]
A "distance" positional target selector filter will define a radius utilising a starting position in the target selector. To define a radius using "distance" positional target selector filters, you would enter an unsigned integer value to set either a radius maximum (r), radius minimum (rm) or both. Both the radius maximum (r) and radius minimum (rm) target selector filters will default to using the command executor's position or the command execution point as the starting position. The starting position can be changed using coordinate positional target selector filters. You would type the distance filters as r=<value> and rm=<value>. Neither of these distance filters can be duplicated in the same target selector. Setting a radius maximum (r) will target all of the specified entities (dependant on other target selector filters) within a spherical radius of the given unsigned integer value, centred from the target selector's starting position. Setting a radius minimum (rm) will exclude all of the specified entities (again, dependant on other target selector filters) within a spherical radius of the given unsigned integer value, which is also centred from the target selector's starting position.
This teleport command defines distance positional filters using the command's default starting position as the centre (this would be the entity or command block running the command in this specific example due to no defined coordinate positional filters). The command will teleport all players within a 5-block spherical radius centred on the starting position to the command's executor (the entity) or execution point (the command block).
/tp @a[r=5] @s
This effect command defines coordinate positional filters using 5, 7, 11 as the values (thus, setting a starting position) and distance positional filters using values of 1 (rm, radius minimum) and 3 (r, radius maximum). The coordinate positional filters have been centre-corrected. The command will apply the speed 2 effect to all players who are within a 3-block spherical radius centred on 5.5, 7.5, 11.5 for 5 seconds when an entity or command block runs the command; however, they must also not be within a 1-block spherical radius centred on the same position. This means all players within the distance created between both spherical radii will receive the effect.
/effect @a[x=5,y=7,z=11,rm=1,r=3] speed 5 1
This kill command defines coordinate positional filters using -15, -9, 21 as the values and distance positional filters using values of 7 (rm, radius minimum) and 7 (r, radius maximum). The coordinate positional filters have been adapted so they are not centre-corrected. The command will kill all players exactly 7 blocks away in a spherical radius centred on -15.0, -9.0, 21.0 when an entity or command block runs the command.
/kill @a[x=-15.0,y=-9.0,z=21.0,rm=7,r=7]
Image Example A
Image Example B
A "volume" positional target selector filter (commonly referred to as "difference values", "distance values" or "d-values") will define an area by volume using the starting position in the target selector. To define a volume utilising a "volume" positional target selector filter, you would enter double values (decimals) or integer values (whole numbers). Just like when calculating volume with anything else, Minecraft will calculate the volumetric area using the formula width x height x length. You may use the "volume" positional target selector filters to create a three-dimensional space in which you can detect entities. The volumetric area will be created based on the distance you specify with your values and the starting position given in the target selector. The starting position can be modified using coordinate positional target selector filters. You would type the volume filters as dx=<value>, dy=<value> and dz=<value>. None of these volume filters can be duplicated in the same target selector. It should be noted that volumetric values start at 0, resulting in the following formula being used to calculate the value total length of area on axis - 1. If coordinate positional target selector filters are not specified, the command will utilise the default starting position, this will be the command executor's position or the command execution point unless specified otherwise. Volumetric values will accept any type of double or integer value, this includes positive and negative values. Any volumetric values left out will default to a value of 0.
Note: In Bedrock Edition, volumetric values require the entity's feet to be inside of the area to select the target.
Common Misinterpretation: Volumetric values are not a second pair of coordinates, they're distance values.
This teleport command defines volume positional filters using the command's default starting position (this would be the entity or command block running the command in this specific example due to no defined coordinate positional filters). The command will teleport all players within a 5 (dx) by 5 (dy) by 5 (dz) volumetric area (125 blocks) starting from the starting position and following each axis positively for each distance.
/tp @a[dx=4,dy=4,dz=4] @s
This effect command defines coordinate positional filters using 5, 0, 3 as the values (thus, setting a starting position) and volume positional filters using values of -2 (dx), 0 (dy) and -2 (dz). The coordinate positional filters have been centre-corrected. The command will apply the fire resistance 2 effect for 20 seconds to all players who are within a 3 (dx) by 1 (dy) by 3 (dz) volumetric area (9 blocks) starting from 5.5, 0.5, 3.5 and following the axis positively for volume values that are positive but negatively for volume values that are negative.
/effect @a[x=5,y=0,z=3,dx=-2,dy=0,dz=-2] fire_resistance 20 1
This kill command defines coordinate positional filters using 25, 0, -253 as the values (thus, setting a starting position) and volume positional filters using values of 0 (dx), 0 (dy) and 0 (dz). The coordinate positional filters have been adapted so they are not centre-corrected. The command will kill all player entities whose feet collide with the block at 25, 0, -253 exactly. This is due to the coordinate positional filters being centre-corrected and the volume positional filters creating a volume of 1 block.
/kill @a[x=25,y=0,z=-253,dx=0,dy=0,dz=0]
Image Example A
Image Example B
Score target selector filters can be used to narrow down target selection based on an entity's score in a scoreboard objective. Tag target selector filters can be used to narrow down target selection based on the tags that an entity has. Using the scores and tag filters is the way to do this. Score arguments can't be duplicated, which means they can't be entered twice in the same target selector. You may test for multiple scores in the same filter, however. Tag target selector filters can be duplicated, allowing the choice of targeting entities with multiple tags.
A "score" target selector filter will narrow down the target selection based on score values that an entity has in one or more scoreboard objectives. To define the score target selector filter, you would need to input signed integer values (whole numbers), this is because scoreboard objectives only support integers and not double values (decimals). Utilising a score target selector filter will allow you to select targets that meet a specific score, targets that have a score greater than or less than the specified score or targets that have a score between a set range. The score selector filter can't be duplicated inside of the same target selector, though you may check multiple score objectives at once in the same filter. You would type the score target selector filter with scores={<objective>=<value>}. You can edit this to check for multiple scores by typing scores={<objective>=<value>,<objective>=<value>}.
Note: In Bedrock Edition, you may test if scores do not equal the set value parameters. To do this, you would need to input an exclamation mark. You'd do this by typing scores=!{<objective>=<value>}.
Common Mistake: Scoreboard objective names are case-sensitive, meaning a scoreboard objective called "money" is unique to that of one called "Money".
This teleport command defines a score target selector filter with a value of 5. The command will teleport all players who have a score value of 5 in the scoreboard objective "money" to the command executor or command's execution point when an entity or command block runs the command.
/tp @a[scores={money=5}] @s
This teleport command defines a score target selector filter with a value of -20. The command will teleport all players who have a score value of -20 in the scoreboard objective "Money" to the command executor or command's execution point when an entity or command block runs the command.
/tp @a[scores={Money=-20}] @s
This teleport command defines two score target selector filters with values of 5 and 1. The command will teleport all players who have a score value of 5 in the scoreboard objective "money" but also do not have a score value of 1 in the scoreboard objective "Level" to the command executor or command's execution point when an entity or command block runs the command.
/tp @a[scores={money=5,Level=!1}] @s
This kill command defines a score target selector filter with a value of 12 or greater. The command will kill all players who have a score value of 12 or higher in the scoreboard objective "points" when an entity or command block runs the command.
/kill @a[scores={points=12..}]
This kill command defines a score target selector filter with a value of -10 or greater. The command will kill all players who have a score value of -10 or higher in the scoreboard objective "Points" when an entity or command block runs the command.
/kill @a[scores={Points=-10..}]
This kill command defines two score target selector filters with values of 12 or greater and 3 or greater. The command will kill all players who have a score value of 12 or higher in the scoreboard objective "points" but also do not have a score value of 3 or higher in the scoreboard objective "Level" when an entity or command block runs the command.
/kill @a[scores={points=12..,Level=!3..}]
This kill command defines a score target selector filter with a value of 15 or less. The command will kill all players who have a score value of 15 or lower in the scoreboard objective "points" when an entity or command block runs the command.
/kill @a[scores={points=..15}]
This kill command defines a score target selector filter with a value of -30 or less. The command will kill all players who have a score value of -30 or lower in the scoreboard objective "Points" when an entity or command block runs the command.
/kill @a[scores={Points=..-30}]
This kill command defines two score target selector filters with values of 5 or less and 10 or less. The command will kill all players who have a score value of 5 or lower in the scoreboard objective "points" but also do not have a score value of 10 or lower in the scoreboard objective "Level" when an entity or command block runs the command.
/kill @a[scores={points=..5,Level=!..10}]
This scoreboard command defines a score target selector filter for any value between 80 and 99 (includes 80 and 99 themselves). The command will change the "xp_target" scores for all players who have a score value between 80 and 99 in the scoreboard objective "current_xp" when an entity or command block runs the command. The new "xp_target" value will be 120 for those players.
/scoreboard players set @a[scores={current_xp=80..99}] xp_target 120
This scoreboard command defines a score target selector filter for any value between -30 and -1 (includes -30 and -1 themselves). The command will change the "Points" scores for all players who have a score value between -30 and -1 in the scoreboard objective "Points" when an entity or command block runs the command. The new "Points" value will be 0 for those players.
/scoreboard players set @a[scores={Points=-30..-1}] Points 0
This effect command defines two score target selector filters with ranges 50 to 100 and 1 to 25 (includes 50, 100, 1 and 25 themselves). The command will apply the wither 1 effect to all players who have a score value between 50 and 100 in the scoreboard objective "corruption" but also do not have a score value between 1 and 25 in the scoreboard objective "Level" when an entity or command block runs the command. The effect will last for 10 seconds and have a strength of 1 (wither I).
/effect @a[scores={corruption=50..100,Level=!1..25}] wither 10 0 true
A "tag" target selector filter will narrow down the target selection based on the tags that an entity has. Tags should be a single string of characters with no spaces. If you'd like a tag to have multiple words in it, you can use the snake case naming convention (e.g. two_words or this_tag_has_lots_of_words). To enter a tag target selector filter you would write tag=<string>. You may use exclusion to check if an entity does not have a tag, to do this you would add an exclamation mark, like so: tag=!<string>.
Note: You may test if an entity has multiple tags. To do this, you would need to duplicate the tag target selector filter in the target selector. You'd do this by typing tag=<string>,tag=<string>. The entity needs to have both tags in cases like this, not one or the other. You may also use exclusion when checking for multiple tags.
Common Mistake: Tag names are case-sensitive, meaning a tag called "zombie" is unique to that of one called "Zombie".
This teleport command defines a tag target selector filter called "blue_team". The command will teleport all players who have the tag "blue_team" to the command executor's position.
/tp @a[tag=blue_team] @s
This effect command defines a tag target selector filter called "safe". The command will apply the poison 3 effect to all players who do not have the tag "safe". The effect will last for 60 seconds and have a strength of 3 (poison III).
/effect @a[tag=!safe] poison 60 2
This kill command defines two tag target selector filters called "infected_zone" and "immune". The command will kill all players who have the "infected_zone" tag but also do not have the "immune" tag. Players with both the "infected_zone" and "immune" tags will be safe, the target must meet ALL of the specified tag requirements.
/kill @a[tag=infected_zone,tag=!immune]
Name target selector filters can be used to narrow down target selection based on an entity's name. Type target selection filters can be used to narrow down target selection based on a type of entity. Family target selection filters can be used to narrow down target selection based on the family an entity belongs to. You would use name, type and family filters to do this. An entity can not have more than one name or type and therefore these filters may not be entered twice in the same target selector unless testing for exclusion. The family target selector filter may be duplicated to check if an entity does or does not belong in multiple families.
A "name" target selector filter will narrow down the target selection based on the name of an entity. Names must be a single string of characters, spaces can be included but will require the string to be contained within quotation marks. To clarify, names with no spaces can be entered without quotation marks; names with spaces must be contained within quotation marks. To enter the name target selector filter you would write name=<string>. You may also use exclusion and test for inequality by typing name=!<string>. The name target selector filter may not be duplicated unless testing for inequality.
Note: A name target selector filter is not case-sensitive, meaning that an entity named "player" is the same as one called "Player"
This teleport command defines a name target selector filter called "Zombie". The command will teleport all entities who have the name "Zombie" to the command executor's position.
/tp @e[name=Zombie] @s
This effect command defines a name target selector filter called "Skeleton King". The command will apply the wither 1 effect to all entities who do not have the name "Skeleton King". The effect will last for 10 seconds and have a strength of 1 (wither I).
/effect @e[name=!"Skeleton King"] wither 10 0
This kill command defines two name target selector filters called "Zombie" and "Skeleton". The command will kill all entities that do not have the name "Zombie" or "Skeleton". Any entity with either of the names "Zombie" or "Skeleton" will be safe, other entities without those names are eliminated.
/kill @e[name=!"Zombie",name=!"Skeleton"]
A "type" target selector filter allows you to narrow down target selection based on the type of entity. You must input the type as a single string of characters, an underscore should be used instead of a space (e.g. snow golem becomes snow_golem). To input the type target selector filter you would write type=<string>. Exclusion can be used to test for inequality by typing type=!<string>.The type target selector filter may not be duplicated unless testing for inequality. Only entityIDs can be used in type target selector filters, a full list is available below.
Last updated for version 1.21.93 and sorted into alphabetical order
A
allay
area_effect_cloud
armadillo
armor_stand
arrow
axolotl
B
bat
bee
blaze
boat
bogged
breeze
C
camel
cat
cave_spider
chest_boat
chicken
cod
command_block_minecart
cow
creaking
creeper
D
dolphin
donkey
dragon_fireball
drowned
E
egg
elder_guardian
elder_guardian_ghost
ender_crystal
ender_dragon
ender_pearl
enderman
endermite
evocation_fang
evocation_illager
F
falling_block
fireball
fireworks_rocket
fishing_hook
fox
frog
G
ghast
glow_squid
goat
guardian
H
hoglin
hopper_minecart
horse
husk
I
iron_golem
item
L
leash_knot
lightning_bolt
lingering_potion
llama
llama_spit
M
magma_cube
minecart
N
npc
O
ocelot
P
painting
panda
parrot
phantom
pig
piglin
piglin_brute
pillager
player
polar_bear
pufferfish
R
rabbit
ravager
S
salmon
sheep
shulker
shulker_bullet
silverfish
skeleton
skeleton_horse
slime
small_fireball
sniffer
snow_golem
snowball
spider
splash_potion
squid
stray
strider
T
tadpole
thrown_trident
tnt
tnt_minecart
trader_llama
tropicalfish
turtle
V
vex
villager
villager_v2
vindicator
W
wandering_trader
warden
witch
wither
wither_skeleton
wither_skull
wither_skull_dangerous
wolf
X
xp_bottle
xp_orb
Z
zoglin
zombie
zombie_horse
zombie_pigman
zombie_villager
zombie_villager_v2
This teleport command defines a type target selector filter for all player entities. The command will teleport all entities who are of the "player" type and teleport them to the command executor's position.
/tp @e[type=player] @s
This effect command defines a type target selector filter for all entities that are not of the "zombie" type. The command will apply the jump boost 2 effect to all entities who are not under the "zombie" type of entity. The effect will last for 15 seconds and have a strength of 2 (jump boost II).
/effect @e[type=!zombie] jump_boost 15 1
This kill command defines two type target selector filters for both "armor stand" and "skeleton" entity types. The command will kill all entities that are not armour stands or skeletons. Armour stands and skeletons will remain safe.
/kill @e[type=!armor_stand,type=!skeleton]
A "family" target selector filter allows you to narrow down target selection based on the family an entity belongs to. The "family" target selector filter needs to be a single string of characters, underscores should be used instead of spaces (e.g. adult piglin becomes adult_piglin). To input the family target selector filter you would write family=<string>. You may use exclusion to test for inequality by inputting family=!<string>. You may duplicate the family target selector filter in both instances (with exclusion and without). You must enter a valid type_family behaviour component when using this target selector filter, a full list of valid family entries is available here.
This teleport command defines a family target selector filter for all entities that are a part of the "arthropod" family (see the list of family entries for affected entities). The command will teleport all entities that are apart of this family to the command executor's position.
/tp @e[family=arthropod] @s
This effect command defines a family target selector filter for all entities that are NOT a part of the "arthropod" family (see the list of family entries for affected entities). The command will apply the instant health 1 effect to all entities who meet this criteria. The effect will last for 1 second and have a strength of 1 (instant health I).
/effect @e[family=!arthropod] instant_health 1 0
This kill command defines two family target selector filters for both the "monster" and "undead" families. The command will kill all entities who are a part of the "monster" family but are also not a part of the "undead" family. Only entities who match the above criteria will be affected (see the list of family entries for affected entities).
/kill @e[family=monster,family=!undead]
Vertical rotation target selector filters (rx and rxm) can be used to narrow down target selection based on an entity's pitch. Horizontal rotation target selector filters (ry and rym) can be used to narrow down target selection based on an entity's yaw. The item target selector filter (hasitem) may be used to narrow down target selection based on what items an entity has. The property target selector filter (has_property) may be used to narrow down target selection based on certain properties an entity has. You may use the item target selector filter to check for one or multiple items, but the filter itself can not be duplicated. Vertical/horizontal rotation target selector filters and the property target selector filter are also not able to be duplicated.
Understanding vertical and horizontal rotation
Standard coordinate systems use the x-axis, y-axis and z-axis. The x-axis (generally left to right, or west and east) and z-axis (generally forward and backwards, or north and south) are based on the horizon, and the y-axis (up and down) is based on vertical direction. Rotation around the y-axis (yaw) is the sort of rotation you'd get if you shook your head as if you were saying "no". Rotation around the z-axis (roll) is the sort of rotation you'd get from tilting your head from side to side. Rotation around the x-axis (pitch) is the sort of rotation you'd get if you shook your head as if you were saying "yes". When using target selector filters for vertical and horizontal rotation, the target selection is being filtered based on the rotation an entity is looking on those axes.
Understanding cardinal directions in Minecraft
In Minecraft, there are a few ways to discover which direction you're travelling in/looking at. A very common method people use is noting that the sun rises in the east and sets in the west. Another common method is using a sunflower, as they always point east. Whilst these methods are useful, there is also the ability to check using coordinates. Your coordinates are displayed as X (the 1st number), Y (the 2nd number) and Z (the 3rd number). Using this, we can tell which way we're going, or which way we're looking. The first number (X) represents east and west. If the number is increasing, you're going east; if the number is decreasing, you're going west. The second number (Y) represents your height. If the number is increasing, you're going higher; if the number is decreasing, you're going lower. The third number (Z) represents north and south. If the number is increasing, you're going south; if the number is decreasing, you're going north.
A "vertical rotation" target selector filter will narrow down target selection based on the pitch of an entity (rotation on the x-axis). Vertical rotation (rx) and minimum vertical rotation (rxm) target selector filters require you to input integer values (whole numbers). You can use any integer value up to a maximum of 90 (looking directly down) and minimum of -90 (looking directly up). Remember, vertical rotation is based on rotation around the x-axis, so we're detecting entities based on high or low they're looking (above, at or below the horizon). To use these target selector filters you would write rx=<value> and rxm=<value>. Exclusion can not be used with either of the vertical rotation target selection filters, and they may also not be duplicated.
This teleport command defines a vertical rotation (rx) and minimum vertical rotation (rxm) target selection filter for narrowing down target selection based on entities who are looking directly at the horizon. The command will teleport all entities who are looking directly at the horizon to the command executor's position.
/tp @a[rx=0,rxm=0] @s
This effect command defines a vertical rotation (rx) and minimum vertical rotation (rxm) target selection filter for narrowing down target selection based on entities who are looking at the angle between 30° and 60°. The command will apply the instant damage 1 effect to all entities who are looking within the specified angle. The effect will last for 1 second and have a strength of 2 (instant damage II).
/effect @a[rx=60,rxm=30] instant_damage 1 1
This kill command defines a vertical rotation (rx) target selection filter for narrowing down target selection based on entities who are looking at or above the horizon because there was no minimum vertical rotation (rxm) target selection filter set. The command will kill any entity that is looking at or above the horizon.
/kill @e[rx=0]
A "horizontal rotation" target selector filter will narrow down target selection based on the yaw of an entity (rotation on the y-axis). Horizontal rotation (ry) and minimum horizontal rotation (rym) target selector filters require you to input integer values (whole numbers). Any integer value up to a maximum of 180 to a minimum of -180 can be used. Remember, horizontal rotation is based on rotation around the y-axis, so we're detecting entities based on which direction they're looking at (north, east, west, south, etc). To use these target selector filters you would write ry=<value> and rym=<value>. Exclusion can not be used with either of the horizontal rotation target selection filters, and they may also not be duplicated.
To help you out when using the horizontal rotation target selection filters, here are some value to direction conversions:
North (N) equals 180 or -180
North East (NE) equals -135
East (E) equals -90
South East (SE) equals -45
South (S) equals 0
South West (SW) equals 45
West (W) equals 90
North West (NW) equals 135
This teleport command defines a horizontal rotation (ry) and minimum horizontal rotation (rym) target selection filter for narrowing down target selection based on entities who are looking directly south. The command will teleport all entities who are looking directly south to the command executor's position.
/tp @a[ry=0,rym=0] @s
This effect command defines a horizontal rotation (ry) and minimum horizontal rotation (rym) target selection filter for narrowing down target selection based on entities who are looking at the angle between 0° (south) and -90° (east). The command will apply the instant damage 1 effect to all entities who are looking within the specified angle. The effect will last for 1 second and have a strength of 2 (instant damage II).
/effect @a[ry=0,rym=-90] instant_damage 1 1
This kill command defines a horizontal rotation (ry) and minimum horizontal rotation (rym) target selection filter for narrowing down target selection based on entities who are looking at who are looking at the angle between 180° (north) and 0° (south). The command will kill any entity that is not facing east within the 180° angle between north and south.
/kill @e[ry=180,rym=0]
Horizontal Rotation Values Diagram
This diagram shows examples of how you would use the horizontal rotation target selection filters to narrow down target selection based on the rotation around the y-axis. As depicted by the diagram:
Players looking at the angle between north west (NW) and north east (NE) can be targeted by using rym=135,ry=-135 in your target selector.
Players looking at the angle between north east (NE) and south east (SE) can be targeted by using rym=-135,ry=-45 in your target selector.
Players looking at the angle between south west (SW) and south east (SE) can be targeted by using rym=-45,ry=45 in your target selector.
Players looking at the angle between north west (NW) and south west (SW) can be targeted by using rym=45,ry=135 in your target selector.
The "hasitem" target selector filter narrows down target selection based on the items an entity has. In addition to checking for items, you're able to check the quantity, data, and location of said items. The "hasitem" target selector filter is split into several subsequent parameters. These subsequent parameters, or arguments, are "item", "quantity", "data", "location", and "slot". These arguments are to be embedded into a set of key-value pairs (otherwise referred to as a compound tag), located within the "hasitem" target selector filter, enclosed in curley braces {}. You would write the "hasitem" target selector filter by typing hasitem={<argument>=<value>}. Each hasitem filter can contain multiple subsequent parameters. You can only use each argument once per item (e.g. you can not check for the quantity of the same item twice, even if it's the same value). It is possible to use all 5 subsequent parameters within a single pair of braces, you'd do so by typing hasitem={item=<value>,quantity=<value>,data=<value>,location=<value>,slot=<value>}. The "hasitem" target selector filter can not be duplicated; however, it is possible to check for multiple items at the same time by typing hasitem=[{<argument>=<value>},{<argument>=<value>}], where each pair of braces {} defines the criteria for a different item. Exclusion can only be used with specific subsequent parameters.
The "item" subsequent parameter is used to define the type of item you want to use within the "hasitem" target selector filter. The "item" argument only accepts item IDs (e.g. diamond_sword). You may write the "item" subsequent parameter by typing item=<item_id>. The "item" argument is not optional, this error message will be given if it is left out:
'item' missing, required for 'hasitem' filter.
Exclusion can not be used with this subsequent parameter.
This testfor command defines a hasitem target selection filter for narrowing down target selection based on entities who have a diamond on them. It uses the "item" subsequent parameter to define the item as a "diamond". The command will provide a message stating a player was found if a player with a diamond on them is found. If a player is not found, a message indicating the search has failed will be shown.
/testfor @a[hasitem={item=diamond}]
This kill command defines a hasitem target selection filter for narrowing down target selection based on entities who have an iron ingot on them. It uses the "item" subsequent parameter to define the item as an "iron ingot". The command will kill any player who has an iron ingot.
/kill @a[hasitem={item=iron_ingot}]
This teleport command defines a hasitem target selection filter for narrowing down target selection based on entities who have both a diamond and an iron ingot on them. It uses the "item" subsequent parameter to define two items, a "diamond" and an "iron ingot". The command will teleport any player who has both a diamond and an iron ingot to the command executor's position.
/tp @a[hasitem=[{item=diamond},{item=iron_ingot}]] @s
The "quantity" subsequent parameter is used to define the amount of the given item type you want to check for within the "hasitem" target selector filter. "Quantity" can be used to check for exact amounts, values equal to or greater than, values equal to or less than, and values between two ranges. The "quantity" argument only accepts integer values, in addition to syntax that represents "greater than", "less than" and "within a range". The "quantity" argument is optional and doesn't need to be included. The exact way to write this subsequent parameter changes depending on what you aim to achieve with it:
Checking for exact matches
Syntax: quantity=<value>
Example: quantity=5
Checking for matches equal to or greater than
Syntax: quantity=<value>..
Example: quantity=5..
Checking for matches equal to or less than
Syntax: quantity=..<value>
Example: quantity=..5
Checking for matches between a range
Syntax: quantity=<value>..<value>
Example: quantity=1..5
Exclusion can be used with this subsequent parameter to check if an entity does not have the specified amount of the defined item. To do so, include an exclamation point directly after the equals sign in any of the above provided syntax (e.g. quantity=!5).
Note: Whilst these examples are to showcase the "quantity" subsequent parameter, the "item" subsequent parameter is required, an item must be specified to avoid being presented with an error message.
This testfor command defines a hasitem target selection filter for narrowing down target selection based on entities who have exactly 5 diamonds on them. It uses the "item" subsequent parameter to define the item as a "diamond" and the "quantity" subsequent parameter to define the quantity as "5". The command will provide a message stating a player was found if a player with exactly 5 diamonds on them is found. If a player is not found, a message indicating the search has failed will be shown.
/testfor @a[hasitem={item=diamond,quantity=5}]
This kill command defines a hasitem target selection filter for narrowing down target selection based on entities who have 3 iron ingots or more on them. It uses the "item" subsequent parameter to define the item as an "iron ingot" and the "quantity" subsequent parameter to define the quantity as "3" or more, the ".." after "3" indicates "or more". The command will kill any player who has 3 iron ingots or more.
/kill @a[hasitem={item=iron_ingot,quantity=3..}]
This kill command defines a hasitem target selection filter for narrowing down target selection based on entities who have 3 gold ingots or less on them. It uses the "item" subsequent parameter to define the item as a "gold ingot" and the "quantity" subsequent parameter to define the quantity as "3" or less, the ".." before "3" indicates "or less". The command will kill any player who has 3 gold ingots or less.
/kill @a[hasitem={item=gold_ingot,quantity=..3}]
This kill command defines a hasitem target selection filter for narrowing down target selection based on entities who have between 3 and 5 copper ingots on them. It uses the "item" subsequent parameter to define the item as a "copper ingot" and the "quantity" subsequent parameter to define the quantity as a value between "3" and "5", the ".." between "3" and "5" indicates "between a range". The command will kill any player who has 3 to 5 copper ingots.
/kill @a[hasitem={item=copper_ingot,quantity=3..5}]
This teleport command defines a hasitem target selection filter for narrowing down target selection based on entities who have exactly 4 diamonds, 2 or more iron ingots, 3 or less gold ingots, and between 1 to 4 copper ingots on them. It uses the "item" subsequent parameter to define four items, a "diamond", an "iron ingot", a "gold ingot" and a "copper ingot". Additionally, it defines a "quantity" subsequent parameter for each of those items. The command will teleport any player who has exactly 4 diamonds, 2 or more iron ingots, 3 or less gold ingots and between 1 to 4 copper ingots to the command executor's position. Players must meet ALL conditions for the command to have a successful output. The command will fail if any one of the conditions are not met.
/tp @a[hasitem=[{item=diamond,quantity=4},{item=iron_ingot,quantity=2..},{item=gold_ingot,quantity=..3},{item=copper_ingot,quantity=1..4}]] @s
This testfor command defines a hasitem target selection filter for narrowing down target selection based on entities who don't have exactly 5 diamonds on them. It uses the "item" subsequent parameter to define the item as a "diamond" and the "quantity" subsequent parameter to define the quantity as not "5", the exclamation point before the "5" is exclusion and means "does not equal". The command will provide a message stating a player was found if a player without exactly 5 diamonds on them is found. If a player is not found, a message indicating the search has failed will be shown.
/testfor @a[hasitem={item=diamond,quantity=!5}]
The "data" subsequent parameter is used to define the data value associated with the given item type you're checking for within the "hasitem" target selector filter. The "data" argument only accepts 32-bit integer values. The "data" argument is optional and doesn't need to be included; however, if left out, it will be given a default value of 0. You may write the "data" subsequent parameter by typing data=<value>. Exclusion can not be used with this subsequent parameter. Data values start at 0, not 1; a "data" subsequent parameter set to a value of "2" is actually the 3rd value.
Note: This subsequent parameter has arguably been made more redundant due to flattening changes (e.g. wool colours now being given their own unique item identifiers). Previously, to check for red wool, you'd write item=wool,data=14 (14 being the data value associated to red wool); in the latest versions of Minecraft, you can now write item=red_wool. However, it is still possible to use data values for anything that has been flattened.
Note: Whilst these examples are to showcase the "data" subsequent parameter, the "item" subsequent parameter is required, an item must be specified to avoid being presented with an error message.
This testfor command defines a hasitem target selection filter for narrowing down target selection based on entities who have red wool on them. It uses the "item" subsequent parameter to define the item as a "wool" (an old item ID prior to flattening changes which referred to all wool blocks) and the "data" subsequent parameter to define the data as "14" (the data value assigned to red wool). The command will provide a message stating a player was found if a player with red wool on them is found. If a player is not found, a message indicating the search has failed will be shown.
/testfor @a[hasitem={item=wool,data=14}]
This kill command defines a hasitem target selection filter for narrowing down target selection based on entities who have a spruce log on them. It uses the "item" subsequent parameter to define the item as a "log" (an old item ID prior to flattening changes which referred to oak, spruce, birch and jungle log types; others used "log2") and the "data" subsequent parameter to define the data as "1" (the data value assigned to spruce logs). The command will kill any player who has a spruce log.
/kill @a[hasitem={item=log,data=1}]
This teleport command defines a hasitem target selection filter for narrowing down target selection based on entities who have both yellow and magenta concrete on them. It uses the "item" subsequent parameter to define two items, both of which are assigned the "concrete" item ID. Additionally, it defines a "data" subsequent parameter for each of those items. The command will teleport any player who has both yellow concrete (data value 4) and magenta concrete (data value 2) to the command executor's position. Players must meet ALL conditions for the command to have a successful output. The command will fail if any one of the conditions are not met.
/tp @a[hasitem=[{item=concrete,data=4},{item=concrete,data=2}]] @s
Note: If you were to duplicate {item=concrete,data=4}, the command would still work; however this is redundancy.
The "location" subsequent parameter is used to define the location of the specified item given in the "hasitem" target selector filter. The "location" argument only accepts predefined slot identifiers. This subsequent parameter can be written by typing location=<slot_identifier>. The "location" argument is optional and does not need to be included. Exclusion can not be used with this subsequent parameter. Here is a list of pre-defined slot identifiers that can be used within the "location" subsequent parameter and what they're for:
slot.armor.head
This slot identifier represents a player's head armour slot
slot.armor.chest
This slot identifier represents a player's chest armour slot
slot.armor.legs
This slot identifier represents a player's legs armour slot
slot.armor.feet
This slot identifier represents a player's feet armour slot
slot.armor
This slot identifier represents a horse's armour slot
slot.chest
This slot identifier represents a mule/donkey's chest slots
slot.enderchest
This slot identifier represents an ender chest's slots
slot.equippable
This slot identifier represents slots found with entities that have the minecraft:equippable component.
slot.hotbar
This slot identifier represents a player's hotbar slots (not to be confused with inventory slots)
slot.inventory
This slot identifier represents a player's inventory slots (not to be confused with hotbar slots)
slot.saddle
This slot identifier represents the saddle slot for horses, mules and donkeys
slot.weapon.mainhand
This slot identifier represents the slot a player has selected on their hotbar
slot.weapon.offhand
This slot identifier represents the offhand slot for a player
The "slot" subsequent parameter is used to define the specific slot the item is located in when a "location" subsequent parameter is defined. The "slot" argument will only be accepted if the "location" argument has also been included. The "slot" argument can also be checked for exact slots, slots equal to or greater than, slots equal to or less than, and slots between two ranges. The "slot" argument only accepts integer values (whole numbers), in addition to syntax that represents "greater than", "less than" and "within a range"; however, accepted values are dependent on the location chosen (see the Minecraft Wiki for specifics). The "slot" argument is optional and does not need to be included. Slot values start at 0, not 1; a "slot" subsequent parameter set to a value of "1" is actually the 2nd slot. The exact way to write this subsequent parameter changes depending on what you aim to achieve with it:
Checking for exact matches
Syntax: slot=<value>
Example: slot=0
Checking for matches equal to or greater than
Syntax: slot=<value>..
Example: slot=0..
Checking for matches equal to or less than
Syntax: slot=..<value>
Example: slot=..5
Checking for matches between a range
Syntax: slot=<value>..<value>
Example: slot=0..5
Exclusion can be used with this subsequent parameter to check if an entity does not have the defined item in the specified slot(s). To do so, include an exclamation point directly after the equals sign in any of the above provided syntax (e.g. slot=!5).
Note: Whilst these examples are to showcase the "location" and "data" subsequent parameters, the "item" subsequent parameter is required, an item must be specified to avoid being presented with an error message. Furthermore, the "slot" subsequent parameter can not exist without the "location" subsequent parameter; as a result, examples are combined.
Common Misunderstanding: These examples are testing for specific items in specific locations, quantity of those items does not matter. For example, 6 diamonds in the specified slot is just the same as 1 diamond. You're checking the item, location and slot, not the quantity.
This testfor command defines a hasitem target selection filter for narrowing down target selection based on entities who have a diamond sword in their main hand. It uses the "item" subsequent parameter to define the item as a "diamond sword" and the "location" subsequent parameter to define the location as the "main hand". The command will provide a message stating a player was found if a player with a diamond sword in their main hand is found. If a player is not found, a message indicating the search has failed will be shown.
/testfor @a[hasitem={item=diamond_sword,location=slot.weapon.mainhand}]
This kill command defines a hasitem target selection filter for narrowing down target selection based on entities who have a diamond in their 3rd hotbar slot. It uses the "item" subsequent parameter to define the item as a "diamond", the "location" subsequent parameter is used to define the location as the "hotbar", and the "slot" subsequent parameter is used to define the slot as "2". The command will kill any player who has a diamond in their 3rd hotbar slot.
/kill @a[hasitem={item=diamond,location=slot.hotbar,slot=2}]
This kill command defines a hasitem target selection filter for narrowing down target selection based on entities who have an iron ingot in slot 3 or higher on their hotbar. It uses the "item" subsequent parameter to define the item as an "iron ingot", the "location" subsequent parameter is used to define the location as the "hotbar", and the "slot" subsequent parameter is used to define the slot as "2" or higher, the ".." after "2" indicates "or higher". The command will kill any player who has an iron ingots in slots 3 to 9 on their hotbar.
/kill @a[hasitem={item=iron_ingot,location=slot.hotbar,slot=2..}]
This kill command defines a hasitem target selection filter for narrowing down target selection based on entities who have a gold ingot in slot 3 or lower on their hotbar. It uses the "item" subsequent parameter to define the item as a "gold ingot", the "location" subsequent parameter is used to define the location as the "hotbar", and the "slot" subsequent parameter is used to define the slot as "2" or lower, the ".." before "2" indicates "or lower". The command will kill any player who has a gold ingot in slots 1 to 3 on their hotbar.
/kill @a[hasitem={item=gold_ingot,location=slot.hotbar,slot=..2}]
This kill command defines a hasitem target selection filter for narrowing down target selection based on entities who have a copper ingot between slots 3 and 6 on their hotbar. It uses the "item" subsequent parameter to define the item as a "copper ingot", the "location" subsequent parameter is used to define the location as the "hotbar", and the "slot" subsequent parameter is used to define slots between "2" and "5", the ".." between "2" and "5" indicates "between a range". The command will kill any player who has a copper ingot in slots 3 to 6 on their hotbar.
/kill @a[hasitem={item=copper_ingot,location=slot.hotbar,slot=2..5}]
This teleport command defines a hasitem target selection filter for narrowing down target selection based on entities who have a diamond, an iron ingot, a gold ingot, and a copper ingot in different locations. It uses the "item" subsequent parameter to define four items, a "diamond", an "iron ingot", a "gold ingot" and a "copper ingot". Additionally, it defines a "location" subsequent parameter for each of those items which sets the location to the "inventory". Furthermore, it defines a "slot" subsequent paramter for each of those items. The command will teleport any player who has a diamond exactly in the 1st inventory slot, an iron ingot in inventory slot 6 or afterwards, a gold ingot in inventory slot 4 or before, and a copper ingot in inventory slots 2 to 5, to the command executor's position. Players must meet ALL conditions for the command to have a successful output. The command will fail if any one of the conditions are not met.
/tp @a[hasitem=[{item=diamond,location=slot.inventory,slot=0},{item=iron_ingot,location=slot.inventory,slot=5..},{item=gold_ingot,location=slot.inventory,slot=..3},{item=copper_ingot,location=slot.inventory,slot=1..4}]] @s
This testfor command defines a hasitem target selection filter for narrowing down target selection based on entities who don't have a diamond in their 9th hotbar slot. It uses the "item" subsequent parameter to define the item as a "diamond", the "location" subsequent parameter is used to define the location as the "hotbar" and the "slot" subsequent parameter to define the slot as not "8", the exclamation point before the "8" is exclusion and means "does not equal". The command will provide a message stating a player was found if a player without a diamond in their 9th hotbar slot is found. If a player is not found, a message indicating the search has failed will be shown.
/testfor @a[hasitem={item=diamond,location=slot.hotbar,slot=!8}]
Note: This example is purely to show how all the subsequent parameters can be used together and how complex this specific target selector filter can easily become (even though this command is oddly specific and has no real practical use). To help better explain what is happening in this example, a different format of breakdown is provided.
/kill @a[hasitem=[{item=diamond,quantity=5,location=slot.inventory,slot=0},{item=iron_ingot,quantity=3..,location=slot.inventory,slot=1},{item=log,quantity=3..5,data=1,location=slot.inventory,slot=2..},{item=diamond_pickaxe,location=slot.hotbar,slot=!1..8}]]
This kill command defines a hasitem target selection filter for narrowing down target selection based on entities who meet the specified requirements, explained below.
The command uses the "item" subsequent parameter to define four unique items; the items defined are "diamond", "iron ingot", "log" and "diamond pickaxe".
The first item, defined as a "diamond" using the relevant item ID, uses the "quantity", "location" and "slot" subsequent parameters. The "quantity" is defined as exactly "5". The "location" is defined as "slot.inventory" (this refers to the 27 inventory slots, not the hotbar). The "slot" is defined with a value of exactly "0" (this refers to the first inventory slot, and only the first inventory slot). This means that the target selector is looking for players who have exactly 5 diamonds in their first inventory slot.
The second item, defined as an "iron ingot" using the relevant item ID, uses the "quantity", "location" and "slot" subsequent parameters. The "quantity" is defined as "3" or more. The "location" is defined as "slot.inventory" (again, this refers to the 27 inventory slots, not the hotbar). The "slot" is defined with a value of exactly "1" (this refers to the second inventory slot, and only the second inventory slot). This means that the target selector is looking for players who have 3 or more iron ingots in their second inventory slot.
The third item, defined as a "log" using the relevant item ID, uses the "quantity", "data", "location" and "slot" subsequent parameters. The "quantity" is defined as the range "3" to "5". The "data" is defined as "1" (this means the log type chosen is spruce). The "location" is defined as "slot.inventory" (once more, this refers to the 27 inventory slots, not the hotbar). The "slot" is defined with a value of "2" or more (this refers to the third inventory slot, and any slot afterwards). This means that the target selector is looking for players who have between 3 and 5 spruce logs in the third inventory slot or any inventory slot after that.
The fourth, and final item, defined as a "diamond pickaxe" using the relevant item ID, uses the "location" and "slot" subsequent parameters. The "location" is defined as "slot.hotbar" (this refers to the 9 hotbar slots, not the 27 inventory slots). The "slot" is defined as the range "1" to "8" (this refers to slots 2 to 9 on the hotbar), and uses exclusion. This means that the target selector is looking for players who do not have a diamond pickaxe in any hotbar slot but the first.
The command will kill any player who meets all of the above conditions.
Diagrams showcasing what each "hasitem" slot identifier refers to
excludes "slot.equippable" as this refers to multiple different types of slots
Missing content; to be added.
Experience target selector filters (l and lm) can be used to narrow down target selection based on a player's experience level. The gamemode target selector filter (m) can be used to narrow down target selection based on a player's gamemode. The permission target selector filter (haspermission) can be used to narrow down target selection based on a player's permissions. Experience and gamemode target selector filters can not be duplicated. The permission target selector filter may be duplicated if testing of inequality only.
An "experience" target selector filter will narrow down target selection based on the experience levels of a player. Level maximum (l) and level minimum (lm) target selector filters required you to input integer values (whole numbers). To use these target selector filters you would write l=<value> and lm=<value>. Neither of the experience target selector filters can be duplicated; exclusion can also not be used.
Note: These target selector filters naturally filter out any non-player entities
This teleport command defines a level maximum (l) target selector filter for narrowing down target selection based on entities who have 5 experience levels (indicated by the number 5 above the experience bar). The command will teleport all player entities who have 5 experience levels (no more, no less) to the command executor's position.
/tp @a[l=5] @s
This effect command defines a level maximum (l) and level minimum (lm) target selector filter for narrowing down target selection based on entities who have 0 to 5 experience levels. The command will apply the regeneration 3 effect to all player entities who have an amount of experience levels within the specified range. The effect will last for 30 seconds and have a strength of 3 (regeneration III).
/effect @a[lm=0,l=5] regeneration 30 2
This kill command defines a level maximum (l) and level minimum (lm) target selector filter for narrowing down target selection based on entities who have 5 to 5 experience levels (so exactly 5). The command will kill any player entity that has the specified amount of experience levels. Whilst the target selector is "@e" (all entities), only player entities will be targeted.
/kill @e[lm=5,l=5]
The gamemode target selector filter (m) will narrow down target selection based on a player's gamemode. To use the gamemode target selector filter you would write m=<string/value>. The gamemode filter can not be duplicated unless testing for inequality. The use exclusion with the gamemode target selector filter, you'd write m=!<string/value>. The gamemode target selector filter only allows strings (text) and integer values (whole numbers) that have already been pre-defined. Accepted inputs for the gamemode target selector filter:
"adventure"; aliases, "a" or "2"
Checks for players in adventure mode
"creative"; aliases, "c" or "1"
Checks for players in creative mode
"default"; alias, "d"
Checks for players in the default gamemode (pause > settings > game > "default game mode")
"spectator"; no aliases
Checks for players in spectator mode
"survival"; aliases, "s" or "0"
Checks for players in survival mode
This teleport command defines a gamemode (m) target selector filter for narrowing down target selection based on entities who are in survival. The command will teleport all player entities who are in survival mode to the command executor's position.
/tp @a[m=s] @s
This effect command defines a gamemode (m) target selector filter for narrowing down target selection based on entities who are in the default gamemode setting (whatever that may be). The command will apply the regeneration 2 effect to all player entities who are in the default gamemode. The effect will last for 20 seconds and have a strength of 2 (regeneration II).
/effect @a[m=default] regeneration 20 1
This kill command defines a gamemode (m) target selector filter for narrowing down target selection based on entities who are not in adventure mode. The command will kill any player entity that is in survival mode (players in creative or spectator are immune to the kill command). Whilst the target selector is "@e" (all entities), only player entities will be targeted.
/kill @e[m=!2]
The "haspermission" target selector filter narrows down target selection based on the permissions a player has. The permission target selector filter allows only pre-defined permission properties and permission states ("enabled"/"disabled"). To use the "haspermission" target selector filter you would write haspermission={<permission>=<state>}. This target selector filter can not be duplicated; additionally, exclusion can not be used. Accepted permission properties:
"movement"
Checks if the player has permission to move their character or not
"camera"
Checks if the player has permission to move their camera or not
This teleport command defines a "haspermission" target selector filter for narrowing down target selection based on entities who lack the specified permission. The command will teleport all player entities who have the "movement" permission disabled to the command executor's position.
/tp @a[haspermission={movement=disabled}] @s
This teleport command defines a "haspermission" target selector filter for narrowing down target selection based on entities who have the specified permission. The command will teleport all player entities who have the "camera" permission enabled to the command executor's position.
/tp @a[haspermission={camera=enabled}] @s
This kill command defines a "haspermission" target selector filter for narrowing down target selection based on entities who meet the specified permission conditions. The command will kill all player entities who have both the "movement" and "camera" permissions disabled. Whilst the target selector is "@e" (all entities), only player entities will be targeted.
/kill @e[haspermission={movement=disabled,camera=disabled}]
The count target selector filter (c) can be used to narrow down target selector based on a limit. The count target selector filter can not be duplicated.
The count (c) target selector filter narrows down target selection based on a specified limit, meaning that a limited amount of entities will be selected if they meet the target selector's filter conditions. The count target selector filter only accepts integer values (whole numbers). To use the count target selector filter you would write c=<value>. The count filter can not be duplicated; exclusion can also not be used. Using positive numbers in this target selector filter will limit the target selection based on the closest players to the command execution point; on the other hand, using negative numbers in this target selector filter will have the reverse effect and select the players furthest away from the command execution point.
Note: Using the "@r" target selector will still result in random players being selected, as opposed to the nearest/furthest players.
This teleport command defines a count target selector filter for narrowing down target selection based on a limit. The command will teleport the 3 player entities who are the closest to the command execution point to the command executor's position.
/tp @a[c=3] @s
This teleport command defines a count target selector filter for narrowing down target selection based on a limit. The command will teleport the 3 player entities who are the furthest from the command execution point to the command executor's position.
/tp @a[c=-3] @s
This kill command defines a count target selector filter for narrowing down target selection based on a limit. The command will kill 3 randomly chosen player entities (remember, "@r" is for player entities unless specified otherwise).
/kill @r[c=3]