Overview
Blocks are the building blocks of the Minecraft world. Minestom provides a powerful API for manipulating blocks, registering custom handlers, and controlling placement rules.Block Class
Immutable representation of a block with properties, NBT data, and optional handler.Getting Blocks
Gets a block by its namespaced key.Parameters:
key- The block key (e.g., “minecraft:stone”)
Parses a block from a state string.Parameters:
state- Block state string (e.g., “minecraft:oak_stairs[facing=north,half=top]”)
Gets a block from its state ID.Parameters:
stateId- The block state ID
Gets a block from its base ID.Parameters:
blockId- The block ID
Gets all registered blocks.Returns: Collection of all blocks
Block Properties
Creates a new block with a property changed.Parameters:
property- Property namevalue- Property value
Changes multiple properties at once.Parameters:
properties- Map of property names to values
Gets a property value.Parameters:
property- Property name
Gets all properties.Returns: Unmodifiable map of properties
Gets all possible states for this block type.Returns: Collection of block states
Gets the default state with no properties or handlers.Returns: The default Block
NBT Data
Creates a new block with NBT data.Parameters:
compound- The NBT compound (null to remove)
Creates a block with a tag modified.Parameters:
tag- The tag to modifyvalue- The tag value (null to remove)
Gets the block NBT data.Returns: The NBT compound, or null if none
Checks if the block has NBT data.Returns: true if NBT is present
Block Handlers
Creates a block with a handler attached.Parameters:
handler- The block handler (null to remove)
Gets the block handler.Returns: The BlockHandler, or null if not present
Block Information
Gets the block namespaced key.Returns: The Key (e.g., “minecraft:stone”)
Gets the block ID.Returns: The block ID
Gets the state ID (unique for each property combination).Returns: The state ID
Gets the block state as a string.Returns: State string (e.g., “minecraft:oak_stairs[facing=north]”)
Checks if the block is air.Returns: true if air
Checks if the block is solid.Returns: true if solid
Checks if the block is a liquid.Returns: true if liquid
Compares two blocks.Parameters:
block- Block to compare tocomparator- Comparison mode (IDENTITY, ID, STATE)
Gets the block registry data.Returns: The registry entry with collision shape, etc.
BlockManager
Manages block handlers and placement rules.Handler Registration
Registers a block handler by namespace.Parameters:
namespace- The block namespace (e.g., “custom:my_block”)handlerSupplier- Supplier that creates handler instances
Registers a handler using a Key.Parameters:
key- The block keyhandlerSupplier- Handler supplier
Gets a handler by namespace.Parameters:
namespace- The block namespace
Placement Rules
Registers a placement rule for a block.Parameters:
blockPlacementRule- The placement rule
Gets the placement rule for a block.Parameters:
block- The block
BlockHandler Interface
Defines custom behavior for blocks. All methods are optional.Lifecycle Events
Called when the block is placed.Parameters:
placement- Details about the placement
Called when the block is destroyed or replaced.Parameters:
destroy- Details about the destruction
Interaction
Handles player interaction with the block.Parameters:
interaction- Interaction details
Called when an entity touches the block.Parameters:
touch- Touch details
Ticking
Called every tick if isTickable() returns true.Parameters:
tick- Tick details
Determines if this handler should receive tick updates.Returns: true to receive ticks
Block Entity
Gets the handler key (required for block entities).Returns: The handler namespace key
Specifies which tags should be sent to clients.Returns: Collection of tags to sync
Block.Getter Interface
Interface for retrieving blocks (implemented by Instance).Gets a block at coordinates.Parameters:
x,y,z- Block coordinates
Gets a block at a point.Parameters:
point- The position
Gets a block with a retrieval hint.Parameters:
x,y,z- Coordinatescondition- Retrieval condition (NONE, CACHED, TYPE)
Block.Setter Interface
Interface for placing blocks (implemented by Instance, Batch).Sets a block at coordinates.Parameters:
x,y,z- Block coordinatesblock- The block to place
Sets a block at a point.Parameters:
blockPosition- The positionblock- The block to place
Examples
Blocks are immutable. Methods like
withProperty() and withNbt() return new Block instances rather than modifying the existing one.