* Use workspace `Cargo.toml` for dependencies and package atributes * Fix a couple clippy warnings * Update bevy, update build script, move deps to workspace, and fix clippy warnings * Remove carrots from crate versions The default behavior is the same * Remove unused dependencies Compiles and all tests pass, so it should be fine * Update codegen to use `std::sync::LazyLock` instead of `once_cell::sync::Lazy` * Update Bevy to `0.15.0-rc.3` Surprisingly little needed to be changed * Update to bevy 0.15.0 * Fix leftover merge issues * Clarify the reason the swarm can't connect * Fix duplicate lint, remove `log` dependency |
||
---|---|---|
.. | ||
azalea-block-macros | ||
src | ||
.gitignore | ||
Cargo.toml | ||
README.md |
Representation of Minecraft block states.
There's 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;
let block_state: BlockState = azalea_registry::Block::Jukebox.into();
Block trait
The [Block
] trait represents a type of a block. With the the [Block
] trait, 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 Block>
.
If for some reason you don't want the Block
trait, set default-features to false.
# use azalea_block::{Block, BlockState};
# let block_state = BlockState::from(azalea_registry::Block::Jukebox);
let block = Box::<dyn Block>::from(block_state);
# use azalea_block::{Block, BlockState};
# let block_state: BlockState = azalea_registry::Block::Jukebox.into();
if let Some(jukebox) = Box::<dyn Block>::from(block_state).downcast_ref::<azalea_block::blocks::Jukebox>() {
// ...
}
azalea_registry::Block enum
This one technically 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 the Block
trait). Converting this into any other block type will use the default state for that block.