Actors API
anvil.api.actors
BPAnimationControllers
Bases: AddonObject
identifier
property
Returns the identifier of the addon object in the format 'namespace:name'.
Returns:
| Name | Type | Description |
|---|---|---|
str |
Identifier
|
The identifier of the addon object. |
name
property
Returns the name of the addon object.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The name of the addon object. |
__export__()
Exports the addon object after potentially shortening its content and replacing backslashes. Logs the event and writes the object to a file.
add_controller(controller_shortname)
Adds a new animation controller to the current actor with default as the initial_state.
Parameters
controller_shortname : str The shortname of the controller you want to add.
Returns
Animation controller.
content(content)
Sets the content of the addon object and returns the object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
any
|
The content to be set for the addon object. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
self |
AddonObject
|
The instance of the current AddonObject. |
set_identifier_data(data)
Sets the data of the addon object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
any
|
The data to be set for the addon object. |
required |
BPAnimations
Bases: AddonObject
identifier
property
Returns the identifier of the addon object in the format 'namespace:name'.
Returns:
| Name | Type | Description |
|---|---|---|
str |
Identifier
|
The identifier of the addon object. |
name
property
Returns the name of the addon object.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The name of the addon object. |
__export__()
Exports the addon object after potentially shortening its content and replacing backslashes. Logs the event and writes the object to a file.
add_animation(animation_short_name, loop=False)
Adds a new animation to the current actor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
animation_short_name
|
str
|
The shortname of the animation you want to add. |
required |
loop
|
bool
|
If the animation should loop or not. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
|
Animation. |
content(content)
Sets the content of the addon object and returns the object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
any
|
The content to be set for the addon object. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
self |
AddonObject
|
The instance of the current AddonObject. |
queue(directory=None)
Queues the animations for export.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str
|
The directory to export to. Defaults to None. |
None
|
set_identifier_data(data)
Sets the data of the addon object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
any
|
The data to be set for the addon object. |
required |
RPAnimationControllers
Bases: AddonObject
identifier
property
Returns the identifier of the addon object in the format 'namespace:name'.
Returns:
| Name | Type | Description |
|---|---|---|
str |
Identifier
|
The identifier of the addon object. |
name
property
Returns the name of the addon object.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The name of the addon object. |
__export__()
Exports the addon object after potentially shortening its content and replacing backslashes. Logs the event and writes the object to a file.
add_controller(controller_shortname, initial_state='default')
Adds a new animation controller to the current actor with default as the initial_state.
Parameters
controller_shortname : str The shortname of the controller you want to add. initial_state : str, optional The initial state of the controller, by default "default".
Returns
Animation controller.
content(content)
Sets the content of the addon object and returns the object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
any
|
The content to be set for the addon object. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
self |
AddonObject
|
The instance of the current AddonObject. |
set_identifier_data(data)
Sets the data of the addon object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
any
|
The data to be set for the addon object. |
required |
SpawnRule
Bases: AddonObject
add_condition
property
Create and add a new spawn condition to this spawn rule.
Each condition represents a different spawning scenario. Multiple conditions allow entities to spawn under various circumstances (e.g., surface vs underground).
Returns:
| Name | Type | Description |
|---|---|---|
_SpawnRuleCondition |
New condition interface for setting spawn requirements. |
description
property
Access the spawn rule description for setting basic properties.
Returns:
| Name | Type | Description |
|---|---|---|
_SpawnRuleDescription |
Description interface for population control and metadata. |
identifier
property
Returns the identifier of the addon object in the format 'namespace:name'.
Returns:
| Name | Type | Description |
|---|---|---|
str |
Identifier
|
The identifier of the addon object. |
name
property
Returns the name of the addon object.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The name of the addon object. |
__init__(identifier, is_vanilla)
Initialize a spawn rule for the specified entity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
Entity identifier (e.g., "mypack:custom_mob"). |
required |
is_vanilla
|
bool
|
Whether this is a vanilla Minecraft entity. |
required |
content(content)
Sets the content of the addon object and returns the object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
any
|
The content to be set for the addon object. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
self |
AddonObject
|
The instance of the current AddonObject. |
queue(directory=None)
Queue this spawn rule for generation in the behavior pack.
Exports the description and all conditions to JSON format and adds the spawn rule file to the generation queue. Only queues if conditions exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str
|
Custom directory path. Uses default if None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
SpawnRule |
Self for method chaining, or None if no conditions exist. |
set_identifier_data(data)
Sets the data of the addon object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
any
|
The data to be set for the addon object. |
required |