Commands
Overview
As a staff member, you have access to many of Minecraft's wide variety of commands. Commands are powerful tools that staff members of any Minecraft server should become familiar with, as they make up a lot of your administrative work in game. This page will discuss many vital parts of how to write commands, describe some of the most important commands to know on WOFTNW, and provide some examples on how to write them.
Vanilla Commands
Minecraft's vanilla commands are plentiful, but most are either not important or are simple to understand. The following is a complete list of the vanilla commands for our server version; you do not have to be familiar with every command listed! If you are curious about any specific command, please visit the wiki via the link in the description of the command.
Command | Description |
---|---|
/advancement |
π‘οΈ π π Grants or revokes an advancement. Wiki |
/attribute |
π‘οΈ π Queries, adds, removes or sets an entity attribute. Wiki |
/ban |
π‘οΈ π Adds a player to the banlist. Wiki |
/banlist |
π‘οΈ π Displays the banlist. Wiki |
/bossbar |
π‘οΈ π Creates and modifies bossbars. Wiki |
/clear |
π‘οΈ π π Clears items from player inventory. Wiki |
/clone |
π‘οΈ π Copies blocks from one place to another. Wiki |
/damage |
π‘οΈ π Applies damage to specified entities. Wiki |
/data |
π‘οΈ π Manipulates block, entity, and storage NBT data. Wiki |
/datapack |
π‘οΈ π π Controls the data packs interface. Wiki |
/debug |
π‘οΈ π π Starts or stops a debugging session. Wiki |
/defaultgamemode |
π‘οΈ π π Sets the default game mode. Wiki |
/deop |
π‘οΈ π π Revokes operator status from a player. Wiki |
/difficulty |
π‘οΈ π Sets the difficulty level. Wiki |
/effect |
π‘οΈ π Adds or removes status effects. Wiki |
/enchant |
π‘οΈ π Adds an enchantment to a player's selected item. Wiki |
/execute |
π‘οΈ π π Executes another command. Wiki |
/experience, /xp |
π‘οΈ π Adds or removes player experience. Wiki |
/fill |
π‘οΈ π π Fills a region with a specific block. Wiki |
/fillbiome |
π‘οΈ π Sets a region with a specific biome. Wiki |
/forceload |
π‘οΈ π Forces chunks to constantly be loaded or not. Wiki |
/function |
π‘οΈ π π Runs a function. Wiki |
/gamemode |
π‘οΈ π π Sets a player's game mode. Wiki |
/gamerule |
π‘οΈ π π Sets or queries a game rule value. Wiki |
/give |
π‘οΈ π π Gives an item to a player. Wiki |
/help |
π Provides a list of commands or help for a command. Wiki |
/item |
π‘οΈ π Manipulates items in inventories. Wiki |
/jfr |
π‘οΈ π π Start or stop a JFR profiler. Wiki |
/kick |
π‘οΈ π Kicks a player off a server. Wiki |
/kill |
π‘οΈ π Kills entities (players, mobs, items, etc.). Wiki |
/list |
π Lists players on the server. Wiki |
/locate |
π‘οΈ π Locates closest structure, biome, or point of interest. Wiki |
/loot |
π‘οΈ π Give a loot table to a selector or spawn a loot table. Wiki |
/me |
π Displays a message about the sender. Wiki |
/msg, /tell, /w |
π Displays a private message to other players. Wiki |
/op |
π‘οΈ π Grants operator status to a player. Wiki |
/pardon |
π‘οΈ π Removes players from the banlist. Wiki |
/pardon-ip |
π‘οΈ π Removes an IP address from the banlist. Wiki |
/particle |
π‘οΈ π π Generates particles. Wiki |
/perf |
π‘οΈ π Captures info and metrics about the game for 10 seconds. Wiki |
/place |
π‘οΈ π π Used to place a configured feature, jigsaw, template, or structure at a given location. Wiki |
/playsound |
π‘οΈ πPlays a sound. Wiki |
/publish |
π‘οΈ π Opens a single-player world to a local network. Wiki |
/recipe |
π‘οΈ π π Gives or takes player recipes. Wiki |
/reload |
π‘οΈ π Reloads loot tables, advancements, and functions from disk. Wiki |
/return |
π‘οΈ π π Control execution flow inside functions. Wiki |
/ride |
π‘οΈ π Used to make entities ride other entities, stop entities from riding, make rides evict their riders, or summon rides or riders. Wiki |
/save-all |
π‘οΈ π Saves the server to disk. Wiki |
/save-off |
π‘οΈ π Disables automatic server saves. Wiki |
/save-on |
π‘οΈ π Enables automatic server saves. Wiki |
/say |
π Displays a message to multiple players. Wiki |
/schedule |
π‘οΈ π π Schedule the execution of a function. Wiki |
/scoreboard |
π‘οΈ π Manages scoreboard objectives and players. Wiki |
/seed |
π‘οΈ π Displays the world seed. Wiki |
/setblock |
π‘οΈ π Changes a block to another block. Wiki |
/setidletimeout |
π‘οΈ π π Sets the time before idle players are kicked. Wiki |
/setworldspawn |
π‘οΈ π Sets the world spawn. Wiki |
/spawnpoint |
π‘οΈ π π Sets the spawn point for a player. Wiki |
/spectate |
π‘οΈ π Force a spectating player to spectate an entity. Wiki |
/spreadplayers |
π‘οΈ π π Teleports entities to random locations. Wiki |
/stop |
π‘οΈ π Stops the server. Wiki |
/stopsound |
π‘οΈ π Stops a sound currently playing. Wiki |
/summon |
π‘οΈ πSummons an entity. Wiki |
/tag |
π‘οΈ π Manages entity tags. Wiki |
/team |
π‘οΈ π Controls teams. Wiki |
/teammsg, /tm |
π Sends a message to the player's team. Wiki |
/teleport, /tp |
π‘οΈ π π Teleports entities. Wiki |
/tellraw |
π‘οΈ π Displays a JSON-formatted message to players. Wiki |
/time |
π‘οΈ π Changes or queries the world's game time. Wiki |
/title |
π‘οΈ π Manages screen titles. Wiki |
/trigger |
π Manages trigger scoreboards. Wiki |
/weather |
π‘οΈ π Sets the weather. Wiki |
/whitelist |
π‘οΈ π π Manages the server whitelist. Wiki |
/worldborder |
π‘οΈ π Manages the world border. Wiki |
Targeting Entities
Target Selectors
Overview
Target selectors are used in many commands in place of usernames or UUIDs to target multiple entities that match a broad criteria.
Target Selector | Entities Selected |
---|---|
@p |
Nearest player |
@r |
One random player |
@a |
All players, living and dead |
@e |
All loaded, living entities |
@s |
Entity executing the current command |
Tips
- Use the most specific selector available. For example, if you want to target the nearest player, use
@p
instead of@a[sort=nearest, limit=1]
. This is because some selectors such as@e
will create a massive list of entities, which can unintentionally cause lag.
Selector Arguments
Overview
Selector arguments can be used to filter entities from the selection even further. These allow you to narrow your selection based on various attributes. There are a wide variety of arguments, but those detailed below are the most important.
Target Selector Argument | Filter By... |
---|---|
x , y , z |
coordinate |
distance |
distance |
dx , dy , dz |
volume dimensions |
x_rotation |
vertical rotation (pitch) |
y_rotation |
horizontal rotation (yaw) |
scores |
scores |
tag |
tag |
team |
team |
name |
entity name |
type |
entity type |
predicate |
predicate |
nbt |
nbt |
level |
experience level |
gamemode |
gamemode |
advancements |
advancements |
limit , sort |
selector limiting |
distance=
distance
allows you to target entities within a specified spherical range in blocks. The entity will only be targeted if the origin of their hitbox (bottom center) is within the distance. This selector also limits the selection to the current dimension.
@e[distance=1.5] |
Target all entities exactly 1.5 blocks away. |
@a[distance=8..16] |
Target all players 8 to 16 blocks away, inclusive. |
@p[distance=..40] |
Target the nearest player up to 40 blocks away, inclusive. Note that if the first number is excluded, the command interprets it as 0. |
@r[distance=12..] |
Target a random player at least 12 blocks away, inclusive. Note that if the second number is excluded, the command will interpret it as infinity, which will include all entities in the dimension. |
dx=
, dy=, dz=
dx
, dy
, and dz
select by rectangular volume from the command origin. These specify the distance from the origin rather than a global coordinate and extend asymmetrically. Unlike distance
, volume selection targets entities if any part of their hitbox is inside the selection.
@a[dx=3, dy=5, dz=2] |
Target all players whose hitbox lies within the volume extending 4 blocks east, 6 blocks up, and 3 blocks south of the execution spot. |
scores=
scores
selects by matching scoreboard objectives. Targeted entities must have all specified scores on all specified objectives. You also can specify an integer range (inclusive) similar to the distance
selector.
@e[scores={myScore1=4}] |
Target all entities with a score of exactly 4 in myScore1. |
@p[scores={myScore2=..5, myScore3=10..}] |
Target the nearest player with at most a score of 5 in myScore2 and at least a score of 10 in myScore3. |
tag=
tag
targets entities with a specified tag. These tags can be applied with the /tag
command.
@a[tag=myTag1] |
Target all players with the myTag1 tag. |
@p[tag=!myTag2] |
Target the nearest player who does not have the myTag2 tag. |
@e[tag=myTag3, tag=myTag4, tag=!myTag5] |
Target all entities who have the myTag3 tag, and the myTag4 tag, and do not have the myTag5 tag. |
@r[tag=] |
Target a random player that has no tags. |
@s[tag=!] |
Target the current executing entity if they have at least one tag. |
team=
team
targets entities who are on a specified team, and works in nearly the exact same way as tag
. Note that using this argument will only target living entities.
@a[team=myTeam1] |
Target all players who are in myTeam1. Note that, in this instance, this argument can only be stated once since entities can only belong to one team. |
@p[team=!myTeam2, team=!myTeam3] |
Target all players who are not in myTeam2 or myTeam3. Note that this argument can be used more than once. |
@r[team=] |
Target a random player who is not on a team. |
@a[team=!] |
Target all players who are on any team. |
nbt=
nbt
targets entities with specified NBT data, and as such is the most resource-intensive arguments. Avoid using NBT unless ABSOLUTELY necessary as misusing it has a high potential to cause lag.
@a[nbt={Inventory: [{id: "minecraft:iron_sword}]}] |
Target all players who have an iron sword in their inventory. |
@e[nbt={DeathLootTable: "myLootTable"}] |
Target all entities who have the myLootTable death loot table. |
limit=
limit
can be used to limit the number of targeted entities.
Note that limit
and sort
are most commonly used together, as they can significantly improve the performance of selectors.
@e[limit=15] |
Target at most 15 entities. |
@a[limit=4] |
Target at most 4 players. |
sort=
Finally, sort
can be used to sort through the currently selected entities. sort
has four possible values: arbitrary
, nearest
, furthest
, and random
. arbitrary
is the default, selecting sorting entities based off of their time of creation. nearest
and furthest
sort by increasing and decreasing distance respectively, and random
is... well, random.
Note that limit
and sort
are most commonly used together, as they can significantly improve the performance of selectors.
@e[sort=nearest] |
Target all entities, selecting the nearest entities first. |
@a[limit=4, sort=random] |
Target at most 4 random players. |
Tips
- Selector arguments β or lack thereof β can make commands dangerous! When you run certain commands, always remember that selectors are made to target everything that matches the criteria. Ensure your arguments are specific and correct, and run them by a more experienced staff member if you are unsure.
- x, y, z can almost always be replaced by
execute positioned <x> <y> <z>
. You will rarely run into an instance where the former is necessary. - Use selector arguments to optimize your selector. Order matters! The following list is the recommended order of selector arguments. At the very least, specify type and limit, but use all that apply:
sort=
limit=
type=
gamemode=
gamemode=!
distance=
x_rotation=
/y_rotation=
x, y, z
/dx, dy, dz
level=
team=
team=!
type=!
tag=
tag=!
name=
name=!
predicate=
predicate=!
scores=
advancements=
nbt=
nbt=!
Important Commands
The following commands listed are important to know during your time as a staff member. Here is a quick guide to understanding the command layout:
text
- Text that should be written how it is shown.<keyword>
- A specific option from a list of valid entries.[keyword]
- An optional entry.(option1 | option2)
- A required "or", meaning you must use one field or another.[option1 | option2]
- An optional "or", meaning you may use one field or another if you wish.
/ban, ban-ip
Bans a player or ip from the server. The player does not have to be online to be banned. In addition to being added to the banlist, they will be kicked automatically.
/ban | ban-ip <player> [reason] |
Syntax for the command. |
ban jjj_North |
Kick and ban jjj_North. |
ban-ip 7pencilsharpen3r Hacking |
Kick and ban 7pencilsharpen3r's IP for hacking, preventing any account from joining from that IP. |
/clear
Clears an item or all items from a player or valid selector entities.
/clear <selector> [item] [amount] |
Syntax for the command. |
clear mmaurice196 |
Clear every item from mmaurice196. |
clear @a[team=SkyWing] cooked_beef 12 |
Clear 12 steak from every player on the SkyWing team. |
clear CalamityLegendz diamond_sword{Enchantments: [{id: "minecraft:sharpness", lvl: 1000s}]} |
Clear all diamond swords with Sharpness 1000 from CalamityLegendz. |
clear @s iron_sword{titanium: 1b} 0 |
Check if the executing entity has an iron sword with the NBT "titanium:1b". By setting the quantity to 0, we can instead check if the selected entities have the item declared. This is mainly only useful in data packs, but you may find certain use cases for this feature. |
/datapack
Enable or disable a data pack or list all data packs.
/datapack <(disable | enable) <name> | list> |
Syntax for the command. |
datapack disable "file/Ender Dragon" |
Disable the "Ender Dragon" data pack. |
datapack enable "file/Example Datapack" |
Load the "Example Datapack" data pack. |
datapack list |
List all data packs. |
/execute
Execute is an extremely powerful command that allows you to execute multiple subcommands to modify given parameters, check for different variables, and fork the command execution. While you do not need to know every in and out of this command, there may be cases in which you will utilise it, so it is important to know the basics!
align <axes>
- aligns the position of the command execution with the block position along the given axes. This allows you to to align to the edges of a block.anchored <anchor>
- sets the position of the command execution to either the eyes or feet of the executor.as <targets>
- sets the executor without changing the location. You must useat
to set the location. If multiple targets are selected, the following subcommands will apply to all targetsat <targets>
- sets the location of the execution without changing the executor. You must useas
to set the executor.facing <pos | <targets> <anchor>>
- sets the execution rotation.in <dimension>
- sets the execution dimension. This will account for distance scaling in the nether and custom dimensions.on <attacker | controller | leasher | origin | owner | passengers | target | vehicle>
- sets the executor based on relation to the current executor.positioned <pos | as | over>
- sets the execution position.rotated <rot | as <targets>>
- sets the execution rotation.summon <entity>
- summons a new entity at the execution position and sets it as the executor.(if|unless) biome <pos> <biome>
- checks for the given biome at a given position.(if|unless) block <pos> <block>
- checks for the given block at a given position.(if|unless) blocks <start> <end> <destination> (all|masked)
- compares blocks in two volumes.(if|unless) data <block | entity | storage> <source> <path>
- checks whether the targeted block, entity or storage has any data tag for a given path.(if|unless) dimension <dimension>
- checks if the execution is in a matching dimension.(if|unless) function <function>
- checks a function or function tag and matches the return value(s). If a tag is given, all functions run regardless of the results of prior functions.(if|unless) entity <entities>
- checks whether one or more entities exist.(if|unless) loaded <pos>
- checks if chunks at a given position is fully loaded.(if|unless) predicate <predicate>
- checks whether the predicate successes. This is primarily a data pack feature.(if|unless) score <target> <targetObjective> <operation | matches <target> <targetObjective>>
- checks whether a score has the specific relation to another score, or whether it is in a given range.store (result|success) <block | bossbar | entity | score | storage>
- stores either the result (i.e. save the number of items in a chest to a scoreboard objective) or the success (i.e. checking if a chest has a specific item in it) of the following command.
Minecraft will process subcommands in the order they are arranged in the command. Note that execute ... run execute ... run ...
has no effect as it is essentially the same as execute ... run
.
/execute <subcommands> [run <command>] |
Syntax for the command. |
execute run say Hello, world! |
The same thing as simply using "/say Hello, world!" Not very practical... |
execute as @e[type=pig] run say I'm a pig! |
Change the executing entity to all pigs... ...then force them to use "/say I'm a pig!". Nice! |
execute in the_end if block 0 64 0 beacon as @e[type=armor_stand, distance=0..] at @s facing 0 64 0 run tp ^ ^ ^1 |
Change the command location to The End... ...then check if there is a beacon at 0 64 0... (if there is no beacon at 0 64 0, the command will stop here entirely!) ...then change the executing entity to all armor stands in the current dimension... ...then change the location of the command execution to the executing entity β all armor stands in the current dimension... ...then change the direction the command is running to face 0 64 0... ...then teleport the executing entities forwards one block. Phew. |
/give
Gives the targeted selectors an item with optional NBT attached.
/give <selector> <item> [nbt] |
Syntax for the command. |
give BogTheMudWing potato |
Give BogTheMudWing 1 potato. |
give @a[limit=10, sort=random] diamond{display: {Name: "Actual Coal"}} |
Give 10 random players 1 diamond named "Actual Coal". |
/kick
Terminates a player's connection to the server.
/kick <player> [reason] |
Syntax for the command. |
kick FlawLessII |
Kick FlawLessII from the server. |
kick s0meb0dysupply Profanity |
Kick s0meb0dysupply from the server for profanity. |
/pardon, pardon-ip
Remove a player or an IP from the banlist, regranting said player or IP access to the server.
Β | Β |
---|---|
/pardon | pardon-ip <player> |
Syntax for the command. |
pardon jjj_North |
Pardon jjj_North. |
pardon-ip 7pencilsharpen3r |
Pardon 7pencilsharpen3r's IP. |
/scoreboard
Add objectives, get player scores, manipulate scoreboard objectives, and much more. This command is very extensive and powerful!
/scoreboard <objective | players> ... |
Syntax for the command. |
scoreboard objectives add player_health health |
Create a scoreboard objective called "player_health" that tracks... the players' health. |
scoreboard objectives modify player_health displayname {"text": "Player Health", "color": "red"} |
Modify the "player_health" scoreboard to appear as "Player Health" in red. |
scoreboard players get Julibeau WhiteKills |
Get Julibeau's score in the objective WhiteKills. |
/summon
Summons an entity.
/summon <entity> [<posX posY posZ> [NBT]] |
Syntax for the command. |
summon ender_dragon |
Summons an Ender Dragon. |
summon iron_golem ~ ~ ~ {NoAI: 1b} |
Summons an iron golem at the current position with no AI. |
summon cow ^ ^ ^10 {active_effects: [{id: "minecraft:levitation", amplifier: 10, duration: 200}], DeathLootTable: "chests/abandoned_mineshaft"} |
Summons a cow 10 blocks forwards from the player's current direction, with Levitation 11 for 10 seconds, that will drop loot from an abandoned mineshaft... wow. |
/tellraw
Announce a highly-customizable message to a selector using JSON.
/tellraw <selector> [string or JSON] |
Syntax for the command. |
tellraw FrazzledDingo "Welcome to the server!" |
Show the message "Welcome to the server!" to FrazzledDingo. |
tellraw @a[team=Green] {"text": "You are on the Green team!", "color": "dark_green"} |
Show the message "Welcome to the server!" to all players on the Green team. |
tellraw @a[distance=..30] [{"selector": "@r[distance=..30]", "color": "red"}, {"text": " won the ", "color": "gray"}, {"text": "Grand Raffle", "color": "gold"}, {"text": "!", "color": "gray"}] |
Show the message "<random player up to 30 blocks away> won the Grand Raffle!" to all players up to 30 blocks away. |
/whitelist
Add or remove a player from the whitelist, enable or disable the whitelist, or reload the whitelist.
/whitelist <add | on | off | reload | remove> <player> |
Syntax for the command. |
whitelist add RaspberryConflict |
Adds RaspberryConflict to the whitelist. |
whitelist remove known__clams |
Removes known__clams from the whitelist. |
whitelist on |
Activates the whitelist, allowing only those on the whitelist to join the server. |
whitelist off |
Deactivates the whitelist, allowing any player to join the server. |
whitelist reload |
Reloads the whitelist. |