Make Lily Pads break when colliding with a boat
Boats are currently not even implemented lol
This commit is contained in:
parent
6f986339e8
commit
30f1a88126
34
pumpkin/src/block/blocks/lily_pad.rs
Normal file
34
pumpkin/src/block/blocks/lily_pad.rs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use async_trait::async_trait;
|
||||||
|
use pumpkin_data::{Block, BlockState};
|
||||||
|
use pumpkin_macros::pumpkin_block;
|
||||||
|
use pumpkin_util::math::position::BlockPos;
|
||||||
|
use pumpkin_world::world::BlockFlags;
|
||||||
|
|
||||||
|
use crate::{block::pumpkin_block::PumpkinBlock, entity::EntityBase, world::World};
|
||||||
|
|
||||||
|
#[pumpkin_block("minecraft:lily_pad")]
|
||||||
|
pub struct LilyPadBlock;
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl PumpkinBlock for LilyPadBlock {
|
||||||
|
async fn on_entity_collision(
|
||||||
|
&self,
|
||||||
|
world: &Arc<World>,
|
||||||
|
entity: &dyn EntityBase,
|
||||||
|
pos: BlockPos,
|
||||||
|
_block: Block,
|
||||||
|
_state: BlockState,
|
||||||
|
) {
|
||||||
|
// Proberbly not the best soultion, but works
|
||||||
|
if entity
|
||||||
|
.get_entity()
|
||||||
|
.entity_type
|
||||||
|
.resource_name
|
||||||
|
.ends_with("_boat")
|
||||||
|
{
|
||||||
|
world.break_block(&pos, None, BlockFlags::empty()).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -13,6 +13,7 @@ pub mod furnace;
|
|||||||
pub mod glass_panes;
|
pub mod glass_panes;
|
||||||
pub mod iron_bars;
|
pub mod iron_bars;
|
||||||
pub mod jukebox;
|
pub mod jukebox;
|
||||||
|
pub mod lily_pad;
|
||||||
pub mod logs;
|
pub mod logs;
|
||||||
pub mod nether_portal;
|
pub mod nether_portal;
|
||||||
pub mod note;
|
pub mod note;
|
||||||
|
|||||||
@ -10,6 +10,7 @@ use blocks::fire::fire::FireBlock;
|
|||||||
use blocks::fire::soul_fire::SoulFireBlock;
|
use blocks::fire::soul_fire::SoulFireBlock;
|
||||||
use blocks::glass_panes::GlassPaneBlock;
|
use blocks::glass_panes::GlassPaneBlock;
|
||||||
use blocks::iron_bars::IronBarsBlock;
|
use blocks::iron_bars::IronBarsBlock;
|
||||||
|
use blocks::lily_pad::LilyPadBlock;
|
||||||
use blocks::logs::LogBlock;
|
use blocks::logs::LogBlock;
|
||||||
use blocks::nether_portal::NetherPortalBlock;
|
use blocks::nether_portal::NetherPortalBlock;
|
||||||
use blocks::note::NoteBlock;
|
use blocks::note::NoteBlock;
|
||||||
@ -90,6 +91,7 @@ pub fn default_registry() -> Arc<BlockRegistry> {
|
|||||||
manager.register(SignBlock);
|
manager.register(SignBlock);
|
||||||
manager.register(SlabBlock);
|
manager.register(SlabBlock);
|
||||||
manager.register(StairBlock);
|
manager.register(StairBlock);
|
||||||
|
manager.register(LilyPadBlock);
|
||||||
manager.register(SugarCaneBlock);
|
manager.register(SugarCaneBlock);
|
||||||
manager.register(TNTBlock);
|
manager.register(TNTBlock);
|
||||||
manager.register(TorchBlock);
|
manager.register(TorchBlock);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user