pub trait BlockTrait: Debug + Any {
// Required methods
fn behavior(&self) -> BlockBehavior;
fn id(&self) -> &'static str;
fn as_block_state(&self) -> BlockState;
fn as_registry_block(&self) -> Block;
fn property_map(&self) -> HashMap<&'static str, &'static str>;
fn get_property(&self, name: &str) -> Option<&'static str>;
}
Required Methods§
fn behavior(&self) -> BlockBehavior
Sourcefn id(&self) -> &'static str
fn id(&self) -> &'static str
Get the Minecraft string ID for this block.
For example, stone
or grass_block
.
Sourcefn as_block_state(&self) -> BlockState
fn as_block_state(&self) -> BlockState
Convert the block to a block state.
This is a lossless conversion, as BlockState
also contains state
data.
Sourcefn as_registry_block(&self) -> Block
fn as_registry_block(&self) -> Block
Convert the block to an azalea_registry::Block
.
This is a lossy conversion, as azalea_registry::Block
doesn’t
contain any state data.
Sourcefn property_map(&self) -> HashMap<&'static str, &'static str>
fn property_map(&self) -> HashMap<&'static str, &'static str>
Returns a map of property names on this block to their values as strings.
Consider using Self::get_property
if you only need a single
property.
Sourcefn get_property(&self, name: &str) -> Option<&'static str>
fn get_property(&self, name: &str) -> Option<&'static str>
Get a property’s value as a string by its name, or None
if the block
has no property with that name.
To get all properties, you may use Self::property_map
.
Implementations§
Source§impl dyn BlockTrait
impl dyn BlockTrait
pub fn downcast_ref<T: BlockTrait>(&self) -> Option<&T>
Trait Implementations§
Source§impl From<BlockState> for Box<dyn BlockTrait>
impl From<BlockState> for Box<dyn BlockTrait>
Source§fn from(block_state: BlockState) -> Self
fn from(block_state: BlockState) -> Self
Converts to this type from the input type.