Skip to content

Entity - Entity Module

anvil.api.actors.entity

Entity

name property

The entity's name, without its namespace.

__init__(name, is_vanilla=False)

Creates an entity: its server and client files share one identifier.

Parameters:

Name Type Description Default
name str

The entity's name, with or without its namespace.

required
is_vanilla bool

If the entity is a vanilla one. Defaults to False.

False

Raises:

Type Description
ValueError

When the name is not valid (see Identifier.parse).

queue(directory=None)

Queues the entity's files to be exported.

Parameters:

Name Type Description Default
directory str

The folder its files go in, under each pack's folder. Vanilla entities go in vanilla.

None

set_display_name(display_name, spawn_egg_name=None)

Sets the names players see, localized by Anvil.

Parameters:

Name Type Description Default
display_name str

The entity's name. Defaults to its name in title case.

required
spawn_egg_name str

Its spawn egg's name. Defaults to Spawn <display name>.

None

Server

anvil.api.actors.server

The behavior pack's entities/<entity>.behavior.json: a server entity, its description, components, component groups and events.

EntityServer

Bases: JsonFile[_EntityServerFile]

A server entity: its description, components, component groups and events.

Documentation reference

components property

The entity's root components.

description property

The description builders.

events property

The entity's events, in the order they were added.

identifier property

The file's identifier.

name property

The identifier's name, without its namespace.

spawn_rule property

The entity's spawn rules.

__init__(name, is_vanilla=False)

Creates a server entity.

Parameters:

Name Type Description Default
name str

The entity's name.

required
is_vanilla bool

If the entity is a vanilla one. Defaults to False.

False

__schema__() classmethod

The JSON Schema (draft 2020-12) of this file: the schema of its _document_type, with the file's type as title and where it is written under x-anvil-file.

Raises:

Type Description
TypeError

When the class is an abstract file base, with no document type.

add_basic_components()

Adds basic server components to the entity.

This includes
  • EntityBreathable
  • EntityCollisionBox
  • EntityDamageSensor
  • EntityHealth
  • EntityJumpStatic
  • EntityKnockbackResistance
  • EntityMovement
  • EntityMovementBasic
  • EntityNavigationWalk
  • EntityPhysics
  • EntityPushableByBlock
  • EntityPushableByEntity
  • EntityPushThrough

component_group(component_group_name)

Returns the component group with this name, added on first use.

Parameters:

Name Type Description Default
component_group_name str

The group name.

required

event(event_name)

Returns the event with this name, added on first use. - minecraft:entity_born runs when the entity is born from breeding. - minecraft:entity_spawned runs when the entity spawns in the world. - minecraft:entity_transformed runs when another entity transforms into it. - minecraft:on_prime runs when the entity is about to explode.

Parameters:

Name Type Description Default
event_name str

The event name.

required

init_vars(**vars)

Initializes variables when the entity is created, in a variables controller.

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 'JsonFile[D]'

The instance of the current JsonFile.

Client

anvil.api.actors.client

The resource pack's entity/<entity>.entity.json: how a client entity renders, and the description builders it shares with the item client (attachable).

EntityClient

Bases: JsonFile[_ClientEntityFile]

A client entity: its geometry, textures, materials, animations and render controllers.

Documentation reference

description property

The description builders.

identifier property

The file's identifier.

name property

The identifier's name, without its namespace.

__init__(name, is_vanilla=False)

Creates a client entity.

Parameters:

Name Type Description Default
name str

The entity's name.

required
is_vanilla bool

If the entity is a vanilla one. Defaults to False.

False

__schema__() classmethod

The JSON Schema (draft 2020-12) of this file: the schema of its _document_type, with the file's type as title and where it is written under x-anvil-file.

Raises:

Type Description
TypeError

When the class is an abstract file base, with no document type.

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 'JsonFile[D]'

The instance of the current JsonFile.