Skip to main content

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 use at to set the location. If multiple targets are selected, the following subcommands will apply to all targets
  • at <targets> - sets the location of the execution without changing the executor. You must use as 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.