diff options
| author | mat <github@matdoes.dev> | 2023-02-09 20:38:25 -0600 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2023-02-09 20:38:25 -0600 |
| commit | 7341a06dbf8adb954fdf6b56539aa576aec0b8f8 (patch) | |
| tree | ede8f33f194bb59daa8e91eb802532261f21d584 | |
| parent | 2fc768612e04e70c77af013285da13e84b2d5cb0 (diff) | |
| download | azalea-drasl-7341a06dbf8adb954fdf6b56539aa576aec0b8f8.tar.xz | |
ok i think i'm gonna leave the block examples like this
| -rwxr-xr-x | azalea-block/README.md | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/azalea-block/README.md b/azalea-block/README.md index d5eb1bde..e4b6357b 100755 --- a/azalea-block/README.md +++ b/azalea-block/README.md @@ -1,16 +1,26 @@ Representation of Minecraft block states. -There's three block types, used for different things. You can (mostly) freely convert between them with `.into()`. +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::{Block, BlockState}; -# let block_state = BlockState::from(azalea_registry::Block::Jukebox); -let block = Box::<dyn Block>::from(block_state); +# use azalea_block::BlockState; +let block_state: BlockState = azalea_block::CobblestoneWallBlock { + east: azalea_block::EastWall::Low, + north: azalea_block::NorthWall::Low, + south: azalea_block::SouthWall::Low, + west: azalea_block::WestWall::Low, + up: false, + waterlogged: false, +} +.into(); +``` +``` +# use azalea_block::BlockState; +let block_state: BlockState = azalea_registry::Block::Jukebox.into(); ``` ## Block trait @@ -20,31 +30,19 @@ If for some reason you don't want the `Block` trait, set default-features to fal ``` # 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::JukeboxBlock>() { // ... } ``` -``` -# use azalea_block::BlockState; -let block_state: BlockState = azalea_block::CobblestoneWallBlock { - east: azalea_block::EastWall::Low, - north: azalea_block::NorthWall::Low, - south: azalea_block::SouthWall::Low, - west: azalea_block::WestWall::Low, - up: false, - waterlogged: false, -} -.into(); -``` ## 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. -``` -# use azalea_block::BlockState; -let block_state: BlockState = azalea_registry::Block::Jukebox.into(); -``` - |
