Skip to main content

Command list and command introduction (2/3)

This page excerpts the reference from MS Learn (MicrosoftDocs/minecraft-creator a9fd1c0, CC BY 4.0). Relative links in the original are removed.

(Source: ms-learn, creator/Documents/CommandsPopularCommands.md)

This list covers some of the more popular and useful commands available in Minecraft: Bedrock Edition.

Requirements​

It's recommended that the following be completed before beginning this tutorial.

  • Introduction to Commands
  • Getting Started with Command Blocks

/help​

First and foremost is the /help command.

/help <page: int>
/help [command: CommandName]

Running /help in the chat by itself will list every command you can run. However, since there are so many, they have been divided up into pages. Supplying a page number will change which page of commands to show.

Whenever you want to know the usage and all of the syntaxes of a command, you can use /help followed by the name of the command. This can be helpful if you want an overview of the command.

/effect​

Adding and removing status effects is done with the /effect command. All status effects on the target can also be cleared.

/execute​

The primary function of the /execute command is to modify the executor and execution origin of a nested command. However, its syntax allows for some conditional command execution that would otherwise be missing in functions.

Find more information on the Execute reference page.

/execute as <origin: target> <chainedCommand: ExecuteChainedOption_0>

For example, to detect if there's a specific block beneath the player and run a command as a result, the "detect" argument can be used instead of having a nested /testforblock command.

/execute as @s positioned as @s if block ~ ~-1 ~ grass run say Player is standing on grass.

/gamemode​

When developing content, most often you'll be playing in creative mode. However, testing your content may require you to enter survival or adventure mode. The /gamemode command allows you to change your current game mode.

/gamemode <gameMode: GameMode> [player: target]
/gamemode <gameMode: int> [player: target]

You have several options for the game mode: the full name, a single character, or a numeric representation. The accepted values are "survival" ("s" or 0), "creative" ("c" or 1), and "adventure" ("a" or 2). There is also "default" ("d"), which sets your game mode to whatever the world's default game mode is. The following will set your own game mode to creative when you run it in the chat.

/gamemode creative

You can also change the game mode of a specific player using target selectors, which can be helpful when controlling gameplay aspects (such as the inability to mine anything in adventure mode). The following changes the game mode of all players with the "sometag" tag to adventure mode.

/gamemode adventure @a[tag=sometag]

/gamerule​

This /gamerule command changes specific gameplay aspects and has options helpful for development. There are a large number of gamerules, which can be listed using the chat's auto-complete feature.

/gamerule <rule: BoolGameRule> [value: Boolean]
/gamerule <rule: IntGameRule> [value: int]

Some gamerules accept only true or false as the value of the rule ("BoolGameRule") while others only accept integers ("IntGameRule"). The primary gamerules crucial for development, which are all booleans, are "commandblockoutput", "sendcommandfeedback", and "commandblocksenabled", "dodaylightcycle", and "doweathercycle" listed below.

commandblockoutput​

You may have noticed that all of the previous command examples send an output to the chat. This can be a nuisance, especially for commands running every tick. The "commandblockoutput" gamerule, when set to false, will disable that chat output.

/gamerule commandblockoutput false
sendcommandfeedback​

Disabling command block output does not disable all feedback. Some commands, such as /xp, continue providing feedback even when command block output is disabled. The "sendcommandfeedback" gamerule disables these messages as well, allowing for a completely silent command system.

/gamerule sendcommandfeedback false
commandblocksenabled​

To quickly enable or disable command blocks in the world, the "commandblocksenabled" can be toggled on and off. This can be especially helpful if a repeating command block is repeatedly teleporting you.

/gamerule commandblocksenabled false
dodaylightcycle​

Either for development or for gameplay concerns, you can choose to prevent the daylight cycle from moving. This means that whatever time you set the game to (such as with the /time command), it will stay at that time.

/gamerule dodaylightcycle false
doweathercycle​

As with "dodaylightcycle", you may also want to control the weather cycle. If you intend to have a happy setting, a thunderstorm setting in may not achieve the best effect. When "doweathercycle" is disabled, the weather will stay as it is, including when set with the /weather command.

/gamerule doweathercycle false

/give, /clear, /replaceitem​

These commands manipulate the player's inventory; /replaceitem can also modify non-player entity inventories and blocks with inventories. The /give command provides items, the /clear command removes items, and the /replaceitem command places items in specific slots in the inventory.

/locate​

