From 7341a06dbf8adb954fdf6b56539aa576aec0b8f8 Mon Sep 17 00:00:00 2001 From: mat Date: Thu, 9 Feb 2023 20:38:25 -0600 Subject: [PATCH] ok i think i'm gonna leave the block examples like this --- azalea-block/README.md | 48 ++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 25 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,30 +1,11 @@ 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::::from(block_state); -``` - -## 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`. -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 = azalea_registry::Block::Jukebox.into(); -if let Some(jukebox) = Box::::from(block_state).downcast_ref::() { - // ... -} -``` ``` # use azalea_block::BlockState; let block_state: BlockState = azalea_block::CobblestoneWallBlock { @@ -37,14 +18,31 @@ let block_state: BlockState = azalea_block::CobblestoneWallBlock { } .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`. +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::::from(block_state); +``` +``` +# use azalea_block::{Block, BlockState}; +# let block_state: BlockState = azalea_registry::Block::Jukebox.into(); +if let Some(jukebox) = Box::::from(block_state).downcast_ref::() { + // ... +} +``` ## 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(); -``` -