onyx.commands

class onyx.commands.Bossbar

Bossbar commands

static list()

list - Gets a list of all bossbars. Only useful with execute store.

Returns

Command

Return type

str

class onyx.commands.Data

Data commands

static get(data_source)

get - Gets a piece of data from a source

Parameters

data_source (DataSource) – The entity to get the data from. Only specify source_type, location, and path for the DataSource object.

Returns

Command

Return type

str

static merge(data_source, data)

merge - Merges NBT with the data source

Parameters
  • data_source (DataSource) – The entity to merge the data with. Only specify source_type and location for the DataSource object.

  • data (Compound) – The data to be merged with the entity. Use nbtlib.Compound or stringified NBT.

Returns

Command

Return type

str

static modify(data_source, operation, value, insert_index=None)

modify - Directly modify a piece of data on an entity

Parameters
  • data_source (DataSource) – The entity to modify the data of. Only specify source_type, location, and path for the DataSource object.

  • operation (data_operator) – How the data should be modified (append, insert, merge, prepend, or set). Use set_from if the data is being copied from another entity. Otherwise, use set_value.

  • value (Union[DataSource, nbtlib.Base]) – Either another DataSource object to copy data from, or the value to set the data to. Use nbtlib.Base or stringified NBT if setting to a specific value.

  • insert_index (int, optional) – The index of path to modify the data of. Only specify if operation is insert. Defaults to None.

Returns

Command

Return type

str

static remove(data_source)

remove - Deletes a piece of data from an entity

Parameters

data_source (DataSource) – The data path to remove. Only specify source_type, location, and path for the DataSource object.

Returns

Command

Return type

str

class onyx.commands.Datapack

Datapack commands

static disable(pack_name)

disable - Disables a data pack. Do not use this to have a data pack disable itself. You will not be able to re-enable it without running the command directly or without another data pack.

Parameters

pack_name (Union[str, DataPack]) – The data pack to disable. This can infer the data pack name from the DataPack object.

Returns

Command

Return type

str

static enable(pack_name, mode=None, other_pack=None)

enable - Enables a data pack

Parameters
  • pack_name (Union[str, DataPack]) – The pack to enable

  • mode (datapack_enable_mode, optional) – How the data pack should be enabled (prepend, append, first, or last). Defaults to None.

  • other_pack (Union[str, "DataPack"], optional) – A pack that this pack should be enabled relative to. Only use if mode is after or before. Defaults to None.

Returns

Command

Return type

str

static list()

list - Gets a list of all data packs. Only useful with execute store.

Returns

Command

Return type

str

class onyx.commands.Debug

Debug commands

static function(function)

function - Debugs a function and stores relevant information in a text file

Parameters

function (Union[str, Function]) – The function to debug. This can infer the function name from the Function object.

Returns

Command

Return type

str

static start()

start - Starts the debug mode

Returns

Command

Return type

str

static stop()

stop - Stops the debug mode

Returns

Command

Return type

str

class onyx.commands.Effect

Effect commands

static clear(targets, effect=None)

clear - Clears an effect from the selected targets

Parameters
  • targets (Selector) – The targets to clear the effect from

  • effect (Union[effect, list], optional) – The effects to remove. Set to a list of effects to remove multiple at once. Defaults to None.

Returns

Command(s)

Return type

Union[str, list]

static give(targets, effect, seconds=30, amplifier=1, show_particles=False)

give - Gives an effect to the selected targets

Parameters
  • targets (Selector) – The targets to give the effect to

  • effect (effect) – The effect to give

  • seconds (int, optional) – The duration of the effect. Defaults to 30.

  • amplifier (int, optional) – How strong the effect is. Defaults to 1.

  • show_particles (bool, optional) – Whether or not effect particles should be shown. Defaults to False.

Returns

Command

Return type

str

class onyx.commands.Experience

Experience commands

static add(players, amount, experience_type=None)

add - Gives experience to a player

Parameters
  • players (Selector) – The player(s) to give experience to

  • amount (Union[int, str]) – The amount of experience to give. Supports both points with 300 and levels with "300L".

Returns

Command

Return type

str

static clear(players)

clear - Clears all experience from the player(s)

Parameters

players (Selector) – The players to clear experience from

Returns

Command

Return type

str

static query(player, type=experience_type.levels)

