Skip to content

Models - Animations Module

anvil.api.models.animations

Builders for Bedrock animation files (*.animations.json).

An :class:Animations is one animations file holding any number of :class:_Animation objects. An animation hands out :class:_AnimBone objects by bone name, and each channel call returns the same bone so keyframes chain.

Example
anims = Animations("my_mob")

walk = anims.animation("walk", length=1.0, loop=True)
walk.bone("arm").rotation(0.0, [0, 0, 0]).rotation(0.5, [0, 30, 0]).rotation(
    1.0, [0, 0, 0]
)
walk.bone("body").position(0.5, [0, 1, 0], pre=[0, 0, 0])
walk.particle(0.25, "minecraft:dust", locator="foot")
walk.sound(0.25, "step")
walk.timeline(0.5, "v.step = 1;")

anims.queue()

Animations

Bases: AddonObject

An animations file (<name>.animations.json) holding many animations.

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.

animation(name, length=None, loop=False, anim_time_update=None, override_previous_animation=False)

Creates an animation in this file and returns it.

This is the only way to add an animation to a set.

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 addon object for processing and logs the event.

Parameters:

Name Type Description Default
directory str

The directory of the addon object.

None

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

validate(geometry)

Checks that every animated bone and locator exists in geometry.

Raises a single ValueError listing all problems.