Finds the nearest specified biome or structure if it exists in the current dimension. Prints an error if it does not.

/locate biome <biome name>
/locate structure <structure name>

The locate command takes two arguments: "biome" or "structure" specifies which to locate, followed by the name of the biome or structure you're looking for.

/locate biome beach
/locate structure village

/scoreboard​

The /scoreboard command is a powerful method of keeping track of numeric values on a per-entity basis, as well as performing mathematical operations with commands. The first step is creating an objective and (optionally) displaying it on the sidebar.

/scoreboard objectives add objectiveA dummy

/scoreboard objectives setdisplay sidebar objectiveA

The simplest course of action would be rewarding the player with a point if they accomplish some task.

/scoreboard players add @p objectiveA 1

Afterwards, target selectors can be used to select players who achieve a certain number of points.

@a[scores={objectiveA=10..}]

/setblock, /fill, /clone​

These commands change the physical blocks in the world. The /setblock command can set a single block while the /fill command can set multiple of the same block. The /clone command, on the other hand, will take a copy of blocks from one area and paste it into another.

/summon​

The /summon command is used to spawn a new entity into the world, from cows to sheep to your own custom entities.

/setworldspawn​

If you have a specific location that you want players new to the world or players who die to spawn at, the /setworldspawn command provides that ability.

/setworldspawn [spawnPoint: x y z]

Note that players who die after they have set their spawn with a bed will still respawn at their bed.

/tag​

Similar to /scoreboard, the /tag command allows you to keep track of string values on a per-entity basis. Tags would be used when a numeric value is not needed, such as for "true or false" situations. For example, you could tag entities as being a boss and later target those same entities based on that tag.

/tag @e[type=sheep] add boss
/tag @e[type=minecart] add boss
/say Bosses: @e[tag=boss]

/tellraw, /titleraw​

The /say, /tell, and /title commands don't provide translation support. To provide that, use the /tellraw and /titleraw commands, which take JSON objects for their messages. The /tellraw command is also clearer in intent, as the message is not accompanied with a "whisper" statement.

/tellraw @a {"rawtext":[{"translate":"commands.testfor.success","with":["PlayerName"]}]}

/tellraw @a {"rawtext":[{"text":"Hello World"}]}

/testfor, /testforblock, /testforblocks​

These commands test for the existence of an entity, block, and a copy of a block structure. While these commands can be useful alongside conditional command blocks, they are less useful in functions, as there is no equivalent conditional setting in functions.

Both the /testfor and /testforblock commands can generally be skipped over in favor of /execute, which can run a command based on the existence of an entity or a block.

/time set​

Changing the gameplay environment can be essential for providing the right atmosphere. Changing the time of day is one method of doing so.

/time set <amount: int>
/time set <time: TimeSpec>

You can either provide an integer which represents a precise time of the day, or "TimeSpec" can be set to one of the following values to more easily select common times of day: "day", "midnight", "night", "noon", "sunrise", and "sunset". For example, quickly setting the sun directly above the player would use the following:

/time set noon

/tp or /teleport​

Sometimes you may want to provide an easy means of transportation or need a form of controlling where the player (or even non-player entity) is. The /tp command will teleport targeted players to specific locations, or even to other entities. The syntaxes for /tp may look daunting at first, but note many branch to and from the same options.

/tp <victim: target> <destination: target> [checkForBlocks: Boolean]
/tp <victim: target> <destination: x y z> [checkForBlocks: Boolean]
/tp <victim: target> <destination: x y z> [yRot: value] [xRot: value] [checkForBlocks: Boolean]
/tp <victim: target> <destination: x y z> facing <lookAtEntity: target> [checkForBlocks: Boolean]
/tp <victim: target> <destination: x y z> facing <lookAtPosition: x y z> [checkForBlocks: Boolean]

At its simplest, you can teleport the player to a specific coordinate location.

/tp @p 100 50 100

You can also teleport them to another player or entity. The destination target must resolve to a single entity, so you have to use a target selector that can only target one entity or ensure there are no duplicates of the intended target (such as using the /tag command to identify targets).

/tp Steve Alex
/tp @p @e[type=minecraft:armor_stand,c=1]
/tp @a @e[type=minecraft:creeper,tag=destination_1]

The common option "checkForBlocks" defaults to false, but when it is set to true, it will prevent teleporting the player if the location they would end up in is occupied by blocks.