query - Get the amount of experience from the player(s). Only useful with execute store.

Parameters
  • player (Selector) – The players to get the experience of. If this selector targets multiple players, only the last targetted players experience will be saved.

  • type (experience_type, optional) – Levels or points. Defaults to experience_type.levels.

Returns

Command

Return type

str

static set(players, amount, experience_type=None)

set - Sets the player(s) experience

Parameters
  • players (Selector) – The players to set the experience of

  • amount (Union[int, str]) – What the experience should be set to. Supports both points with 300 and levels with "300L".

  • experience_type (experience_type, optional) – Levels or points. Defaults to None.

Returns

Command

Return type

str

class onyx.commands.Forceload

Forceload commands

static add(pos1, pos2=None)

add - Forceloads all chunks in the selected area

Parameters
  • pos1 (Vector2) – The first corner of the selection area

  • pos2 (Vector2, optional) – The second corner of the selection area. If left unspecified, then the first corner is used as the second corner. Defaults to None.

Returns

Command

Return type

str

static query(position)

query - Check if a position is forceloaded

Parameters

position (Vector2) – The position to check

Returns

Command

Return type

str

static remove(pos1, pos2=None)

remove - Remove all forceloaded chunks in the selected area

Parameters
  • pos1 (Vector2) – The first corner of the selection area

  • pos2 (Vector2, optional) – The second corner of the selection area. If left unspecified, then the first corner is used as the second corner. Defaults to None.

Returns

Command

Return type

str

static remove_all()

remove_all - Remove all forceloaded chunks

Returns

Command

Return type

str

class onyx.commands.Item

Item commands

static modify(source, modifier)

modify - Apply a modifier to an item

Parameters
  • source (DataSource) – The source of the item. Only specify source_type, location, and path (as a slot) for the DataSource object.

  • modifier (Union[ItemModifier, str]) – The modifier to apply

Returns

Command

Return type

str

static replace(source, value, infer_replace_mode_override=None)

replace - Replaces an entity at the source with another item

Parameters
  • source (DataSource) – The location of the item to replace

  • value (Union[Item, DataSource]) – The item to replace the source. Set to an item to replace directly, or use a DataSource object to replace it with an item from another source.

  • infer_replace_mode_override (str, optional) – Whether or not from or with should be used in the command is inferred from the type of value. If you’re not getting the right output, you can edit this manually by setting this. Defaults to None.

Returns

Command

Return type

str

class onyx.commands.Loot

Loot commands

static give(targets, loot_table=None, block=None, killed_entity=None, broken_with=None, infer_context_override=None)

give - Give a player some loot

Parameters
  • targets (Selector) – The players to give loot to

  • loot_table (Union[LootTable, str], optional) – The loot table containing the loot you want to give. Defaults to None.

  • block (Vector3, optional) – Either the block that was broken or where the loot should be placed in the case of fish. Defaults to None.

  • killed_entity (Selector, optional) – The entity that was killed. Defaults to None.

  • broken_with (Union[item, hand], optional) – The item the block was broken with. Defaults to None.

  • infer_context_override (str, optional) – The context for the command is inferred from the parameters passed in. You can override this by setting this variable (should be fish, mine, loot, or kill). Defaults to None.

Returns

Command

Return type

str

static insert(target, loot_table=None, block=None, killed_entity=None, broken_with=None, infer_context_override=None)

insert - Insert loot into a container

Parameters
  • targets (Vector3) – The block to insert the items in

  • loot_table (Union[LootTable, str], optional) – The loot table containing the loot you want to give. Defaults to None.

  • block (Vector3, optional) – Either the block that was broken or where the loot should be placed in the case of fish. Defaults to None.

  • killed_entity (Selector, optional) – The entity that was killed. Defaults to None.

  • broken_with (Union[item, hand], optional) – The item the block was broken with. Defaults to None.

  • infer_context_override (str, optional) – The context for the command is inferred from the parameters passed in. You can override this by setting this variable (should be fish, mine, loot, or kill). Defaults to None.

Returns

Command

Return type

str

static replace(targets, loot_table=None, block=None, killed_entity=None, broken_with=None, infer_context_override=None)

replace - Replace a slot in a container with loot

