Blocks - Components Module
anvil.api.blocks.components
BlockCollisionBox
Bases: _BaseComponent
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. |
__init__(size, origin)
Defines the area of the block that collides with entities.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size
|
list[float]
|
The size of the collision box. |
required |
origin
|
list[float]
|
The origin of the collision box. |
required |
__iter__()
Iterates over the component's fields.
BlockCraftingTable
Bases: _BaseComponent
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. |
__init__(table_name, *crafting_tags)
Makes your block into a custom crafting table which enables the crafting table UI and the ability to craft recipes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table_name
|
str
|
The name of the crafting table. |
required |
Raises:
Type | Description |
---|---|
IndexError
|
The crafting table tags cannot exceed 64 tags. |
ValueError
|
The crafting table tags are limited to 64 characters. |
__iter__()
Iterates over the component's fields.
BlockCustomComponents
Bases: _BaseComponent
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. |
__init__(component_name)
Allows you to add custom components to a block by specifying the components in a comma-separated list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
components
|
str
|
The components to register, if the namespace is not provided, the project namespace will be used. |
required |
__iter__()
Iterates over the component's fields.
BlockDefault
Bases: _BaseComponent
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. |
__init__()
The default block component.
__iter__()
Iterates over the component's fields.
ambient_occlusion_exponent(exponent)
The exponent for ambient occlusion of the block.
carried_textures(**kwParameters)
The carried textures of the block.
isotropic(**kwParameters)
The isotropic of the block.
sound(sound)
The sound of the block.
textures(**kwParameters)
The textures of the block.
BlockDestructibleByExplosion
Bases: _BaseComponent
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. |
__init__(explosion_resistance=None)
Describes the destructible by explosion properties for this block.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
explosion_resistance
|
int
|
The amount of resistance to explosions in a range of 0 to 100. |
None
|
__iter__()
Iterates over the component's fields.
BlockDestructibleByMining
Bases: _BaseComponent
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. |
__init__(seconds_to_destroy=None)
Describes the destructible by mining properties for this block.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seconds_to_destroy
|
int
|
The amount of time it takes to destroy the block in seconds. If None, disables mining destructibility. |
None
|
__iter__()
Iterates over the component's fields.
BlockDestructionParticles
Bases: _BaseComponent
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. |
__init__(blockbench_name, texture=None, tint_method=TintMethod.None_)
Sets the particles that will be used when the block is destroyed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
blockbench_name
|
str
|
The name of the blockbench model. |
required |
texture
|
str
|
The texture name used for the particle. |
None
|
tint_method
|
TintMethod
|
Tint multiplied to the color. Defaults to TintMethod.None_. |
None_
|
__iter__()
Iterates over the component's fields.
BlockDisplayName
Bases: _BaseComponent
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. |
__init__(display_name, localize=True)
Sets the block display name within Minecraft: Bedrock Edition. This component may also be used to pull from the localization file by referencing a key from it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
display_name
|
str
|
Set the display name for an block. |
required |
localize
|
bool
|
Whether to use the name with a localization file or not. Defaults to True. |
True
|
__iter__()
Iterates over the component's fields.
BlockFlammable
Bases: _BaseComponent
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. |
__init__(catch_chance_modifier, destroy_chance_modifier)
Describes the flammable properties for this block.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
catch_chance_modifier
|
int
|
The chance that this block will catch fire in a range of 0 to 100. |
required |
destroy_chance_modifier
|
int
|
The chance that this block will be destroyed when on fire in a range of 0 to 100. |
required |
__iter__()
Iterates over the component's fields.
BlockFriction
Bases: _BaseComponent
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. |
__init__(friction=0.4)
Describes the friction for this block in a range of 0.0 to 0.9.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
friction
|
float
|
The friction of the block. Defaults to 0.4. |
0.4
|
__iter__()
Iterates over the component's fields.
BlockGeometry
Bases: _BaseComponent
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. |
__init__(geometry_name, uv_lock=False)
The description identifier of the geometry file to use to render this block.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
geometry_name
|
str
|
The name of the geometry to use to render this block. |
required |
uv_lock
|
bool
|
A Boolean locking UV orientation of all bones in the geometry, or an array of strings locking UV orientation of specific bones in the geometry. For performance reasons it is recommended to use the Boolean. Note that for cubes using Box UVs, rather than Per-face UVs, 'uv_lock' is only supported if the cube faces are square. |
False
|
__iter__()
Iterates over the component's fields.
bone_visibility(**bone)
Specifies the visibility of bones in the geometry file.
Example
BlockGeometry('block').bone_visibility(bone0=True, bone1=False)
BlockItemVisual
Bases: _BaseComponent
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. |
__init__(geometry_name, texture, render_method=BlockMaterial.Opaque)
The description identifier of the geometry and material used to render the item of this block.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
geometry
|
str
|
The geometry of the item. |
required |
texture
|
str
|
The texture of the item. |
required |
render_method
|
BlockMaterial
|
The method used to render the item. |
Opaque
|
__iter__()
Iterates over the component's fields.
BlockLightDampening
Bases: _BaseComponent
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. |
__init__(light_dampening=15)
The amount that light will be dampened when it passes through the block in a range of 0 to 15.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
light_dampening
|
int
|
The amount of light dampening. Defaults to 15. |
15
|
__iter__()
Iterates over the component's fields.
BlockLightEmission
Bases: _BaseComponent
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. |
__init__(light_emission=0)
The amount of light this block will emit in a range of 0 to 15.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
light_emission
|
int
|
The amount of light emission. Defaults to 0. |
0
|
__iter__()
Iterates over the component's fields.
BlockLiquidDetection
Bases: _BaseComponent
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. |
__init__()
The block's liquid detection.
__iter__()
Iterates over the component's fields.
add_rule(liquid_type='minecraft:water', on_liquid_touches=BlockLiquidDetectionTouching.Blocking, can_contain_liquid=False, stops_liquid_flowing_from_direction=[])
Adds a rule to the liquid detection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
liquid_type
|
str
|
The type of liquid, defaults to "minecraft:water". |
'minecraft:water'
|
on_liquid_touches
|
BlockLiquidDetectionTouching
|
The action to take when the liquid touches the block. |
Blocking
|
can_contain_liquid
|
bool
|
Whether the block can contain the liquid. Defaults to False. |
False
|
BlockLootTable
Bases: _BaseComponent
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. |
__init__(loot)
Specifies the path to the loot table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
loot
|
str
|
The path to the loot table. |
required |
__iter__()
Iterates over the component's fields.
BlockMapColor
Bases: _BaseComponent
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. |
__init__(color, tint_method=TintMethod.None_)
Sets the color of the block when rendered to a map. If this component is omitted, the block will not show up on the map.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
color
|
str
|
The color is represented as a hex value in the format "#RRGGBB". May also be expressed as an array of [R, G, B] from 0 to 255. |
required |
tint_method
|
str
|
Optional, tint multiplied to the color. Tint method logic varies, but often refers to the "rain" and "temperature" of the biome the block is placed in to compute the tint. Defaults to None. |
None_
|
__iter__()
Iterates over the component's fields.
BlockMaterialInstance
Bases: _BaseComponent
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. |
__init__()
Maps face or material_instance names in a geometry file to an actual material instance.
__iter__()
Iterates over the component's fields.
add_instance(blockbench_name, color_texture, block_face=BlockFaces.All, render_method=BlockMaterial.Opaque, ambient_occlusion=0, face_dimming=True, isotropic=False, tint_method=TintMethod.None_, normal_texture=None, heightmap_texture=None, metalness_emissive_roughness_texture=None, metalness_emissive_roughness_subsurface_texture=None)
Maps face or material_instance names in a geometry file to an actual material instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
color_texture
|
str
|
The name of the texture to use for this block. |
required |
block_face
|
BlockFaces
|
The face of the block to apply the texture to. Defaults to BlockFaces.All. |
All
|
render_method
|
BlockMaterial
|
The render method to use for this block. Defaults to BlockMaterial.Opaque. |
Opaque
|
ambient_occlusion
|
float
|
The amount of ambient occlusion for this block. Defaults to 0. |
0
|
face_dimming
|
bool
|
Whether or not to use face dimming for this block. Defaults to True. |
True
|
tint_method
|
TintMethod
|
The tint method to use for this block. Defaults to TintMethod.None_. |
None_
|
BlockMovable
Bases: _BaseComponent
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. |
__init__(movement_type=BlockMovementType.PushPull, sticky='none')
The description identifier of the movable component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
movement_type
|
BlockMovementType
|
How the block reacts to being pushed by another block like a piston. Defaults to BlockMovementType.PushPull. |
PushPull
|
sticky
|
str
|
How the block should handle adjacent blocks around it when being pushed by another block like a piston. Defaults to "none". |
'none'
|
__iter__()
Iterates over the component's fields.
BlockPlacementFilter
Bases: _BaseComponent
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. |
__init__()
By default, custom blocks can be placed anywhere and do not have placement restrictions unless you specify them in this component.
__iter__()
Iterates over the component's fields.
add_condition(allowed_faces, block_filter)
Adds a condition to the placement filter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
allowed_faces
|
list[BlockFaces]
|
The faces of the block that are allowed to be placed on. |
required |
block_filter
|
list[BlockDescriptor | str]
|
The blocks that are allowed to be placed on. |
required |
BlockRedstoneConductivity
Bases: _BaseComponent
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. |
__init__(allows_wire_to_step_down=True, redstone_conductor=False)
Specifies whether a block has redstone properties. If the component is not provided, the default values are used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
allows_wire_to_step_down
|
bool
|
Specifies if redstone wire can stair-step downward on the block, Defaults to True. |
True
|
redstone_conductor
|
bool
|
Specifies if the block can be powered by redstone, Defaults to False. |
False
|
__iter__()
Iterates over the component's fields.
BlockSelectionBox
Bases: _BaseComponent
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. |
__init__(size, origin)
Defines the area of the block that is selected by the player's cursor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size
|
list[float]
|
The size of the selection box. |
required |
origin
|
list[float]
|
The origin of the selection box. |
required |
__iter__()
Iterates over the component's fields.
BlockTick
Bases: _BaseComponent
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. |
__init__(interval_range=(0, 0), looping=True)
Causes the block to tick at intervals randomly chosen from interval_range.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interval_range
|
tuple[int, int]
|
[min, max] ticks before next tick. Defaults to (0, 0). |
(0, 0)
|
looping
|
bool
|
If True, block will continue ticking; otherwise it ticks only once. Defaults to True. |
True
|
__iter__()
Iterates over the component's fields.
BlockTransformation
Bases: _BaseComponent
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. |
__init__()
The block's transfomration.
__iter__()
Iterates over the component's fields.
rotation(rotation, rotation_pivot=(0, 0, 0))
The block's rotation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rotation
|
position
|
The block's rotation. |
required |
scale(scale, scale_pivot=(0, 0, 0))
The block's scale.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scale
|
position
|
The block's scale. |
required |
translation(translation)
The block's translation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
translation
|
position
|
The block's translation. |
required |