Runs a particular command asynchronously from the context of the broader dimension. Note that there is a maximum queue of 128 asynchronous commands that can be run in a given tick.
Usually, it executes the command in the next tick. To run command in the same tick, you have to delay the JS code.
Returns a Promise<CommandResult>
. Throws an error synchronously if the queue is full.
Normally we recommend avoiding using commands, however, the following command features are not implemented in scripting API (as of 1.19.60).
- Can't get entity by unique id.
- Can't access ender chest.
- Can't access equipments.
- Can't access ender chest.
- Can't access equipments.
- Can't access ender chest.
- Can't access equipments.
- Can't access ticking areas.
- Can't kick player.
- Can't destroy block
/setblock ... destroy
- Can't clone blocks.
- Can't move blocks.
- Can't display raw title.
- You can't set abilities for each player.
- You can't read player's abilites.
- There's no way to give damage to players & entities.
- Opening GUI with custom command will not possible (unless there's another way) because it's need damage for close the chat UI.
- New execute can be useful to run command with lot of if/unless condition for simplicity or maybe performance.
- Cannot run
/loot
command with /execute.
- Cannot run mcfunctions.
- Cannot set any game rules.
- Cannot read game rules' value.
- Cannot give item with these following NBT Data:
minecraft:can_place_on
minecraft:can_destroy
minecraft:item_lock
minecraft:keep_in_inventory
- Cannot set player's gamemode.
- Cannot set world default gamemode.
- Cannot get structure's location.
- Cannot get biome's location.
- Even though the loot is broken from the start, but it's useful for drop or set the item to players/world.
- Can't get world spawn point.
- Can't set world spawn point.
- Can't get player spawn point.
- Can't set player spawn point.
- Can't clear player spawn point.
- Can't get weather directly.
- Can't set weather.
- Can't set world difficulty.
- Can't play client entity animation.
- Can't enable/disable mobevent.
- Can't add/stop camera shake for player.
- Can't manage active fog settings for player.
- Can't stop playing a sound.
- Can't open the NPC dialogue to player.
- Can't change the dialogue displayed by an NPC.