Parameters
  • targets (DataSource) – The data location to put the items in. Only specify source_type, location, and path in the DataSource object (where path is a slot name).

  • loot_table (Union[LootTable, str], optional) – The loot table containing the loot you want to give. Defaults to None.

  • block (Vector3, optional) – Either the block that was broken or where the loot should be placed in the case of fish. Defaults to None.

  • killed_entity (Selector, optional) – The entity that was killed. Defaults to None.

  • broken_with (Union[item, hand], optional) – The item the block was broken with. Defaults to None.

  • infer_context_override (str, optional) – The context for the command is inferred from the parameters passed in. You can override this by setting this variable (should be fish, mine, loot, or kill). Defaults to None.

Returns

Command

Return type

str

static spawn(target, loot_table=None, block=None, killed_entity=None, broken_with=None, infer_context_override=None)

spawn - Summons loot as items

Parameters
  • targets (Vector3) – The location to spawn the items at

  • loot_table (Union[LootTable, str], optional) – The loot table containing the loot you want to give. Defaults to None.

  • block (Vector3, optional) – Either the block that was broken or where the loot should be placed in the case of fish. Defaults to None.

  • killed_entity (Selector, optional) – The entity that was killed. Defaults to None.

  • broken_with (Union[item, hand], optional) – The item the block was broken with. Defaults to None.

  • infer_context_override (str, optional) – The context for the command is inferred from the parameters passed in. You can override this by setting this variable (should be fish, mine, loot, or kill). Defaults to None.

Returns

Command

Return type

str

class onyx.commands.Perf

Perf commands

static start()

start - Start capturing metrics on a server. This will automatically stop after 10 seconds.

Returns

Command

Return type

str

static stop()

stop - Stop capturing metrics on a server prematurely

Returns

Command

Return type

str

class onyx.commands.Recipe

Recipe commands

static give(players, recipe)

give - Gives player(s) a recipe

Parameters
  • players (Selector) – The players to give the recipe to

  • recipe (recipe) – The recipe to give

Returns

Command

Return type

str

static take(players, recipe)

take - Takes a recipe from the player(s)

Parameters
  • players (Selector) – The players to take the recipe from

  • recipe (recipe) – The recipe to take

Returns

Command

Return type

str

class onyx.commands.Schedule

Schedule commands

static clear(function)

clear - Clear a function from the schedule

Parameters

function (Union[Function, str]) – The function to clear

Returns

Command

Return type

str

static function(function, time, schedule_mode=schedule_mode.replace)

function - Schedules a function

Parameters
  • function (Union[Function, str]) – The function to schedule

  • time (Union[int, str]) – The time to wait before the function runs. If int, unit is ticks. Ticks, seconds, minutes, hours, days, weeks are supported as a string. 3, “3t”, “3s”, “3m”, “3h”, “3d”, and “3w” are all supported values. Note that the unit will be converted to the closest matching neighbor. Ticks are left as ticks, minutes are converted to seconds, hours are converted to seconds, and weeks are converted to days.

  • schedule_mode (schedule_mode, optional) – Whether or not the functions existing schedule time or allow multiple schedules for the same function to exist at once. Defaults to schedule_mode.replace.

Returns

Command

Return type

str

class onyx.commands.Scoreboard

Scoreboard commands

static list_player_scores(target)

list_player_scores - Get a list of all scores for a player

Parameters

target (Selector) – The players to get the scores of

Returns

Command

Return type

str

static reset_player_scores(target)

reset_player_scores - Reset all scores of the player(s)

Parameters

target (Selector) – The players to reset the scores of

Returns

Command

Return type

str

static list_objectives()

list_objectives - Get a list of all objectives. Only useful with execute store.

Returns

Command

Return type

str

class onyx.commands.Tag

Tag commands

static add(targets, tag_name)

add - Add a tag to the target(s)

Parameters
  • targets (Selector) – The targets to add the tag to

  • tag_name (str) – The tag to add

Returns

Command

Return type

str

static list(targets)

list - Get a list of all tags on the target(s)

Parameters

targets (Selector) – The targets to get the tags of

Returns

Command

Return type

str

static remove(targets, tag_name)

remove - Remove a tag from the target(s)

Parameters
  • targets (Selector) – The targets to remove the tag from

  • tag_name (str) – The tag to remove

Returns

Command

Return type

str

class onyx.commands.Team

Team commands

static add(name, display_name=None)

add - Creates a team

