Blocks - Beta Components Module
anvil.beta.blocks.components
Experimental block components. They need features.experimental in anvilconfig.json.
BlockCollisionBoxMinMax
Bases: JsonComponent
[EXPERIMENTAL] The area of the block that collides with entities, as boxes given by their two corners.
It writes minecraft:collision_box like BlockCollisionBox, and clashes with it: a block
cannot use both, in its components or in a permutation.
Experimental: needs features.experimental in anvilconfig.json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
tuple[float, float, float]
|
The minimal corner of the box, in pixels from the bottom-left corner of the block. |
required |
max
|
tuple[float, float, float]
|
The maximal corner of the box. Boxes must stay within (0, 0, 0) and (16, 24, 16). |
required |
Give either min and max, or a voxel shape with set_voxel_shape. Add more boxes with
add_box, up to 32. Boxes are always written as a list.
__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_fields__()
classmethod
The compiled fields of this class, compiled on first use.
__payload_schema__(definitions)
classmethod
The schema of the payload under the identifier.
__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 {identifier: payload}.
add_box(*, min, max)
Adds another collision box, for more complex shapes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
tuple[float, float, float]
|
The minimal corner of the box. |
required |
max
|
tuple[float, float, float]
|
The maximal corner of the box. |
required |
set_voxel_shape(voxel_shape=None, *, blockbench=None, collection=None)
Uses a voxel shape as the collision shape instead of boxes.
Example
BlockCollisionBoxMinMax().set_voxel_shape(blockbench="lantern")
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
voxel_shape
|
VoxelShape
|
A voxel shape built in code, queued for export. |
None
|
blockbench
|
str
|
The Blockbench model whose bounding boxes build the shape, the same shape |
None
|
collection
|
str
|
The collection of the Blockbench model to build the shape from. |
None
|
Give either voxel_shape or blockbench.
BlockEnchantmentPowerTransmitter
Bases: JsonValueComponent
[EXPERIMENTAL] Whether the block transmits enchantment power. When true and the block sits
in the 1 block gap between an enchanting table and a bookshelf, the table stays powered by
the bookshelf.
Experimental: needs features.experimental in anvilconfig.json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
bool
|
Whether the block transmits enchantment power. Defaults to True. |
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_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 {identifier: payload}.
BlockMinMaxBox
Bases: JsonObject
A box inside the block, in pixels, by its two corners. (0, 0, 0) is the bottom-left corner of the block and (16, 16, 16) the top-right.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
tuple[float, float, float]
|
The minimal corner. |
required |
max
|
tuple[float, float, float]
|
The maximal corner. |
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 |
required |
__validate__()
Cross-field checks, run on export after the fields are checked.
BlockNeighborChange
Bases: JsonComponent
[EXPERIMENTAL] Which neighbouring block changes trigger the neighbor change after event of
the block's custom components.
Experimental: needs features.experimental in anvilconfig.json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
neighbor_directions
|
list[all | up | down | north | south | west | east]
|
The directions to observe, 1 to 6 of them, no repeats. "all" must be used alone. |
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 component as {identifier: payload}.
__json_fields__()
classmethod
The compiled fields of this class, compiled on first use.
__payload_schema__(definitions)
classmethod
The schema of the payload under the identifier.
__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 {identifier: payload}.
BlockVibrationProperties
Bases: JsonComponent
[EXPERIMENTAL] How the block affects vibrations.
Experimental: needs features.experimental in anvilconfig.json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dampen_vibrations
|
bool
|
Whether the block dampens vibrations. The game defaults to False. |
required |
occlude_vibrations
|
bool
|
Whether the block occludes vibrations. The game defaults to False. |
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 component as {identifier: payload}.
__json_fields__()
classmethod
The compiled fields of this class, compiled on first use.
__payload_schema__(definitions)
classmethod
The schema of the payload under the identifier.
__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 {identifier: payload}.