Blocks
src.anvil.api.blocks
Block
Server
property
The block server object.
identifier
property
The block identifier.
__init__(name, is_vanilla=False)
The block object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the block. |
required |
is_vanilla
|
bool
|
Whether or not the block is a vanilla block. Defaults to False. |
False
|
queue()
Queues the block to be exported.
BlockCollisionBox
Bases: _component
__init__(size, origin)
Defines the area of the block that collides with entities.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size
|
coordinates
|
The size of the collision box. |
required |
origin
|
coordinates
|
The origin of the collision box. |
required |
BlockCraftingTable
Bases: _component
__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. |
BlockCustomComponents
Bases: _component
__init__(*components)
Sets the color of the block when rendered to a map.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
components
|
str
|
The components to register, if the namespace is not provided, the project namespace will be used. |
()
|
BlockDefault
Bases: _component
__init__()
The default block component.
brightness_gamma(gamma)
The gamma of the block's brightness.
carried_textures(**kwargs)
The carried textures of the block.
isotropic(**kwargs)
The isotropic of the block.
sound(sound)
The sound of the block.
textures(**kwargs)
The textures of the block.
BlockDescriptor
Bases: dict
A class that inherits from Python's built-in dict class. It is used to create a descriptor for a block in Minecraft with its name, tags, and states.
__init__(name, tags, **states)
Initializes a BlockDescriptor object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the block. |
required |
tags
|
Molang
|
The tags of the block. |
required |
**states
|
The states of the block. |
{}
|
BlockDestructibleByExplosion
Bases: _component
__init__(explosion_resistance)
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. |
required |
BlockDestructibleByMining
Bases: _component
__init__(seconds_to_destroy)
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. |
required |
BlockDisplayName
Bases: _component
__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
|
BlockFlammable
Bases: _component
__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 |
BlockFriction
Bases: _component
__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
|
BlockGeometry
Bases: _component
__init__(geometry_name)
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 |
bone_visibility(**bone)
Specifies the visibility of bones in the geometry file.
Example
BlockGeometry('block').bone_visibility(bone0=True, bone1=False)
BlockLightDampening
Bases: _component
__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
|
BlockLightEmission
Bases: _component
__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
|
BlockLootTable
Bases: _component
__init__(loot)
Specifies the path to the loot table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
loot
|
str
|
The path to the loot table. |
required |
BlockMapColor
Bases: _component
__init__(map_color)
Sets the color of the block when rendered to a map.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
map_color
|
str
|
The color of the block when rendered to a map, must be a hexadecimal color value. |
required |
BlockMaterialInstance
Bases: _component
__init__()
Maps face or material_instance names in a geometry file to an actual material instance.
add_instance(blockbench_name, texture_name, block_face=BlockFaces.All, render_method=BlockMaterial.Opaque, ambient_occlusion=True, face_dimming=True)
Maps face or material_instance names in a geometry file to an actual material instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
texture_name
|
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
|
bool
|
Whether or not to use ambient occlusion for this block. Defaults to True. |
True
|
face_dimming
|
bool
|
Whether or not to use face dimming for this block. Defaults to True. |
True
|
BlockPlacementFilter
Bases: _component
__init__()
By default, custom blocks can be placed anywhere and do not have placement restrictions unless you specify them in this component.
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: _component
__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
|
BlockSelectionBox
Bases: _component
__init__(size, origin)
Defines the area of the block that is selected by the player's cursor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size
|
coordinates
|
The size of the selection box. |
required |
origin
|
coordinates
|
The origin of the selection box. |
required |
BlockTransformation
Bases: _component
__init__()
The block's transfomration.
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 |