Parameters
  • name (str) – The name of the team

  • display_name (TextComponent, optional) – The display name of the team. Defaults to None.

Returns

Command

Return type

str

static empty(name)

empty - Empties a team

Parameters

name (str) – The team to empty

Returns

Command

Return type

str

static join(name, targets)

join - Adds the target(s) to the team

Parameters
  • name (str) – The team to add the target(s) to

  • targets (Selector) – The target(s) to add to the team

Returns

Command

Return type

str

static leave(targets)

leave - Removes the target(s) from their teams

Parameters

targets (Selector) – The target(s) to remove from their teams

Returns

Command

Return type

str

static list(name=None)

list - Get a list of all players in a team

Parameters

name (str, optional) – The team to get the list of players from. Defaults to None.

Returns

Command

Return type

str

static modify(name, attribute, value)

modify - Modifies a team’s attribute

Parameters
  • name (str) – The team to modify

  • attribute (team_attribute) – The attribute to modify

  • value (Union[bool, TextComponent, color, collision_rule, death_message_visibility, nametag_visibility]) – The value to set the attribute to

Returns

Command

Return type

str

static remove(name)

remove - Deletes a team

Parameters

name (str) – The team to delete

Returns

Command

Return type

str

class onyx.commands.Time

Time commands

static add(time)

add - Adds time to the world

Parameters

time (str) – The amount of time to add. Seconds, minutes, hours, days, weeks are supported as a string. 3, “3s”, “3m”, “3h”, “3d”, and “3w” are all supported values. Note that all units will be converted to time units. See this wiki page for more info.

Returns

Command

Return type

str

static query(type)

query - Get the current time

Parameters

type (time_query) – What type of time should be queried (day count, day time, or game time)

Returns

Command

Return type

str

static set(time)

set - Sets the time of the world

Parameters

time (str) –

The amount to be set. Seconds, minutes, hours, days, weeks are supported as a string. 3, “3s”, “3m”, “3h”, “3d”, and “3w” are all supported values. Note that all units will be converted to time units. See this wiki page for more info.

Returns

Command

Return type

str

class onyx.commands.Title

Title commands

static actionbar(players, text)

actionbar - Sets text in the action bar

Parameters
Returns

Command

Return type

str

static clear(players)

clear - Clear all titles

Parameters

players (Selector) – The players to clear the titles of

Returns

Command

Return type

str

static reset(players)

reset - Reset subtitle and title timings to their default value

Parameters

players (Selector) – The players to reset the subtitles and title timings of

Returns

Command

Return type

str

static subtitle(players, text, only_subtitle=False)

subtitle - Sets text as a subtitle

Parameters
  • players (Selector) – The players to show the text to

  • text (TextComponent) – The text to show

  • only_subtitle (bool, optional) – Whether or not the subtitle will be shown by itself. If True, a blank title will be created. Defaults to False.

Returns

Command

Return type

str

static times(players, fadeIn, stay, fadeOut)

times - Sets the fade in, stay, and fade out times for titles

Parameters
  • players (Selector) – The players to modify the title timings of

  • fadeIn (int) – How long it takes for the text to fade in in ticks

  • stay (int) – How long the text will stay in ticks

  • fadeOut (int) – How long it takes for the text to fade out in ticks

Returns

Command

Return type

str

static title(players, text)

title - Sets text as a title

Parameters
Returns

Command

Return type

str

class onyx.commands.Trigger

Trigger commands

static add(objective, value)

add - Adds to the score of a trigger objective

