Skip to content

Camera - Aim Assist

anvil.api.camera.aim_assist

Aim assist presets and categories, used by a camera preset's aim assist.

AimAssistCategories

Bases: JsonFile[_AimAssistCategoriesFile]

The aim assist categories of the pack, written next to the aim assist presets as categories.json. Only one category is active at a time, chosen by the held item.

Documentation reference

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__()

Initializes the Aim Assist Categories file.

__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_category(category)

Adds an aim assist category and returns it.

Parameters:

Name Type Description Default
category str

The category name.

required

queue()

Queues the aim assist categories for export.

AimAssistCategory

Bases: JsonObject

An aim assist category: the targeting priority of blocks and entities. Made by AimAssistCategories.add_category.

Parameters:

Name Type Description Default
name str

The category name, used by AimAssistPreset.

required

__required__ = () class-attribute

JSON keys the schema marks required although their field is optional, because __validate__ requires them.

__from_json__(data) classmethod

Builds the object from its parsed JSON, the inverse of __json__(). Each key goes to the field written under it, read through the field's annotation.

Parameters:

Name Type Description Default
data Any

The parsed JSON object.

required

Raises:

Type Description
TypeError

The data is not an object, or a value does not match its field.

ValueError

The data has a key the class does not write, or a constant field holds another value.

__json__()

The JSON payload of this object, built from its fields after checking them.

__json_fields__() classmethod

The compiled fields of this class, compiled on first use.

__post_init__()

Side effects after construction.

__prepare_export__(owner, *, root=True)

Finishes the object for export, where its owner calls it. Components with a localized name override it. root is False for a permutation's components.

__schema__() classmethod

The JSON Schema (draft 2020-12) of this object's JSON, its parts under $defs.

__schema_body__(definitions) classmethod

The schema of this object's JSON, adding the parts it uses to definitions.

Parameters:

Name Type Description Default
definitions dict[str, JsonSchema]

The $defs of the schema being built.

required

__validate__()

Cross-field checks, run on export after the fields are checked.

block_default(value)

Sets the priority of blocks without their own priority.

Parameters:

Name Type Description Default
value int

The priority.

required

block_priority(block, priority)

Sets the priority of a block.

Parameters:

Name Type Description Default
block str

The block identifier.

required
priority int

The priority. Larger numbers are preferred.

required

entity_default(value)

Sets the priority of entities without their own priority.

Parameters:

Name Type Description Default
value int

The priority.

required

entity_priority(entity, priority)

Sets the priority of an entity.

Parameters:

Name Type Description Default
entity str

The entity identifier.

required
priority int

The priority. Larger numbers are preferred.

required

AimAssistPreset

Bases: JsonFile[_AimAssistPresetFile]

An aim assist preset: which category is used for each held item, and what aim assist never targets. Camera presets use one through CameraPreset.aim_assist, the /aimassist command by its identifier.

Written to the behavior pack's cameras/presets/ folder.

Documentation reference

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__(name)

Initializes the Aim Assist Preset.

Parameters:

Name Type Description Default
name str

The preset's name, also its file name. The identifier is <namespace>:<name>.

required

__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.

default_item_settings(category)

Sets the aim assist category for items not given an item_setting.

Parameters:

Name Type Description Default
category str

The category name.

required

exclusion_list(exclusions)

Sets the entities and blocks aim assist ignores.

Parameters:

Name Type Description Default
exclusions list[str]

The block and entity identifiers to exclude, such as "minecraft:bedrock".

required

hand_settings(category)

Sets the aim assist category used when the player holds nothing.

Parameters:

Name Type Description Default
category str

The category name.

required

item_setting(item, category)

Uses an aim assist category while an item is held.

Parameters:

Name Type Description Default
item str

The item identifier.

required
category str

The name of a category in AimAssistCategories.

required

liquid_targeting_list(targets)

Sets the items that are allowed to target liquids.

Parameters:

Name Type Description Default
targets list[str]

The item identifiers that target liquids while held, such as "minecraft:bucket".

required

queue()

Queues the aim assist preset for export.