This command teleports Steve to coordinates [50, 63, 50] and makes sure there are no blocks in the way.

/tp Steve 50 63 50 true

[!NOTE] One of the differences between using commands and commands blocks is that /tp @s ... will not work in a command block.

/weather​

Like /time set, the /weather command can be used to change the environment. If you want a specific type of weather to occur, this would be the command you would use.

/weather <clear|rain|thunder> [duration: int]

The optional duration is the number of game ticks that the selected weather will last for. 20 game ticks is one second, so for each second you want the weather to last, multiply it by twenty. The following sets the weather to thunder for 30 seconds, which is 600 ticks.

/weather thunder 600

Be sure that the "doweathercycle" gamerule is false if you intend on making use of the duration. If it is true, the weather cycle will not occur, rendering the duration useless.

What's next?​

After learning about commands and target selectors, command blocks, and a variety of useful commands, it's time to put them together and create a small project in the form of a Complete the Monument system.

[!div class="nextstepaction"] Create an In-World Game with Commands

(Source: ms-learn, creator/Documents/CommandsDamageIntroduction.md)

Introduction to the Damage Command​

The /damage command allows users to deal damage to a specified entity from a specified source. For example, you can deal fire damage to a creeper or fall damage to a zombie. This feature provides a more direct and controlled way to apply damage when compared to other methods, such as spawning in arrows.

In this tutorial you will learn the following:

[!div class="checklist"]

  • What the /damage command is and how to use it
  • Special use cases and exceptions
Requirements​

It's recommended that the following be completed before beginning this tutorial.

  • Introduction to Commands

Syntax of the Damage Command​

The damage command can be called in two ways.

/damage <target> <amount> [cause]
/damage <target> <amount> <cause> entity <damager>
  • target is a selector. It determines the entities that will receive the damage.

  • amount is an integer. This is the amount of damage that will be dealt.

  • cause determines what kind of damage will be dealt. This can affect the death message, and some targets may resist or ignore certain damage causes

    • For example, helmets reduce stalactite damage, and cats are immune to fall damage.
    • Cause must be one of anvil, block_explosion, charging, contact, drowning, entity_attack, entity_explosion, fall, falling_block, fire, fire_tick, fireworks, fly_into_wall, freezing, lava, lightning, magic, magma, none, override, piston, projectile, self-destruct, stalactite, stalagmite, starve, suffocation, temperature, thorns, void, wither.
  • damager is a selector that must evaluate to one entity. It determines which entity will be treated as dealing the damage to the target. For example, a damaged zombified piglin will get angry at this entity.

    • If specified, the target will also take knockback such that they are pushed away from the damager, no matter the distance between the two entities.
    • In peaceful difficulty, the player will ignore all damage if the damager is a mob.

Special use cases​

Because both the damage and source follow the damage rules specified in behavior packs, there are some unique use cases that may not deal damage, or may deal damage when it would be expected they shouldn't.

If the affected entity has a damage_sensor component, the damage dealt by this command will activate it when applicable. The presence or absence of this behavior on vanilla mobs may make some situations unintuitive. Here are a few examples:

Drowning damage​

drowning damage can still be dealt to aquatic and undead mobs. This is because while they can breathe underwater, they are not immune to drowning damage itself.

Zombie conversion​

A villager may receive damage from a zombie or husk, but will only transform into a zombie if the damage was fatal.

Drowning zombies​

Dealing drowning damage does not turn zombies and husks into Drowned. This is because the check to change something to a Drowned is based on the amount of time underwater, not the amount of damage dealt.

Glow squid glow​

A glow squid will stop glowing and emit ink when damaged, but only if there was a damage source.

This logic also applies to the glow squid and squids inking behavior. If the damage applied has no source, it will not "ink".

Slow falling​

The player receives fall damage by using the /damage command when the Slow Falling status effect is applied. The Slow Falling status effect does not prevent fall damage explicitly, so it would not prevent the Damage Command from applying damage.

What's Next?​

There are more commands out there for you to use to unleash mayhem upon your world - or use to make things nice. It's up to you.

[!div class="nextstepaction"] Popular Commands

(Source: ms-learn, creator/Documents/TickingAreaCommand.md)

Introduction to Ticking Areas​

Minecraft time passes (typically) only in the chunks of the world where there is a player. The chunk of area around a player is where time passes in ticks, so we call this a "ticking area." In this area, crops grow, mobs spawn, and command blocks function as intended. But when the player leaves the ticking area, time stops. Crops don't grow, mobs won't spawn, and command blocks stop functioning. If you want command block to work all the time, no matter where players are, you can use the /tickingarea command.