Parameters
  • objective (Union[str,) – The objective to add to the score of. Player is not specified as the scoreboard player is @s.

  • value (Union[int, float]) – The value to add

Returns

Command

Return type

str

static set(objective, value)

sets - Sets a score of a trigger objective

Parameters
  • objective (Union[str,) – The objective to set the score of. Player is not specified as the scoreboard player is @s.

  • value (Union[int, float]) – The value to set

Returns

Command

Return type

str

class onyx.commands.Worldborder

Worldborder commands

static add(distance, time=0)

add - Increases the area of the world border

Parameters
  • distance (int) – The distance in blocks that will be added to the world border (even numbers will go to half blocks)

  • time (int) – How long it should take for the world border to transition to the new size. Defaults to 0.

Returns

Command

Return type

str

static center(position)

center - Defines the center of the world border

Parameters

position (AbsPos2D) – The position to set the center of the world border to

Returns

Command

Return type

str

static damage(per_block=None, buffer_distance=None)

damage - Sets the amount of damage done by the world border

Parameters
  • per_block (int, optional) – How much damage should be done to the player per second per block that they move past the world border buffer. Defaults to None.

  • buffer_distance (int, optional) – How distance from the world border the player must be before taking damage. Defaults to None.

Raises

ValueError – Neither per_block nor buffer_distance are specified

Returns

Command

Return type

str

static get()

get - Gets the world border size. Only useful with execute store.

Returns

Command

Return type

str

static set(distance, time=0)

set - Sets the world border size

Parameters
  • distance (int) – The new size of the world border

  • time (int) – How long it should take for the world border to transition to the new size. Defaults to 0.

Returns

Command

Return type

str

static warning(distance=None, time=None)

warning - Sets a world border warning

Parameters
  • distance (int, optional) – The distance the player has to be from the world border to start showing a red border.. Defaults to None.

  • time (int, optional) – The time in seconds the world border has to be away from the player before showing a red border. Defaults to None.

Raises

ValueError – Neither distance nor time are specified

Returns

Commands

Return type

list

class onyx.commands.Commands

Commands - A class containing all the commands in the game. Commands with many sub-commands are split into their own classes.

static push(command, init=False)

push - Adds a command to the function contents. All function calls for commands go through this function at some point.

Parameters
  • command (str) – The command to add

  • init (bool, optional) – Whether or not the command is added to the pack’s _init.mcfunction. Defaults to False.

Returns

The command that was added

Return type

str

static comment(text, preline=1, postline=0)

comment - Adds a comment to the function

Parameters
  • text (str) – The comment contents

  • preline (int, optional) – How many blank lines should be inserted before the comment. Defaults to 1.

  • postline (int, optional) – How many blank lines should be inserted after the comment. Defaults to 0.

Return type

None

static advancement(should_revoke, players, advancement_mode, advancement_source=None)

advancement - Modify advancements on players

Parameters
  • should_revoke (bool) – Whether or not the advancement specified should be revoked or not.

  • players (Selector) – The players to modify the advancements of

  • advancement_mode (advancement_mode) – How the advancement should be modified (everything, from, only, through, until)

  • advancement_source (Union[Advancement, optional) – The source of the advancement that should be added or removed to players. Only specify if advancement_mode is NOT everything. Defaults to None.

Returns

Command

Return type

str

static attribute(targets, attribute, attribute_mode, modifier=None, scale=1, base_value=None)

attribute - Modify attributes on entities

Parameters
  • targets (Selector) – The entities to modify the attributes of

  • attribute (attribute) – The attribute to modify

  • attribute_mode (attribute_mode) – How the attribute should be modified (get, get_base, set_base, add_modifier, etc.)

  • modifier (AttributeModifier, optional) – The modifier to apply to the selected attribute. Only use with modifier advancement modes. Defaults to None.

  • scale (Union[int, float], optional) – The scale at which an attribute should be retrieved. Only useful with execute store. Defaults to 1.

  • base_value (int, optional) – The value for base set. Should only be specified if attribute_mode is base set. Defaults to None.

Returns

Command

Return type

str

static clear(players, item=None, max_count=None)

clear - Clears an item from players

Parameters
  • players (Selector) – The players to clear the item from

  • item (Union[item, str], optional) – The item to clear. Defaults to None.

  • max_count (int, optional) – The limit on how many items can be cleared. Defaults to None.

Returns

Command

Return type

str

static clone(corner1, corner2, location, mask_mode=clone_mask_mode.replace, filter=None, clone_mode=clone_mode.normal)

clone - Clone blocks in a selected area

Parameters
  • corner1 (Vector3) – Corner 1 of the selection area

  • corner2 (Vector3) – Corner 2 of the selection area

  • location (Vector3) – The location the selection area should be cloned to

  • mask_mode (clone_mask_mode, optional) – What blocks should be selected in the clone area. filtered removes blocks that don’t match the block/block tag specified in the filter argument. masked prevents air from overriding blocks at the location. replace replaces everything at the location. Defaults to clone_mask_mode.replace.

  • filter (Block, optional) – Argument for mask_mode. Only specify if mask_mode is filtered. Defaults to None.

  • clone_mode (clone_mode, optional) – How the cloning should be done (force, move, or normal). Defaults to clone_mode.normal.

Returns

Command

Return type

str

static defaultgamemode(mode)

defaultgamemode - Sets the default game mode

Parameters

mode (gamemode) – The gamemode to set as the default

Returns

Command

Return type

str

static difficulty(difficulty)

difficulty - Sets the difficulty

Parameters

difficulty (difficulty) – The difficulty to set

Returns

Command

Return type

str

static enchant(players, enchantment, level=1)

enchant - Adds enchantments to the selected item on a player

Parameters
  • players (Selector) – The players whose selected item should be enchanted

  • enchantment (Union[enchantment, dict]) – The enchantment to apply. Can either be specified as an enchantment or a dictionary. If dictionary, the keys are the enchantments and the values are the levels.

  • level (int, optional) – The level of the enchantment. Only specify if enchantment is not a dictionary. Defaults to 1.

Returns

Command(s)

Return type

Union[str, list]

static fill(corner1, corner2, block, mode=fill_mode.replace, replace_block=None)

fill - Fills all blocks in an area with a specified block

Parameters
  • corner1 (Vector3) – Corner 1 of the selection area

  • corner2 (Vector3) – Corner 2 of the selection area

  • block (block) – The block to fill in the selection area

  • mode (fill_mode, optional) – How the fill should be done (destroy, hollow, keep, outline, replace). Defaults to fill_mode.replace.

  • replace_block (block, optional) – What blocks should be replaced. Only specify if mode is replace. Defaults to None.

Returns

Command

Return type

str

static function(function)

function - Executes a function

Parameters

function (Union[Function, str]) – The function to execute. An alternative to function <FunctionObj> is just <FunctionObj()>.

Returns

Command

Return type

str

static gamemode(mode, players)

gamemode - Sets the gamemode of players

Parameters
  • mode (gamemode) – The gamemode to set

  • players (Selector) – The players to set the gamemode of

Returns

Command

Return type

str

static gamerule(rule, value)

gamerule - Modifies a gamerule

Parameters
  • rule (gamerule) – The rule to modify

  • value (Union[bool, int, str]) – The new value of the gamerule

Returns

Command

Return type

str

static give(players, item, count=None)

give - Gives an item to players

Parameters
  • players (Selector) – The players to give the item to

  • item (Union[item, Item]) – The item to be given. If you need to specify item NBT, use an Item object.

  • count (int, optional) – How many of the item should be given. Defaults to None.

Returns

Command

Return type

str

static help(command=None)

help - Displays help for a command

Parameters

command (str, optional) – The command to get help for. Defaults to None.

Returns

Command

Return type

str

static kill(targets, clean_kill=False)

kill - Kills entities

Parameters
  • targets (Selector) – The entities to kill

  • clean_kill (bool, optional) – If True, then a data merge command is used instead to leave no trace of the entity (no particles, items, etc.). This will not work on players (it won’t fail, but it won’t do anything to them either). Defaults to False.

Returns

Command

Return type

str

static list(include_uuids=False)

list - Lists all online players

Parameters

include_uuids (bool, optional) – Whether or not the UUID should be listed next to the player name. Defaults to False.

Returns

Command

Return type

str

static locate(structure)

locate - Get the distance to the nearest specified structure

Parameters

structure (structure) – The structure to target

Returns

Command

Return type

str

static locatebiome(biome)

locatebiome - Get the distance to the nearest specified biome

Parameters

biome (biome) – The biome to target

Returns

Command

Return type

str

static me(text)

me - Display a message about the executor

Parameters

text (str) – The message to display

Returns

Command

Return type

str

static msg(players, text)

msg - Messages a player

Parameters
  • players (Selector) – The players to message

  • text (str) – The message to send

Returns

Command

Return type

str

static particle(particle_settings, force=False, players=None)

particle - Displays a particle

Parameters
  • particle_settings (Particle) – Information about the particle itself

  • force (bool, optional) – Whether the particle should be forced to render. Defaults to False.

  • players (Selector, optional) – The players who can see the particle. Defaults to None.

Returns

Command

Return type

str

static playsound(sound, channel, players, position=None, volume=None, pitch=None)

playsound - Plays a sound

Parameters
  • sound (str) – The sound to play

  • channel (sound_channel) – The channel to play the sound on

  • players (Selector) – The players to play the sound to

  • position (Vector3, optional) – The position that the sound should be played from. Defaults to None.

  • volume (Union[int, float], optional) – How far away the sound can be heard in blocks. Defaults to None.

  • pitch (float, optional) – The pitch of the sound. Defaults to None.

Raises
  • ValueError – Invalid sound channel (stopsound exclusive)

  • ValueError – Invalid pitch value (must be between 0 and 2)

Returns

Command

Return type

str

static say(text)

say - Prints text to chat

Parameters

text (str) – The text to print

Returns

Command

Return type

str

static seed()

seed - Gets the world seed

Returns

Command

Return type

str

static setblock(position, block, mode=setblock_mode.replace)

setblock - Sets a block

Parameters
  • position (Vector3) – The position to set the block at

  • block (Block) – The block to set

  • mode (setblock_mode, optional) – How the block should be set (destroy, keep, replace). Defaults to setblock_mode.replace.

Returns

Command

Return type

str

static setworldspawn(position, angle=0)

setworldspawn - Sets the world spawn

Parameters
  • position (Vector3) – The position to set the world spawn at

  • angle (Union[int, float], optional) – The Y (horizontal) angle that the players will spawn at. Defaults to 0.

Returns

Command

Return type

str

static spawnpoint(players, position, angle=0)

spawnpoint - Sets the spawn point of specific players

Parameters
  • players (Selector) – The players to set the spawn point of

  • position (Vector3) – The position to set the spawn point at

  • angle (Union[int, float], optional) – The Y (horizontal) angle that the players will spawn at. Defaults to 0.

Returns

Command

Return type

str

static spectate(target, source='@s', put_in_gamemode=False)

spectate - Forces an entity to spectate another

Parameters
  • target (Selector) – The entity which should be spectated

  • source (Selector, optional) – The entity that will be spectating the target. Defaults to “@s”.

  • put_in_gamemode (bool, optional) – Whether the target should be put in spectator mode. Defaults to False.

Returns

Command

Return type

str

static spreadplayers(center, spread_distance, max_range, respect_teams, players, under=None)

spreadplayers - Spreads players around a point

Parameters
  • center (Vector2) – The point at which players should be spread around

  • spread_distance (Union[int, float]) – The minimum distance between players

  • max_range (Union[int, float]) – The maximum distance from the center that players should be spread to. This area is a square, not a circle.

  • respect_teams (bool) – Whether or not teams should be kept together

  • players (Selector) – The players that should be spread

  • under (Union[int, float], optional) – The maximum height players can be spread to. If undefined, players will be put as high as possible. Defaults to None.

Returns

Command

Return type

str

static stopsound(targets, channel=None, sound=None)

stopsound - Stops sound(s) for players

Parameters
  • targets (Selector) – The players to stop the sound(s) for

  • channel (sound_channel, optional) – The channel to stop the sound(s) on. Defaults to None.

  • sound (str, optional) – The sound to stop. Defaults to None.

Returns

Command

Return type

str

static summon(type, position, nbt=None)

summon - Summons an entity

Parameters
  • type (entity) – The identifier of the entity to summon

  • position (Vector3) – The location that the entity should be summoned at

  • nbt (Compound, optional) – Any NBT that should be placed on the entity. Defaults to None.

Returns

Command

Return type

str

static teammsg(text)

teammsg - Sends a message to the players team

Parameters

text (str) – The message to send

Returns

Command

Return type

str

static teleport(targets, destination, facing=None)

teleport - Teleports entities to another entity or a location

Parameters
  • targets (Selector) – The entities to teleport

  • destination (Union[Selector, Vector3]) – The location or entity the targets should be teleported to

  • facing (Union[Selector, Vector3], optional) – The location or entity the targets should be facing. Defaults to None.

Returns

Command

Return type

str

static tellraw(players, text)

tellraw - Prints a text component

Parameters
  • players (Selector) – The players the text should be sent to

  • text (TextComponent) – The text to print

Returns

Command

Return type

str

static weather(weather_type, duration=None)

weather - Modifies the weather

Parameters
  • weather_type (weather_type) – The weather that should be set

  • duration (int, optional) – How long the weather should last. Defaults to None.

Returns

Command

Return type

str