20 releases (breaking)
Uses new Rust 2024
| 0.16.0+mc26.1 | Mar 28, 2026 |
|---|---|
| 0.15.0+mc1.21.11 | Dec 19, 2025 |
| 0.14.0+mc1.21.8 | Sep 28, 2025 |
| 0.13.0+mc1.21.5 | Jun 16, 2025 |
| 0.4.0 | Nov 19, 2022 |
#433 in Games
883 downloads per month
Used in 6 crates
1MB
24K
SLoC
azalea-block
Representation of Minecraft block states.
There are three block types, used for different things. You can (mostly) convert between them with .into().
BlockState struct
BlockState is a struct containing the numerical protocol ID of a block state. This is how blocks are stored in the world.
# use azalea_block::BlockState;
let block_state: BlockState = azalea_block::blocks::CobblestoneWall {
east: azalea_block::properties::WallEast::Low,
north: azalea_block::properties::WallNorth::Low,
south: azalea_block::properties::WallSouth::Low,
west: azalea_block::properties::WallWest::Low,
up: false,
waterlogged: false,
}
.into();
# use azalea_block::BlockState;
# use azalea_registry::builtin::BlockKind;
let block_state: BlockState = BlockKind::Jukebox.into();
BlockTrait
The BlockTrait trait represents a type of a block. With BlockTrait, you can get some extra things like the string block ID and some information about the block's behavior. Also, the structs that implement the trait contain the block attributes as fields so it's more convenient to get them. Note that this is often used as Box<dyn BlockTrait>.
If for some reason you don't want BlockTrait, set default-features = false.
# use azalea_block::{BlockTrait, BlockState};
# let block_state = BlockState::from(azalea_registry::builtin::BlockKind::Jukebox);
let block = Box::<dyn BlockTrait>::from(block_state);
# use azalea_block::{BlockTrait, BlockState};
# let block_state: BlockState = azalea_registry::builtin::BlockKind::Jukebox.into();
if let Some(jukebox) = Box::<dyn BlockTrait>::from(block_state).downcast_ref::<azalea_block::blocks::Jukebox>() {
// ...
}
azalea_registry::builtin::BlockKind
This one isn't from the azalea-block crate, but it's still very relevant. It's an enum that contains every block type as a variant without containing any state data (unlike BlockState and BlockTrait). Converting this into any other block type will use the default state for that block.
Dependencies
~6.5–9.5MB
~96K SLoC