In this tutorial you will learn the following:

[!div class="checklist"]

  • How to create a ticking area.
  • How to find out what ticking areas have been created.
  • What it means if a ticking area is preloaded.

You should be familiar with these topics:

  • Introduction to Commands
  • Introduction to Command Blocks

You will need a Minecraft world with cheats enabled and coordinates shown.

add​

Ticking areas are not made up of blocks; they are made up of the chunks Minecraft uses to create worlds.

[!NOTE] What's a chunk? A chunk is a portion of a world that's 16 blocks wide and 16 blocks long, extending from the bottom to the top of the world. (In the vanilla Overworld, that's 384 blocks high; in the Nether and the End, it's 256 blocks high.) World maps are generated chunk by chunk.

When you use the /tickingarea add ... command, it uses the parameters you give it to draw a shape that extends all the way up and all the way down from where you place it—like a column. But, you won't actually see the shape in the game, so it's like an imaginary column. Any chunks that are touched by this column are included in the ticking area. This chunk, or collection of chunks, is then saved with a name that you give it as a ticking area.

You can have up to 10 ticking areas in one world and you can keep track of them by name or by their coordinates.

There are two ways to draw the shapes used to add a ticking area:

  • /tickingarea add <from: x y z> <to: x y z> [name: string]: This draws an imaginary square, rectangle, or cube, depending on what coordinates you give it. Remember: the y coordinate doesn't really matter because the shape extends upwards and downwards to the boundaries of your world.
  • /tickingarea add circle <center: x y z> <radius: int> [name: string]: This draws an imaginary circle, with a maximum radius of 4 chunks.
  1. Before you add a ticking area, give yourself a command block that gives you an emerald once every 15 ticks.

  2. Note the coordinates of the command block.

  3. Travel in one direction away from the command block until you notice the command stops. This means you have traveled out of the chunk containing the command block.

  4. Add a ticking area around the command block's coordinates. If you placed the command block at 0 72 0, then you could use /tickingarea add circle 0 72 0 3 emerald_block.

  5. You will start getting emeralds again.

list​

To see a list of all of the ticking areas in a world, use:

/tickingarea list [all-dimensions]

remove​

To remove a ticking area from the game use:

/tickingarea remove <name:string>

or

/tickingarea remove <position x y z>
remove_all​

To remove all of the ticking areas from the game use:

/tickingarea remove_all

Preloaded ticking areas​

Ticking areas typically load after the world containing them is launched, unless you use the preload overload. This could be a useful tool for you if you're having problems with the order things are loading into a world.

:::image type="content" source="Media/TickingArea/loading_ticking_areas.png" alt-text="Image of the loading ticking areas message as Minecraft launches":::

Like the tickingarea add command, there are two syntaxes for the preload overload: one taking a position and one taking an area name.

/tickingarea preload <position> [optional preload value]

/tickingarea preload <area name> [optional preload value]

If the optional preload value is not specified, then the command queries the current preload value. This will print out the ticking area info as well as message with a count of how many matching areas area marked with preload.

For /tickingarea add..., there is an option value to specify that the new area should preload, for both the box and circle variants.

/tickingarea add <min position> <max position> [optional name] [optional preload value]

/tickingarea add circle <center position> <radius in chunks> [optional name] [optional preload value]

Using the schedule command with a ticking area​

Creators can use the /schedule command to make the game wait for chunks and entities to be loaded before executing a series of commands, such as those configured in a ticking area. This is important for our creators so that they can know when they can run their commands in each area.

Syntax of the /schedule command​
/schedule on_area_loaded add <from: x y z> <to: x y z> <function:filepath>

/schedule on_area_loaded add circle <center: x y z> <radius: int> <function: filepath>

/schedule on_area_loaded add tickingarea <name: string> <function: filepath>

What's next?​

Now that you have learned the basics of ticking areas, you can explore how they interact with simulation distance and render distance for more advanced use cases.

[!div class="nextstepaction"] Understanding Simulation Distance, Render Distance, and Ticking Areas Scoreboard Operations Tutorial Create an In-World Game

Sources
idSourceLicenseCommitAccessed
ms-learnMinecraft Creator documentation (Microsoft Learn)CC BY 4.0 (documentation), MIT (code)a9fd1c02026-11-13