only require block ids, should make bin size smaller and let the compiler better optimize, should also be faster performance wise
41 lines
1.1 KiB
Rust
41 lines
1.1 KiB
Rust
use pumpkin_data::Block;
|
|
use pumpkin_world::BlockStateId;
|
|
|
|
use crate::block::{
|
|
BlockBehaviour, BlockFuture, BlockMetadata, CanPlaceAtArgs, GetStateForNeighborUpdateArgs,
|
|
blocks::plant::PlantBlockBase,
|
|
};
|
|
|
|
pub struct ShortPlantBlock;
|
|
|
|
impl BlockMetadata for ShortPlantBlock {
|
|
fn ids() -> Box<[u16]> {
|
|
[Block::SHORT_GRASS.id, Block::FERN.id].into()
|
|
}
|
|
}
|
|
|
|
impl BlockBehaviour for ShortPlantBlock {
|
|
fn can_place_at<'a>(&'a self, args: CanPlaceAtArgs<'a>) -> BlockFuture<'a, bool> {
|
|
Box::pin(async move {
|
|
<Self as PlantBlockBase>::can_place_at(self, args.block_accessor, args.position).await
|
|
})
|
|
}
|
|
|
|
fn get_state_for_neighbor_update<'a>(
|
|
&'a self,
|
|
args: GetStateForNeighborUpdateArgs<'a>,
|
|
) -> BlockFuture<'a, BlockStateId> {
|
|
Box::pin(async move {
|
|
<Self as PlantBlockBase>::get_state_for_neighbor_update(
|
|
self,
|
|
args.world,
|
|
args.position,
|
|
args.state_id,
|
|
)
|
|
.await
|
|
})
|
|
}
|
|
}
|
|
|
|
impl PlantBlockBase for ShortPlantBlock {}
|