Skip to content

Actors - Spawn Rules Module

anvil.api.actors.spawn_rules

The behavior pack's spawn_rules/<entity>.spawn_rules.json: where and how an entity spawns.

SpawnRule

Bases: JsonFile[_SpawnRulesFile]

An entity's spawn rules: its population pool and the conditions it spawns under. Written only when it has conditions.

Documentation reference

add_condition property

Adds a set of conditions the entity spawns under, and returns it. Each set is another way to spawn, such as on the surface or underground.

description property

The description builders, such as set_population_control.

identifier property

The file's identifier.

name property

The identifier's name, without its namespace.

__export__()

Exports the addon object after potentially shortening its content and replacing backslashes. Logs the event and writes the object to a file.

__init__(identifier, is_vanilla=False)

Creates the spawn rules of an entity.

Parameters:

Name Type Description Default
identifier str

The entity identifier, such as mypack:custom_mob.

required
is_vanilla bool

If the entity is a vanilla one.

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 spawn rules for export, when they have conditions.

Parameters:

Name Type Description Default
directory str

The folder inside spawn_rules.

None