mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-30 20:14:23 +00:00
Add Spore blossom block (#1735)
* feat: spore blossom block * chore: make requested changes * chore: rename block var to ceiling_block
This commit is contained in:
@@ -21,6 +21,7 @@ pub mod sea_grass;
|
||||
pub mod sea_pickles;
|
||||
pub mod segmented;
|
||||
pub mod short_plant;
|
||||
pub mod spore_blossom;
|
||||
pub mod sugar_cane;
|
||||
pub mod tall_plant;
|
||||
pub mod wither_rose;
|
||||
|
||||
49
pumpkin/src/block/blocks/plant/spore_blossom.rs
Normal file
49
pumpkin/src/block/blocks/plant/spore_blossom.rs
Normal file
@@ -0,0 +1,49 @@
|
||||
use crate::block::{BlockBehaviour, BlockFuture, CanPlaceAtArgs};
|
||||
use crate::block::{GetStateForNeighborUpdateArgs, blocks::plant::PlantBlockBase};
|
||||
use pumpkin_data::tag::Taggable;
|
||||
use pumpkin_data::{Block, tag};
|
||||
use pumpkin_macros::pumpkin_block;
|
||||
use pumpkin_util::math::position::BlockPos;
|
||||
use pumpkin_world::BlockStateId;
|
||||
use pumpkin_world::world::BlockAccessor;
|
||||
|
||||
#[pumpkin_block("minecraft:spore_blossom")]
|
||||
pub struct SporeBlossomBlock;
|
||||
|
||||
impl BlockBehaviour for SporeBlossomBlock {
|
||||
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 SporeBlossomBlock {
|
||||
async fn can_plant_on_top(
|
||||
&self,
|
||||
_block_accessor: &dyn pumpkin_world::world::BlockAccessor,
|
||||
_pos: &pumpkin_util::math::position::BlockPos,
|
||||
) -> bool {
|
||||
false
|
||||
}
|
||||
async fn can_place_at(&self, block_accessor: &dyn BlockAccessor, block_pos: &BlockPos) -> bool {
|
||||
let ceiling_block = block_accessor.get_block(&block_pos.up()).await;
|
||||
supports_spore_blossom(ceiling_block)
|
||||
}
|
||||
}
|
||||
fn supports_spore_blossom(block: &Block) -> bool {
|
||||
!block.has_tag(&tag::Block::MINECRAFT_LEAVES) && block.is_solid()
|
||||
}
|
||||
@@ -64,6 +64,7 @@ use crate::block::blocks::plant::sapling::SaplingBlock;
|
||||
use crate::block::blocks::plant::sea_grass::SeaGrassBlock;
|
||||
use crate::block::blocks::plant::sea_pickles::SeaPickleBlock;
|
||||
use crate::block::blocks::plant::short_plant::ShortPlantBlock;
|
||||
use crate::block::blocks::plant::spore_blossom::SporeBlossomBlock;
|
||||
use crate::block::blocks::plant::sugar_cane::SugarCaneBlock;
|
||||
use crate::block::blocks::plant::tall_plant::TallPlantBlock;
|
||||
use crate::block::blocks::plant::wither_rose::WitherRose;
|
||||
@@ -256,6 +257,7 @@ pub fn default_registry() -> Arc<BlockRegistry> {
|
||||
manager.register(CobwebBlock);
|
||||
manager.register(WitherRose);
|
||||
manager.register(Fungus);
|
||||
manager.register(SporeBlossomBlock);
|
||||
|
||||
manager.register(FallingBlock);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user