Commands
src.anvil.api.commands
Camera
Bases: Command
__init__(target)
Transforms the camera for the selected player to a different perspective.
Clone
Bases: Command
__init__(begin, end, destination, cloneMode=CloneMode.normal, maskMode=MaskMode.replace)
Clones a region of blocks.
Hud
Bases: Command
__init__(target, visible=HudVisibility.Reset, hud_element=HudElement.All)
Changes the visibility of HUD elements for a player.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target
|
Selector | Target
|
The player to change the HUD visibility for. |
required |
visible
|
HudVisibility
|
The visibility state to set. Defaults to HudVisibility.Reset. |
Reset
|
hud_element
|
HudElement
|
The HUD element to change the visibility of. Defaults to HudElement.All. |
All
|
ScriptEvent
Bases: Command
__init__(message_id, message=None)
Causes an event to fire within script with the specified message ID and payload. This can be used to connect scripting with any location where commands are used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message_id
|
str
|
Identifier of the message to send. This is custom and dependent on the kinds of behavior packs and content you may have installed within the world. |
required |
message
|
str
|
Data component of the message to send. This is custom and dependent on the kinds of behavior packs and content you may have installed within the world. |
None
|
Stopsound
Bases: Command
__init__(target, sound='')
Stop a sound for a player with an optional sound string .
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target
|
Target
|
A player name string or Target to identify the player. |
required |
sound
|
str
|
A string from the sound enum of the sound to stop. Defaults to "". |
''
|
Time
Bases: Command
__init__()
Changes the world's game time.
add(amount)
Add an integer amount of time in-game.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
amount
|
int
|
The amount of time to add. |
required |
set(amount)
Set the time in-game.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
amount
|
TimeSpec | int
|
The time to set. |
required |
XP
Bases: Command
__init__()
Adds or removes player experience.
add(target, amount)
Adds experience to a player.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target
|
Selector | Target | str
|
The target to add experience to. |
required |
amount
|
int
|
The amount of experience to add. |
required |
Returns:
Name | Type | Description |
---|---|---|
Command |
Command
|
The command. |
remove(target, amount)
Removes experience from a player.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target
|
Selector | Target | str
|
The target to remove experience from. |
required |
amount
|
int
|
The amount of experience to remove. |
required |
Returns:
Name | Type | Description |
---|---|---|
Command |
Command
|
The command. |