This commit is contained in:
parent
13ef8de2dc
commit
fd8d89a219
@ -181,7 +181,7 @@ pub fn pumpkin_block(input: TokenStream, item: TokenStream) -> TokenStream {
|
|||||||
|
|
||||||
let code = quote! {
|
let code = quote! {
|
||||||
#item
|
#item
|
||||||
impl #impl_generics crate::block::pumpkin_block::BlockMetadata for #name #ty_generics {
|
impl #impl_generics crate::block::BlockMetadata for #name #ty_generics {
|
||||||
fn namespace(&self) -> &'static str {
|
fn namespace(&self) -> &'static str {
|
||||||
#namespace
|
#namespace
|
||||||
}
|
}
|
||||||
@ -210,7 +210,7 @@ pub fn pumpkin_block_from_tag(input: TokenStream, item: TokenStream) -> TokenStr
|
|||||||
|
|
||||||
let code = quote! {
|
let code = quote! {
|
||||||
#item
|
#item
|
||||||
impl #impl_generics crate::block::pumpkin_block::BlockMetadata for #name #ty_generics {
|
impl #impl_generics crate::block::BlockMetadata for #name #ty_generics {
|
||||||
fn namespace(&self) -> &'static str {
|
fn namespace(&self) -> &'static str {
|
||||||
#namespace
|
#namespace
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ use pumpkin_data::{
|
|||||||
use pumpkin_util::math::position::BlockPos;
|
use pumpkin_util::math::position::BlockPos;
|
||||||
use pumpkin_world::{BlockStateId, world::BlockAccessor};
|
use pumpkin_world::{BlockStateId, world::BlockAccessor};
|
||||||
|
|
||||||
use crate::{block::pumpkin_block::GetStateForNeighborUpdateArgs, entity::player::Player};
|
use crate::{block::GetStateForNeighborUpdateArgs, entity::player::Player};
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait WallMountedBlock {
|
pub trait WallMountedBlock {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use crate::block::pumpkin_block::{OnPlaceArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, OnPlaceArgs};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::block_properties::{BlockProperties, WallTorchLikeProperties};
|
use pumpkin_data::block_properties::{BlockProperties, WallTorchLikeProperties};
|
||||||
use pumpkin_data::tag::{RegistryKey, get_tag_values};
|
use pumpkin_data::tag::{RegistryKey, get_tag_values};
|
||||||
@ -9,7 +9,7 @@ use pumpkin_world::BlockStateId;
|
|||||||
pub struct AnvilBlock;
|
pub struct AnvilBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for AnvilBlock {
|
impl BlockBehaviour for AnvilBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let dir = args
|
let dir = args
|
||||||
.player
|
.player
|
||||||
|
|||||||
@ -3,13 +3,13 @@ use pumpkin_data::tag;
|
|||||||
use pumpkin_data::tag::Taggable;
|
use pumpkin_data::tag::Taggable;
|
||||||
use pumpkin_macros::pumpkin_block;
|
use pumpkin_macros::pumpkin_block;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{CanPlaceAtArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, CanPlaceAtArgs};
|
||||||
|
|
||||||
#[pumpkin_block("minecraft:bamboo")]
|
#[pumpkin_block("minecraft:bamboo")]
|
||||||
pub struct BambooBlock;
|
pub struct BambooBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for BambooBlock {
|
impl BlockBehaviour for BambooBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
let block_below = args.block_accessor.get_block(&args.position.down()).await;
|
let block_below = args.block_accessor.get_block(&args.position.down()).await;
|
||||||
block_below.is_tagged_with_by_tag(&tag::Block::MINECRAFT_BAMBOO_PLANTABLE_ON)
|
block_below.is_tagged_with_by_tag(&tag::Block::MINECRAFT_BAMBOO_PLANTABLE_ON)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use crate::block::pumpkin_block::{OnPlaceArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, OnPlaceArgs};
|
||||||
use crate::entity::EntityBase;
|
use crate::entity::EntityBase;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::block_properties::{BlockProperties, WhiteBannerLikeProperties};
|
use pumpkin_data::block_properties::{BlockProperties, WhiteBannerLikeProperties};
|
||||||
@ -10,7 +10,7 @@ use pumpkin_world::BlockStateId;
|
|||||||
pub struct BannerBlock;
|
pub struct BannerBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for BannerBlock {
|
impl BlockBehaviour for BannerBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut props = WhiteBannerLikeProperties::default(args.block);
|
let mut props = WhiteBannerLikeProperties::default(args.block);
|
||||||
props.rotation = args.player.get_entity().get_flipped_rotation_16();
|
props.rotation = args.player.get_entity().get_flipped_rotation_16();
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{OnPlaceArgs, PlacedArgs};
|
use crate::block::{OnPlaceArgs, PlacedArgs};
|
||||||
use crate::block::{
|
use crate::block::{
|
||||||
pumpkin_block::{NormalUseArgs, PumpkinBlock},
|
|
||||||
registry::BlockActionResult,
|
registry::BlockActionResult,
|
||||||
|
{BlockBehaviour, NormalUseArgs},
|
||||||
};
|
};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::block_properties::{BarrelLikeProperties, BlockProperties};
|
use pumpkin_data::block_properties::{BarrelLikeProperties, BlockProperties};
|
||||||
@ -43,7 +43,7 @@ impl ScreenHandlerFactory for BarrelScreenFactory {
|
|||||||
pub struct BarrelBlock;
|
pub struct BarrelBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for BarrelBlock {
|
impl BlockBehaviour for BarrelBlock {
|
||||||
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
||||||
if let Some(block_entity) = args.world.get_block_entity(args.position).await {
|
if let Some(block_entity) = args.world.get_block_entity(args.position).await {
|
||||||
if let Some(inventory) = block_entity.get_inventory() {
|
if let Some(inventory) = block_entity.get_inventory() {
|
||||||
|
|||||||
@ -15,10 +15,10 @@ use pumpkin_world::BlockStateId;
|
|||||||
use pumpkin_world::block::entities::bed::BedBlockEntity;
|
use pumpkin_world::block::entities::bed::BedBlockEntity;
|
||||||
use pumpkin_world::world::BlockFlags;
|
use pumpkin_world::world::BlockFlags;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{
|
|
||||||
BrokenArgs, CanPlaceAtArgs, NormalUseArgs, OnPlaceArgs, PlacedArgs, PumpkinBlock,
|
|
||||||
};
|
|
||||||
use crate::block::registry::BlockActionResult;
|
use crate::block::registry::BlockActionResult;
|
||||||
|
use crate::block::{
|
||||||
|
BlockBehaviour, BrokenArgs, CanPlaceAtArgs, NormalUseArgs, OnPlaceArgs, PlacedArgs,
|
||||||
|
};
|
||||||
use crate::entity::{Entity, EntityBase};
|
use crate::entity::{Entity, EntityBase};
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ const NO_SLEEP_IDS: &[u16] = &[
|
|||||||
pub struct BedBlock;
|
pub struct BedBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for BedBlock {
|
impl BlockBehaviour for BedBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
if let Some(player) = args.player {
|
if let Some(player) = args.player {
|
||||||
let facing = player.living_entity.entity.get_horizontal_facing();
|
let facing = player.living_entity.entity.get_horizontal_facing();
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use crate::block::pumpkin_block::{OnPlaceArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, OnPlaceArgs};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::block_properties::{BlockProperties, FurnaceLikeProperties};
|
use pumpkin_data::block_properties::{BlockProperties, FurnaceLikeProperties};
|
||||||
use pumpkin_macros::pumpkin_block;
|
use pumpkin_macros::pumpkin_block;
|
||||||
@ -8,7 +8,7 @@ use pumpkin_world::BlockStateId;
|
|||||||
pub struct BlastFurnaceBlock;
|
pub struct BlastFurnaceBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for BlastFurnaceBlock {
|
impl BlockBehaviour for BlastFurnaceBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut props = FurnaceLikeProperties::default(args.block);
|
let mut props = FurnaceLikeProperties::default(args.block);
|
||||||
props.facing = args
|
props.facing = args
|
||||||
|
|||||||
@ -11,16 +11,16 @@ use pumpkin_world::BlockStateId;
|
|||||||
use pumpkin_world::tick::TickPriority;
|
use pumpkin_world::tick::TickPriority;
|
||||||
use pumpkin_world::world::{BlockAccessor, BlockFlags};
|
use pumpkin_world::world::{BlockAccessor, BlockFlags};
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{
|
use crate::block::{
|
||||||
CanPlaceAtArgs, GetStateForNeighborUpdateArgs, OnEntityCollisionArgs, OnScheduledTickArgs,
|
BlockBehaviour, CanPlaceAtArgs, GetStateForNeighborUpdateArgs, OnEntityCollisionArgs,
|
||||||
PumpkinBlock, RandomTickArgs,
|
OnScheduledTickArgs, RandomTickArgs,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[pumpkin_block("minecraft:cactus")]
|
#[pumpkin_block("minecraft:cactus")]
|
||||||
pub struct CactusBlock;
|
pub struct CactusBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for CactusBlock {
|
impl BlockBehaviour for CactusBlock {
|
||||||
async fn on_scheduled_tick(&self, args: OnScheduledTickArgs<'_>) {
|
async fn on_scheduled_tick(&self, args: OnScheduledTickArgs<'_>) {
|
||||||
if !can_place_at(args.world.as_ref(), args.position).await {
|
if !can_place_at(args.world.as_ref(), args.position).await {
|
||||||
args.world
|
args.world
|
||||||
|
|||||||
@ -3,8 +3,8 @@ use std::sync::Arc;
|
|||||||
use crate::{
|
use crate::{
|
||||||
block::{
|
block::{
|
||||||
blocks::candle_cakes::cake_from_candle,
|
blocks::candle_cakes::cake_from_candle,
|
||||||
pumpkin_block::{NormalUseArgs, PumpkinBlock, UseWithItemArgs},
|
|
||||||
registry::BlockActionResult,
|
registry::BlockActionResult,
|
||||||
|
{BlockBehaviour, NormalUseArgs, UseWithItemArgs},
|
||||||
},
|
},
|
||||||
entity::player::Player,
|
entity::player::Player,
|
||||||
world::World,
|
world::World,
|
||||||
@ -79,7 +79,7 @@ impl CakeBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for CakeBlock {
|
impl BlockBehaviour for CakeBlock {
|
||||||
async fn use_with_item(&self, args: UseWithItemArgs<'_>) -> BlockActionResult {
|
async fn use_with_item(&self, args: UseWithItemArgs<'_>) -> BlockActionResult {
|
||||||
let state_id = args.world.get_block_state_id(args.position).await;
|
let state_id = args.world.get_block_state_id(args.position).await;
|
||||||
let properties = CakeLikeProperties::from_state_id(state_id, args.block);
|
let properties = CakeLikeProperties::from_state_id(state_id, args.block);
|
||||||
|
|||||||
@ -10,9 +10,9 @@ use pumpkin_world::{BlockStateId, tick::TickPriority};
|
|||||||
use crate::{
|
use crate::{
|
||||||
block::{
|
block::{
|
||||||
BlockIsReplacing,
|
BlockIsReplacing,
|
||||||
pumpkin_block::{
|
{
|
||||||
BlockMetadata, GetStateForNeighborUpdateArgs, OnEntityCollisionArgs, OnPlaceArgs,
|
BlockBehaviour, BlockMetadata, GetStateForNeighborUpdateArgs, OnEntityCollisionArgs,
|
||||||
PumpkinBlock,
|
OnPlaceArgs,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
entity::EntityBase,
|
entity::EntityBase,
|
||||||
@ -31,7 +31,7 @@ impl BlockMetadata for CampfireBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for CampfireBlock {
|
impl BlockBehaviour for CampfireBlock {
|
||||||
// TODO: cooking food on campfire (CampfireBlockEntity)
|
// TODO: cooking food on campfire (CampfireBlockEntity)
|
||||||
async fn on_entity_collision(&self, args: OnEntityCollisionArgs<'_>) {
|
async fn on_entity_collision(&self, args: OnEntityCollisionArgs<'_>) {
|
||||||
if CampfireLikeProperties::from_state_id(args.state.id, args.block).lit
|
if CampfireLikeProperties::from_state_id(args.state.id, args.block).lit
|
||||||
|
|||||||
@ -13,8 +13,8 @@ use pumpkin_world::{item::ItemStack, world::BlockFlags};
|
|||||||
use crate::{
|
use crate::{
|
||||||
block::{
|
block::{
|
||||||
blocks::cake::CakeBlock,
|
blocks::cake::CakeBlock,
|
||||||
pumpkin_block::{NormalUseArgs, PumpkinBlock, UseWithItemArgs},
|
|
||||||
registry::BlockActionResult,
|
registry::BlockActionResult,
|
||||||
|
{BlockBehaviour, NormalUseArgs, UseWithItemArgs},
|
||||||
},
|
},
|
||||||
entity::player::Player,
|
entity::player::Player,
|
||||||
world::World,
|
world::World,
|
||||||
@ -101,7 +101,7 @@ impl CandleCakeBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for CandleCakeBlock {
|
impl BlockBehaviour for CandleCakeBlock {
|
||||||
async fn use_with_item(&self, args: UseWithItemArgs<'_>) -> BlockActionResult {
|
async fn use_with_item(&self, args: UseWithItemArgs<'_>) -> BlockActionResult {
|
||||||
match args.item_stack.lock().await.item.id {
|
match args.item_stack.lock().await.item.id {
|
||||||
id if id == Item::FIRE_CHARGE.id || id == Item::FLINT_AND_STEEL.id => {
|
id if id == Item::FIRE_CHARGE.id || id == Item::FLINT_AND_STEEL.id => {
|
||||||
|
|||||||
@ -12,11 +12,11 @@ use pumpkin_world::{BlockStateId, world::BlockFlags};
|
|||||||
use crate::{
|
use crate::{
|
||||||
block::{
|
block::{
|
||||||
BlockIsReplacing,
|
BlockIsReplacing,
|
||||||
pumpkin_block::{
|
registry::BlockActionResult,
|
||||||
CanPlaceAtArgs, CanUpdateAtArgs, NormalUseArgs, OnPlaceArgs, PumpkinBlock,
|
{
|
||||||
|
BlockBehaviour, CanPlaceAtArgs, CanUpdateAtArgs, NormalUseArgs, OnPlaceArgs,
|
||||||
UseWithItemArgs,
|
UseWithItemArgs,
|
||||||
},
|
},
|
||||||
registry::BlockActionResult,
|
|
||||||
},
|
},
|
||||||
entity::EntityBase,
|
entity::EntityBase,
|
||||||
};
|
};
|
||||||
@ -25,7 +25,7 @@ use crate::{
|
|||||||
pub struct CandleBlock;
|
pub struct CandleBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for CandleBlock {
|
impl BlockBehaviour for CandleBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
if args.player.get_entity().pose.load() != EntityPose::Crouching {
|
if args.player.get_entity().pose.load() != EntityPose::Crouching {
|
||||||
if let BlockIsReplacing::Itself(state_id) = args.replacing {
|
if let BlockIsReplacing::Itself(state_id) = args.replacing {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use crate::block::pumpkin_block::{
|
use crate::block::{
|
||||||
CanPlaceAtArgs, GetStateForNeighborUpdateArgs, OnScheduledTickArgs, PumpkinBlock,
|
BlockBehaviour, CanPlaceAtArgs, GetStateForNeighborUpdateArgs, OnScheduledTickArgs,
|
||||||
};
|
};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::tag::{RegistryKey, get_tag_values};
|
use pumpkin_data::tag::{RegistryKey, get_tag_values};
|
||||||
@ -13,7 +13,7 @@ use pumpkin_world::world::{BlockAccessor, BlockFlags};
|
|||||||
pub struct CarpetBlock;
|
pub struct CarpetBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for CarpetBlock {
|
impl BlockBehaviour for CarpetBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
can_place_at(args.block_accessor, args.position).await
|
can_place_at(args.block_accessor, args.position).await
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ impl PumpkinBlock for CarpetBlock {
|
|||||||
pub struct MossCarpetBlock;
|
pub struct MossCarpetBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for MossCarpetBlock {
|
impl BlockBehaviour for MossCarpetBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
can_place_at(args.block_accessor, args.position).await
|
can_place_at(args.block_accessor, args.position).await
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ impl PumpkinBlock for MossCarpetBlock {
|
|||||||
pub struct PaleMossCarpetBlock;
|
pub struct PaleMossCarpetBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for PaleMossCarpetBlock {
|
impl BlockBehaviour for PaleMossCarpetBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
can_place_at(args.block_accessor, args.position).await
|
can_place_at(args.block_accessor, args.position).await
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,13 +12,11 @@ use pumpkin_world::BlockStateId;
|
|||||||
use pumpkin_world::block::entities::chest::ChestBlockEntity;
|
use pumpkin_world::block::entities::chest::ChestBlockEntity;
|
||||||
use pumpkin_world::world::BlockFlags;
|
use pumpkin_world::world::BlockFlags;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{
|
use crate::block::{BlockMetadata, BrokenArgs, OnPlaceArgs, PlacedArgs, UseWithItemArgs};
|
||||||
BlockMetadata, BrokenArgs, OnPlaceArgs, PlacedArgs, UseWithItemArgs,
|
|
||||||
};
|
|
||||||
use crate::entity::EntityBase;
|
use crate::entity::EntityBase;
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
use crate::{
|
use crate::{
|
||||||
block::{pumpkin_block::PumpkinBlock, registry::BlockActionResult},
|
block::{BlockBehaviour, registry::BlockActionResult},
|
||||||
entity::player::Player,
|
entity::player::Player,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -35,7 +33,7 @@ impl BlockMetadata for ChestBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for ChestBlock {
|
impl BlockBehaviour for ChestBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut chest_props = ChestLikeProperties::default(args.block);
|
let mut chest_props = ChestLikeProperties::default(args.block);
|
||||||
|
|
||||||
|
|||||||
@ -2,11 +2,11 @@ use std::sync::{Arc, atomic::Ordering};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
block::{
|
block::{
|
||||||
pumpkin_block::{
|
|
||||||
BlockHitResult, GetComparatorOutputArgs, NormalUseArgs, OnPlaceArgs, PlacedArgs,
|
|
||||||
PumpkinBlock, UseWithItemArgs,
|
|
||||||
},
|
|
||||||
registry::BlockActionResult,
|
registry::BlockActionResult,
|
||||||
|
{
|
||||||
|
BlockBehaviour, BlockHitResult, GetComparatorOutputArgs, NormalUseArgs, OnPlaceArgs,
|
||||||
|
PlacedArgs, UseWithItemArgs,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
entity::{EntityBase, player::Player},
|
entity::{EntityBase, player::Player},
|
||||||
world::World,
|
world::World,
|
||||||
@ -32,7 +32,7 @@ use tokio::sync::Mutex;
|
|||||||
pub struct ChiseledBookshelfBlock;
|
pub struct ChiseledBookshelfBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for ChiseledBookshelfBlock {
|
impl BlockBehaviour for ChiseledBookshelfBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut properties = ChiseledBookshelfLikeProperties::default(args.block);
|
let mut properties = ChiseledBookshelfLikeProperties::default(args.block);
|
||||||
|
|
||||||
|
|||||||
@ -6,8 +6,8 @@ use pumpkin_util::{GameMode, math::position::BlockPos};
|
|||||||
use pumpkin_world::{block::entities::command_block::CommandBlockEntity, tick::TickPriority};
|
use pumpkin_world::{block::entities::command_block::CommandBlockEntity, tick::TickPriority};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
block::pumpkin_block::{
|
block::{
|
||||||
BlockMetadata, CanPlaceAtArgs, OnNeighborUpdateArgs, OnScheduledTickArgs, PumpkinBlock,
|
BlockBehaviour, BlockMetadata, CanPlaceAtArgs, OnNeighborUpdateArgs, OnScheduledTickArgs,
|
||||||
},
|
},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
@ -51,7 +51,7 @@ impl BlockMetadata for CommandBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for CommandBlock {
|
impl BlockBehaviour for CommandBlock {
|
||||||
async fn on_neighbor_update(&self, args: OnNeighborUpdateArgs<'_>) {
|
async fn on_neighbor_update(&self, args: OnNeighborUpdateArgs<'_>) {
|
||||||
if let Some(block_entity) = args.world.get_block_entity(args.position).await {
|
if let Some(block_entity) = args.world.get_block_entity(args.position).await {
|
||||||
if block_entity.resource_location() != CommandBlockEntity::ID {
|
if block_entity.resource_location() != CommandBlockEntity::ID {
|
||||||
|
|||||||
@ -2,11 +2,11 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
block::{
|
block::{
|
||||||
pumpkin_block::{
|
registry::BlockActionResult,
|
||||||
GetComparatorOutputArgs, NormalUseArgs, OnScheduledTickArgs, PumpkinBlock,
|
{
|
||||||
|
BlockBehaviour, GetComparatorOutputArgs, NormalUseArgs, OnScheduledTickArgs,
|
||||||
UseWithItemArgs,
|
UseWithItemArgs,
|
||||||
},
|
},
|
||||||
registry::BlockActionResult,
|
|
||||||
},
|
},
|
||||||
entity::{Entity, item::ItemEntity},
|
entity::{Entity, item::ItemEntity},
|
||||||
world::World,
|
world::World,
|
||||||
@ -30,7 +30,7 @@ use uuid::Uuid;
|
|||||||
pub struct ComposterBlock;
|
pub struct ComposterBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for ComposterBlock {
|
impl BlockBehaviour for ComposterBlock {
|
||||||
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
||||||
let state_id = args.world.get_block_state_id(args.position).await;
|
let state_id = args.world.get_block_state_id(args.position).await;
|
||||||
let props = ComposterLikeProperties::from_state_id(state_id, args.block);
|
let props = ComposterLikeProperties::from_state_id(state_id, args.block);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use crate::block::pumpkin_block::{NormalUseArgs, PumpkinBlock};
|
|
||||||
use crate::block::registry::BlockActionResult;
|
use crate::block::registry::BlockActionResult;
|
||||||
|
use crate::block::{BlockBehaviour, NormalUseArgs};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_inventory::crafting::crafting_screen_handler::CraftingTableScreenHandler;
|
use pumpkin_inventory::crafting::crafting_screen_handler::CraftingTableScreenHandler;
|
||||||
use pumpkin_inventory::player::player_inventory::PlayerInventory;
|
use pumpkin_inventory::player::player_inventory::PlayerInventory;
|
||||||
@ -13,7 +13,7 @@ use tokio::sync::Mutex;
|
|||||||
pub struct CraftingTableBlock;
|
pub struct CraftingTableBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for CraftingTableBlock {
|
impl BlockBehaviour for CraftingTableBlock {
|
||||||
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
||||||
args.player
|
args.player
|
||||||
.open_handled_screen(&CraftingTableScreenFactory)
|
.open_handled_screen(&CraftingTableScreenFactory)
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
use crate::block::pumpkin_block::CanPlaceAtArgs;
|
use crate::block::BlockBehaviour;
|
||||||
use crate::block::pumpkin_block::GetStateForNeighborUpdateArgs;
|
use crate::block::CanPlaceAtArgs;
|
||||||
use crate::block::pumpkin_block::OnPlaceArgs;
|
use crate::block::GetStateForNeighborUpdateArgs;
|
||||||
use crate::block::pumpkin_block::OnScheduledTickArgs;
|
use crate::block::OnPlaceArgs;
|
||||||
use crate::block::pumpkin_block::PumpkinBlock;
|
use crate::block::OnScheduledTickArgs;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::Block;
|
use pumpkin_data::Block;
|
||||||
use pumpkin_data::BlockDirection;
|
use pumpkin_data::BlockDirection;
|
||||||
@ -17,7 +17,7 @@ use pumpkin_world::world::BlockFlags;
|
|||||||
pub struct DirtPathBlock;
|
pub struct DirtPathBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for DirtPathBlock {
|
impl BlockBehaviour for DirtPathBlock {
|
||||||
async fn on_scheduled_tick(&self, args: OnScheduledTickArgs<'_>) {
|
async fn on_scheduled_tick(&self, args: OnScheduledTickArgs<'_>) {
|
||||||
// TODO: push up entities
|
// TODO: push up entities
|
||||||
args.world
|
args.world
|
||||||
|
|||||||
@ -19,14 +19,14 @@ use pumpkin_world::world::BlockAccessor;
|
|||||||
use pumpkin_world::world::BlockFlags;
|
use pumpkin_world::world::BlockFlags;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use crate::block::BlockBehaviour;
|
||||||
|
use crate::block::CanPlaceAtArgs;
|
||||||
|
use crate::block::GetStateForNeighborUpdateArgs;
|
||||||
|
use crate::block::NormalUseArgs;
|
||||||
|
use crate::block::OnNeighborUpdateArgs;
|
||||||
|
use crate::block::OnPlaceArgs;
|
||||||
|
use crate::block::PlacedArgs;
|
||||||
use crate::block::blocks::redstone::block_receives_redstone_power;
|
use crate::block::blocks::redstone::block_receives_redstone_power;
|
||||||
use crate::block::pumpkin_block::CanPlaceAtArgs;
|
|
||||||
use crate::block::pumpkin_block::GetStateForNeighborUpdateArgs;
|
|
||||||
use crate::block::pumpkin_block::NormalUseArgs;
|
|
||||||
use crate::block::pumpkin_block::OnNeighborUpdateArgs;
|
|
||||||
use crate::block::pumpkin_block::OnPlaceArgs;
|
|
||||||
use crate::block::pumpkin_block::PlacedArgs;
|
|
||||||
use crate::block::pumpkin_block::PumpkinBlock;
|
|
||||||
use crate::block::registry::BlockActionResult;
|
use crate::block::registry::BlockActionResult;
|
||||||
use crate::entity::player::Player;
|
use crate::entity::player::Player;
|
||||||
use pumpkin_protocol::java::server::play::SUseItemOn;
|
use pumpkin_protocol::java::server::play::SUseItemOn;
|
||||||
@ -164,7 +164,7 @@ async fn get_hinge(
|
|||||||
pub struct DoorBlock;
|
pub struct DoorBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for DoorBlock {
|
impl BlockBehaviour for DoorBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let powered = block_receives_redstone_power(args.world, args.position).await
|
let powered = block_receives_redstone_power(args.world, args.position).await
|
||||||
|| block_receives_redstone_power(args.world, &args.position.up()).await;
|
|| block_receives_redstone_power(args.world, &args.position.up()).await;
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::OnEntityCollisionArgs;
|
use crate::block::BlockBehaviour;
|
||||||
use crate::block::pumpkin_block::PlacedArgs;
|
use crate::block::OnEntityCollisionArgs;
|
||||||
use crate::block::pumpkin_block::PumpkinBlock;
|
use crate::block::PlacedArgs;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_macros::pumpkin_block;
|
use pumpkin_macros::pumpkin_block;
|
||||||
use pumpkin_registry::VanillaDimensionType;
|
use pumpkin_registry::VanillaDimensionType;
|
||||||
@ -12,7 +12,7 @@ use pumpkin_world::block::entities::end_portal::EndPortalBlockEntity;
|
|||||||
pub struct EndPortalBlock;
|
pub struct EndPortalBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for EndPortalBlock {
|
impl BlockBehaviour for EndPortalBlock {
|
||||||
async fn on_entity_collision(&self, args: OnEntityCollisionArgs<'_>) {
|
async fn on_entity_collision(&self, args: OnEntityCollisionArgs<'_>) {
|
||||||
let world = if args.world.dimension_type == VanillaDimensionType::TheEnd {
|
let world = if args.world.dimension_type == VanillaDimensionType::TheEnd {
|
||||||
args.server
|
args.server
|
||||||
|
|||||||
@ -4,7 +4,7 @@ use pumpkin_macros::pumpkin_block;
|
|||||||
use pumpkin_world::BlockStateId;
|
use pumpkin_world::BlockStateId;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
block::pumpkin_block::{OnPlaceArgs, PumpkinBlock},
|
block::{BlockBehaviour, OnPlaceArgs},
|
||||||
entity::EntityBase,
|
entity::EntityBase,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ type EndPortalFrameProperties = pumpkin_data::block_properties::EndPortalFrameLi
|
|||||||
pub struct EndPortalFrameBlock;
|
pub struct EndPortalFrameBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for EndPortalFrameBlock {
|
impl BlockBehaviour for EndPortalFrameBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut end_portal_frame_props = EndPortalFrameProperties::default(args.block);
|
let mut end_portal_frame_props = EndPortalFrameProperties::default(args.block);
|
||||||
end_portal_frame_props.facing = args.player.get_entity().get_horizontal_facing().opposite();
|
end_portal_frame_props.facing = args.player.get_entity().get_horizontal_facing().opposite();
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use crate::block::pumpkin_block::{OnPlaceArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, OnPlaceArgs};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::block_properties::{BlockProperties, LadderLikeProperties};
|
use pumpkin_data::block_properties::{BlockProperties, LadderLikeProperties};
|
||||||
use pumpkin_macros::pumpkin_block;
|
use pumpkin_macros::pumpkin_block;
|
||||||
@ -8,7 +8,7 @@ use pumpkin_world::BlockStateId;
|
|||||||
pub struct EnderChestBlock;
|
pub struct EnderChestBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for EnderChestBlock {
|
impl BlockBehaviour for EnderChestBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut props = LadderLikeProperties::default(args.block);
|
let mut props = LadderLikeProperties::default(args.block);
|
||||||
props.facing = args
|
props.facing = args
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
use crate::block::pumpkin_block::CanPlaceAtArgs;
|
use crate::block::BlockBehaviour;
|
||||||
use crate::block::pumpkin_block::GetStateForNeighborUpdateArgs;
|
use crate::block::CanPlaceAtArgs;
|
||||||
use crate::block::pumpkin_block::OnPlaceArgs;
|
use crate::block::GetStateForNeighborUpdateArgs;
|
||||||
use crate::block::pumpkin_block::OnScheduledTickArgs;
|
use crate::block::OnPlaceArgs;
|
||||||
use crate::block::pumpkin_block::PumpkinBlock;
|
use crate::block::OnScheduledTickArgs;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::Block;
|
use pumpkin_data::Block;
|
||||||
use pumpkin_data::BlockDirection;
|
use pumpkin_data::BlockDirection;
|
||||||
@ -17,7 +17,7 @@ use pumpkin_world::world::BlockFlags;
|
|||||||
pub struct FarmLandBlock;
|
pub struct FarmLandBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for FarmLandBlock {
|
impl BlockBehaviour for FarmLandBlock {
|
||||||
async fn on_scheduled_tick(&self, args: OnScheduledTickArgs<'_>) {
|
async fn on_scheduled_tick(&self, args: OnScheduledTickArgs<'_>) {
|
||||||
// TODO: push up entities
|
// TODO: push up entities
|
||||||
args.world
|
args.world
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::GetStateForNeighborUpdateArgs;
|
use crate::block::GetStateForNeighborUpdateArgs;
|
||||||
use crate::block::pumpkin_block::NormalUseArgs;
|
use crate::block::NormalUseArgs;
|
||||||
use crate::block::pumpkin_block::OnPlaceArgs;
|
use crate::block::OnPlaceArgs;
|
||||||
use crate::entity::player::Player;
|
use crate::entity::player::Player;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::block_properties::BlockProperties;
|
use pumpkin_data::block_properties::BlockProperties;
|
||||||
@ -15,7 +15,7 @@ use pumpkin_util::math::position::BlockPos;
|
|||||||
use pumpkin_world::BlockStateId;
|
use pumpkin_world::BlockStateId;
|
||||||
use pumpkin_world::world::BlockFlags;
|
use pumpkin_world::world::BlockFlags;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::PumpkinBlock;
|
use crate::block::BlockBehaviour;
|
||||||
use crate::block::registry::BlockActionResult;
|
use crate::block::registry::BlockActionResult;
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ pub async fn toggle_fence_gate(
|
|||||||
pub struct FenceGateBlock;
|
pub struct FenceGateBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for FenceGateBlock {
|
impl BlockBehaviour for FenceGateBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut fence_gate_props = FenceGateProperties::default(args.block);
|
let mut fence_gate_props = FenceGateProperties::default(args.block);
|
||||||
fence_gate_props.facing = args.player.living_entity.entity.get_horizontal_facing();
|
fence_gate_props.facing = args.player.living_entity.entity.get_horizontal_facing();
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use crate::block::pumpkin_block::GetStateForNeighborUpdateArgs;
|
use crate::block::GetStateForNeighborUpdateArgs;
|
||||||
use crate::block::pumpkin_block::OnPlaceArgs;
|
use crate::block::OnPlaceArgs;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::BlockDirection;
|
use pumpkin_data::BlockDirection;
|
||||||
use pumpkin_data::BlockState;
|
use pumpkin_data::BlockState;
|
||||||
@ -14,7 +14,7 @@ use pumpkin_world::BlockStateId;
|
|||||||
type FenceGateProperties = pumpkin_data::block_properties::OakFenceGateLikeProperties;
|
type FenceGateProperties = pumpkin_data::block_properties::OakFenceGateLikeProperties;
|
||||||
type FenceProperties = pumpkin_data::block_properties::OakFenceLikeProperties;
|
type FenceProperties = pumpkin_data::block_properties::OakFenceLikeProperties;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{BlockMetadata, PumpkinBlock};
|
use crate::block::{BlockBehaviour, BlockMetadata};
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
|
|
||||||
pub struct FenceBlock;
|
pub struct FenceBlock;
|
||||||
@ -29,7 +29,7 @@ impl BlockMetadata for FenceBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for FenceBlock {
|
impl BlockBehaviour for FenceBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut fence_props = FenceProperties::default(args.block);
|
let mut fence_props = FenceProperties::default(args.block);
|
||||||
fence_props.waterlogged = args.replacing.water_source();
|
fence_props.waterlogged = args.replacing.water_source();
|
||||||
|
|||||||
@ -16,9 +16,9 @@ use pumpkin_world::BlockStateId;
|
|||||||
use pumpkin_world::tick::TickPriority;
|
use pumpkin_world::tick::TickPriority;
|
||||||
|
|
||||||
use crate::block::blocks::tnt::TNTBlock;
|
use crate::block::blocks::tnt::TNTBlock;
|
||||||
use crate::block::pumpkin_block::{
|
use crate::block::{
|
||||||
BrokenArgs, CanPlaceAtArgs, GetStateForNeighborUpdateArgs, OnEntityCollisionArgs,
|
BlockBehaviour, BrokenArgs, CanPlaceAtArgs, GetStateForNeighborUpdateArgs,
|
||||||
OnScheduledTickArgs, PlacedArgs, PumpkinBlock,
|
OnEntityCollisionArgs, OnScheduledTickArgs, PlacedArgs,
|
||||||
};
|
};
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
use crate::world::portal::nether::NetherPortal;
|
use crate::world::portal::nether::NetherPortal;
|
||||||
@ -166,7 +166,7 @@ impl FireBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for FireBlock {
|
impl BlockBehaviour for FireBlock {
|
||||||
async fn placed(&self, args: PlacedArgs<'_>) {
|
async fn placed(&self, args: PlacedArgs<'_>) {
|
||||||
if args.old_state_id == args.state_id {
|
if args.old_state_id == args.state_id {
|
||||||
// Already a fire
|
// Already a fire
|
||||||
|
|||||||
@ -11,7 +11,7 @@ use rand::Rng;
|
|||||||
use soul_fire::SoulFireBlock;
|
use soul_fire::SoulFireBlock;
|
||||||
|
|
||||||
use crate::block::blocks::fire::fire::FireBlock;
|
use crate::block::blocks::fire::fire::FireBlock;
|
||||||
use crate::block::pumpkin_block::{CanPlaceAtArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, CanPlaceAtArgs};
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
use crate::world::portal::nether::NetherPortal;
|
use crate::world::portal::nether::NetherPortal;
|
||||||
|
|
||||||
|
|||||||
@ -4,9 +4,7 @@ use pumpkin_data::{Block, tag};
|
|||||||
use pumpkin_macros::pumpkin_block;
|
use pumpkin_macros::pumpkin_block;
|
||||||
use pumpkin_world::BlockStateId;
|
use pumpkin_world::BlockStateId;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{
|
use crate::block::{BlockBehaviour, BrokenArgs, CanPlaceAtArgs, GetStateForNeighborUpdateArgs};
|
||||||
BrokenArgs, CanPlaceAtArgs, GetStateForNeighborUpdateArgs, PumpkinBlock,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::FireBlockBase;
|
use super::FireBlockBase;
|
||||||
|
|
||||||
@ -21,7 +19,7 @@ impl SoulFireBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for SoulFireBlock {
|
impl BlockBehaviour for SoulFireBlock {
|
||||||
async fn get_state_for_neighbor_update(
|
async fn get_state_for_neighbor_update(
|
||||||
&self,
|
&self,
|
||||||
args: GetStateForNeighborUpdateArgs<'_>,
|
args: GetStateForNeighborUpdateArgs<'_>,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use crate::block::pumpkin_block::{PumpkinBlock, RandomTickArgs, UseWithItemArgs};
|
|
||||||
use crate::block::registry::BlockActionResult;
|
use crate::block::registry::BlockActionResult;
|
||||||
|
use crate::block::{BlockBehaviour, RandomTickArgs, UseWithItemArgs};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::Block;
|
use pumpkin_data::Block;
|
||||||
use pumpkin_data::flower_pot_transformations::get_potted_item;
|
use pumpkin_data::flower_pot_transformations::get_potted_item;
|
||||||
@ -12,7 +12,7 @@ use pumpkin_world::world::BlockFlags;
|
|||||||
pub struct FlowerPotBlock;
|
pub struct FlowerPotBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for FlowerPotBlock {
|
impl BlockBehaviour for FlowerPotBlock {
|
||||||
async fn use_with_item(&self, args: UseWithItemArgs<'_>) -> BlockActionResult {
|
async fn use_with_item(&self, args: UseWithItemArgs<'_>) -> BlockActionResult {
|
||||||
let item = args.item_stack.lock().await.item;
|
let item = args.item_stack.lock().await.item;
|
||||||
//Place the flower inside the pot
|
//Place the flower inside the pot
|
||||||
|
|||||||
@ -13,7 +13,7 @@ use pumpkin_world::{
|
|||||||
};
|
};
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::PumpkinBlock;
|
use crate::block::BlockBehaviour;
|
||||||
|
|
||||||
struct FurnaceScreenFactory {
|
struct FurnaceScreenFactory {
|
||||||
inventory: Arc<dyn Inventory>,
|
inventory: Arc<dyn Inventory>,
|
||||||
@ -56,10 +56,10 @@ impl ScreenHandlerFactory for FurnaceScreenFactory {
|
|||||||
pub struct FurnaceBlock;
|
pub struct FurnaceBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for FurnaceBlock {
|
impl BlockBehaviour for FurnaceBlock {
|
||||||
async fn normal_use(
|
async fn normal_use(
|
||||||
&self,
|
&self,
|
||||||
args: crate::block::pumpkin_block::NormalUseArgs<'_>,
|
args: crate::block::NormalUseArgs<'_>,
|
||||||
) -> crate::block::registry::BlockActionResult {
|
) -> crate::block::registry::BlockActionResult {
|
||||||
if let Some(block_entity) = args.world.get_block_entity(args.position).await {
|
if let Some(block_entity) = args.world.get_block_entity(args.position).await {
|
||||||
if let Some(inventory) = block_entity.clone().get_inventory() {
|
if let Some(inventory) = block_entity.clone().get_inventory() {
|
||||||
@ -75,34 +75,24 @@ impl PumpkinBlock for FurnaceBlock {
|
|||||||
//Same to normal_use
|
//Same to normal_use
|
||||||
async fn use_with_item(
|
async fn use_with_item(
|
||||||
&self,
|
&self,
|
||||||
_args: crate::block::pumpkin_block::UseWithItemArgs<'_>,
|
_args: crate::block::UseWithItemArgs<'_>,
|
||||||
) -> crate::block::registry::BlockActionResult {
|
) -> crate::block::registry::BlockActionResult {
|
||||||
crate::block::registry::BlockActionResult::PassToDefaultBlockAction
|
crate::block::registry::BlockActionResult::PassToDefaultBlockAction
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn on_entity_collision(
|
async fn on_entity_collision(&self, _args: crate::block::OnEntityCollisionArgs<'_>) {}
|
||||||
&self,
|
|
||||||
_args: crate::block::pumpkin_block::OnEntityCollisionArgs<'_>,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
fn should_drop_items_on_explosion(&self) -> bool {
|
fn should_drop_items_on_explosion(&self) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn explode(&self, _args: crate::block::pumpkin_block::ExplodeArgs<'_>) {}
|
async fn explode(&self, _args: crate::block::ExplodeArgs<'_>) {}
|
||||||
|
|
||||||
async fn on_synced_block_event(
|
async fn on_synced_block_event(&self, _args: crate::block::OnSyncedBlockEventArgs<'_>) -> bool {
|
||||||
&self,
|
|
||||||
_args: crate::block::pumpkin_block::OnSyncedBlockEventArgs<'_>,
|
|
||||||
) -> bool {
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn on_place(
|
async fn on_place(&self, args: crate::block::OnPlaceArgs<'_>) -> pumpkin_world::BlockStateId {
|
||||||
&self,
|
|
||||||
args: crate::block::pumpkin_block::OnPlaceArgs<'_>,
|
|
||||||
) -> pumpkin_world::BlockStateId {
|
|
||||||
let mut props = FurnaceLikeProperties::default(args.block);
|
let mut props = FurnaceLikeProperties::default(args.block);
|
||||||
props.facing = args
|
props.facing = args
|
||||||
.player
|
.player
|
||||||
@ -114,74 +104,59 @@ impl PumpkinBlock for FurnaceBlock {
|
|||||||
props.to_state_id(args.block)
|
props.to_state_id(args.block)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn random_tick(&self, _args: crate::block::pumpkin_block::RandomTickArgs<'_>) {}
|
async fn random_tick(&self, _args: crate::block::RandomTickArgs<'_>) {}
|
||||||
|
|
||||||
async fn can_place_at(&self, _args: crate::block::pumpkin_block::CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, _args: crate::block::CanPlaceAtArgs<'_>) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn can_update_at(&self, _args: crate::block::pumpkin_block::CanUpdateAtArgs<'_>) -> bool {
|
async fn can_update_at(&self, _args: crate::block::CanUpdateAtArgs<'_>) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn placed(&self, args: crate::block::pumpkin_block::PlacedArgs<'_>) {
|
async fn placed(&self, args: crate::block::PlacedArgs<'_>) {
|
||||||
let furnace_block_entity = FurnaceBlockEntity::new(*args.position);
|
let furnace_block_entity = FurnaceBlockEntity::new(*args.position);
|
||||||
args.world
|
args.world
|
||||||
.add_block_entity(Arc::new(furnace_block_entity))
|
.add_block_entity(Arc::new(furnace_block_entity))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn player_placed(&self, _args: crate::block::pumpkin_block::PlayerPlacedArgs<'_>) {}
|
async fn player_placed(&self, _args: crate::block::PlayerPlacedArgs<'_>) {}
|
||||||
|
|
||||||
async fn broken(&self, args: crate::block::pumpkin_block::BrokenArgs<'_>) {
|
async fn broken(&self, args: crate::block::BrokenArgs<'_>) {
|
||||||
args.world.remove_block_entity(args.position).await;
|
args.world.remove_block_entity(args.position).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn on_neighbor_update(
|
async fn on_neighbor_update(&self, _args: crate::block::OnNeighborUpdateArgs<'_>) {}
|
||||||
&self,
|
|
||||||
_args: crate::block::pumpkin_block::OnNeighborUpdateArgs<'_>,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn prepare(&self, _args: crate::block::pumpkin_block::PrepareArgs<'_>) {}
|
async fn prepare(&self, _args: crate::block::PrepareArgs<'_>) {}
|
||||||
|
|
||||||
async fn get_state_for_neighbor_update(
|
async fn get_state_for_neighbor_update(
|
||||||
&self,
|
&self,
|
||||||
args: crate::block::pumpkin_block::GetStateForNeighborUpdateArgs<'_>,
|
args: crate::block::GetStateForNeighborUpdateArgs<'_>,
|
||||||
) -> pumpkin_world::BlockStateId {
|
) -> pumpkin_world::BlockStateId {
|
||||||
args.state_id
|
args.state_id
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn on_scheduled_tick(&self, _args: crate::block::pumpkin_block::OnScheduledTickArgs<'_>) {
|
async fn on_scheduled_tick(&self, _args: crate::block::OnScheduledTickArgs<'_>) {}
|
||||||
}
|
|
||||||
|
|
||||||
async fn on_state_replaced(&self, _args: crate::block::pumpkin_block::OnStateReplacedArgs<'_>) {
|
async fn on_state_replaced(&self, _args: crate::block::OnStateReplacedArgs<'_>) {}
|
||||||
}
|
|
||||||
|
|
||||||
async fn emits_redstone_power(
|
async fn emits_redstone_power(&self, _args: crate::block::EmitsRedstonePowerArgs<'_>) -> bool {
|
||||||
&self,
|
|
||||||
_args: crate::block::pumpkin_block::EmitsRedstonePowerArgs<'_>,
|
|
||||||
) -> bool {
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_weak_redstone_power(
|
async fn get_weak_redstone_power(&self, _args: crate::block::GetRedstonePowerArgs<'_>) -> u8 {
|
||||||
&self,
|
|
||||||
_args: crate::block::pumpkin_block::GetRedstonePowerArgs<'_>,
|
|
||||||
) -> u8 {
|
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_strong_redstone_power(
|
async fn get_strong_redstone_power(&self, _args: crate::block::GetRedstonePowerArgs<'_>) -> u8 {
|
||||||
&self,
|
|
||||||
_args: crate::block::pumpkin_block::GetRedstonePowerArgs<'_>,
|
|
||||||
) -> u8 {
|
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_comparator_output(
|
async fn get_comparator_output(
|
||||||
&self,
|
&self,
|
||||||
_args: crate::block::pumpkin_block::GetComparatorOutputArgs<'_>,
|
_args: crate::block::GetComparatorOutputArgs<'_>,
|
||||||
) -> Option<u8> {
|
) -> Option<u8> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use crate::block::pumpkin_block::GetStateForNeighborUpdateArgs;
|
use crate::block::GetStateForNeighborUpdateArgs;
|
||||||
use crate::block::pumpkin_block::OnPlaceArgs;
|
use crate::block::OnPlaceArgs;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::BlockDirection;
|
use pumpkin_data::BlockDirection;
|
||||||
use pumpkin_data::block_properties::BlockProperties;
|
use pumpkin_data::block_properties::BlockProperties;
|
||||||
@ -12,7 +12,7 @@ use pumpkin_world::BlockStateId;
|
|||||||
|
|
||||||
type GlassPaneProperties = pumpkin_data::block_properties::OakFenceLikeProperties;
|
type GlassPaneProperties = pumpkin_data::block_properties::OakFenceLikeProperties;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{BlockMetadata, PumpkinBlock};
|
use crate::block::{BlockBehaviour, BlockMetadata};
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
|
|
||||||
pub struct GlassPaneBlock;
|
pub struct GlassPaneBlock;
|
||||||
@ -27,7 +27,7 @@ impl BlockMetadata for GlassPaneBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for GlassPaneBlock {
|
impl BlockBehaviour for GlassPaneBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut pane_props = GlassPaneProperties::default(args.block);
|
let mut pane_props = GlassPaneProperties::default(args.block);
|
||||||
pane_props.waterlogged = args.replacing.water_source();
|
pane_props.waterlogged = args.replacing.water_source();
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use crate::block::pumpkin_block::{BlockMetadata, OnPlaceArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, BlockMetadata, OnPlaceArgs};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::block_properties::{BlockProperties, WallTorchLikeProperties};
|
use pumpkin_data::block_properties::{BlockProperties, WallTorchLikeProperties};
|
||||||
use pumpkin_data::tag::{RegistryKey, get_tag_values};
|
use pumpkin_data::tag::{RegistryKey, get_tag_values};
|
||||||
@ -16,7 +16,7 @@ impl BlockMetadata for GlazedTerracottaBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for GlazedTerracottaBlock {
|
impl BlockBehaviour for GlazedTerracottaBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut prop = WallTorchLikeProperties::default(args.block);
|
let mut prop = WallTorchLikeProperties::default(args.block);
|
||||||
prop.facing = args
|
prop.facing = args
|
||||||
|
|||||||
@ -7,9 +7,9 @@ use pumpkin_macros::pumpkin_block;
|
|||||||
use pumpkin_util::math::position::BlockPos;
|
use pumpkin_util::math::position::BlockPos;
|
||||||
use pumpkin_world::{BlockStateId, world::BlockAccessor};
|
use pumpkin_world::{BlockStateId, world::BlockAccessor};
|
||||||
|
|
||||||
use crate::block::pumpkin_block::CanPlaceAtArgs;
|
use crate::block::BlockBehaviour;
|
||||||
use crate::block::pumpkin_block::PumpkinBlock;
|
use crate::block::CanPlaceAtArgs;
|
||||||
use crate::block::pumpkin_block::{GetStateForNeighborUpdateArgs, OnPlaceArgs};
|
use crate::block::{GetStateForNeighborUpdateArgs, OnPlaceArgs};
|
||||||
|
|
||||||
use super::abstruct_wall_mounting::WallMountedBlock;
|
use super::abstruct_wall_mounting::WallMountedBlock;
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ use super::abstruct_wall_mounting::WallMountedBlock;
|
|||||||
pub struct GrindstoneBlock;
|
pub struct GrindstoneBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for GrindstoneBlock {
|
impl BlockBehaviour for GrindstoneBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut props =
|
let mut props =
|
||||||
GrindstoneLikeProperties::from_state_id(args.block.default_state.id, args.block);
|
GrindstoneLikeProperties::from_state_id(args.block.default_state.id, args.block);
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::block::blocks::redstone::block_receives_redstone_power;
|
use crate::block::blocks::redstone::block_receives_redstone_power;
|
||||||
use crate::block::pumpkin_block::{OnNeighborUpdateArgs, OnPlaceArgs, PlacedArgs};
|
use crate::block::{OnNeighborUpdateArgs, OnPlaceArgs, PlacedArgs};
|
||||||
use crate::block::{
|
use crate::block::{
|
||||||
pumpkin_block::{NormalUseArgs, PumpkinBlock},
|
|
||||||
registry::BlockActionResult,
|
registry::BlockActionResult,
|
||||||
|
{BlockBehaviour, NormalUseArgs},
|
||||||
};
|
};
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
@ -50,7 +50,7 @@ pub struct HopperBlock;
|
|||||||
type HopperLikeProperties = pumpkin_data::block_properties::HopperLikeProperties;
|
type HopperLikeProperties = pumpkin_data::block_properties::HopperLikeProperties;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for HopperBlock {
|
impl BlockBehaviour for HopperBlock {
|
||||||
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
||||||
if let Some(block_entity) = args.world.get_block_entity(args.position).await {
|
if let Some(block_entity) = args.world.get_block_entity(args.position).await {
|
||||||
if let Some(inventory) = block_entity.get_inventory() {
|
if let Some(inventory) = block_entity.get_inventory() {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use crate::block::pumpkin_block::GetStateForNeighborUpdateArgs;
|
use crate::block::GetStateForNeighborUpdateArgs;
|
||||||
use crate::block::pumpkin_block::OnPlaceArgs;
|
use crate::block::OnPlaceArgs;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::BlockDirection;
|
use pumpkin_data::BlockDirection;
|
||||||
use pumpkin_data::block_properties::BlockProperties;
|
use pumpkin_data::block_properties::BlockProperties;
|
||||||
@ -11,14 +11,14 @@ use pumpkin_world::BlockStateId;
|
|||||||
|
|
||||||
type IronBarsProperties = pumpkin_data::block_properties::OakFenceLikeProperties;
|
type IronBarsProperties = pumpkin_data::block_properties::OakFenceLikeProperties;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::PumpkinBlock;
|
use crate::block::BlockBehaviour;
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
|
|
||||||
#[pumpkin_block("minecraft:iron_bars")]
|
#[pumpkin_block("minecraft:iron_bars")]
|
||||||
pub struct IronBarsBlock;
|
pub struct IronBarsBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for IronBarsBlock {
|
impl BlockBehaviour for IronBarsBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut bars_props = IronBarsProperties::default(args.block);
|
let mut bars_props = IronBarsProperties::default(args.block);
|
||||||
bars_props.waterlogged = args.replacing.water_source();
|
bars_props.waterlogged = args.replacing.water_source();
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{BrokenArgs, PumpkinBlock, UseWithItemArgs};
|
|
||||||
use crate::block::registry::BlockActionResult;
|
use crate::block::registry::BlockActionResult;
|
||||||
|
use crate::block::{BlockBehaviour, BrokenArgs, UseWithItemArgs};
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::data_component_impl::JukeboxPlayableImpl;
|
use pumpkin_data::data_component_impl::JukeboxPlayableImpl;
|
||||||
@ -46,7 +46,7 @@ impl JukeboxBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for JukeboxBlock {
|
impl BlockBehaviour for JukeboxBlock {
|
||||||
async fn use_with_item(&self, args: UseWithItemArgs<'_>) -> BlockActionResult {
|
async fn use_with_item(&self, args: UseWithItemArgs<'_>) -> BlockActionResult {
|
||||||
let world = &args.player.living_entity.entity.world.read().await;
|
let world = &args.player.living_entity.entity.world.read().await;
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use crate::block::pumpkin_block::{
|
use crate::block::{
|
||||||
CanPlaceAtArgs, GetStateForNeighborUpdateArgs, OnPlaceArgs, OnScheduledTickArgs, PumpkinBlock,
|
BlockBehaviour, CanPlaceAtArgs, GetStateForNeighborUpdateArgs, OnPlaceArgs, OnScheduledTickArgs,
|
||||||
};
|
};
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
@ -16,7 +16,7 @@ use pumpkin_world::world::BlockFlags;
|
|||||||
pub struct LadderBlock;
|
pub struct LadderBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for LadderBlock {
|
impl BlockBehaviour for LadderBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut props = LadderLikeProperties::default(args.block);
|
let mut props = LadderLikeProperties::default(args.block);
|
||||||
props.facing = args.direction.opposite().to_cardinal_direction();
|
props.facing = args.direction.opposite().to_cardinal_direction();
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use crate::block::pumpkin_block::{OnPlaceArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, OnPlaceArgs};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::block_properties::{BlockProperties, LecternLikeProperties};
|
use pumpkin_data::block_properties::{BlockProperties, LecternLikeProperties};
|
||||||
use pumpkin_macros::pumpkin_block;
|
use pumpkin_macros::pumpkin_block;
|
||||||
@ -8,7 +8,7 @@ use pumpkin_world::BlockStateId;
|
|||||||
pub struct LecternBlock;
|
pub struct LecternBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for LecternBlock {
|
impl BlockBehaviour for LecternBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut props = LecternLikeProperties::default(args.block);
|
let mut props = LecternLikeProperties::default(args.block);
|
||||||
props.facing = args
|
props.facing = args
|
||||||
|
|||||||
@ -4,8 +4,8 @@ use pumpkin_data::tag::{RegistryKey, get_tag_values};
|
|||||||
use pumpkin_macros::pumpkin_block_from_tag;
|
use pumpkin_macros::pumpkin_block_from_tag;
|
||||||
use pumpkin_world::BlockStateId;
|
use pumpkin_world::BlockStateId;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::OnPlaceArgs;
|
use crate::block::BlockBehaviour;
|
||||||
use crate::block::pumpkin_block::PumpkinBlock;
|
use crate::block::OnPlaceArgs;
|
||||||
|
|
||||||
type LogProperties = pumpkin_data::block_properties::PaleOakWoodLikeProperties;
|
type LogProperties = pumpkin_data::block_properties::PaleOakWoodLikeProperties;
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ type LogProperties = pumpkin_data::block_properties::PaleOakWoodLikeProperties;
|
|||||||
pub struct LogBlock;
|
pub struct LogBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for LogBlock {
|
impl BlockBehaviour for LogBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut log_props = LogProperties::default(args.block);
|
let mut log_props = LogProperties::default(args.block);
|
||||||
log_props.axis = args.direction.to_axis();
|
log_props.axis = args.direction.to_axis();
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{
|
use crate::block::{BlockBehaviour, GetStateForNeighborUpdateArgs, OnEntityCollisionArgs};
|
||||||
GetStateForNeighborUpdateArgs, OnEntityCollisionArgs, PumpkinBlock,
|
|
||||||
};
|
|
||||||
use crate::entity::EntityBase;
|
use crate::entity::EntityBase;
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
use crate::world::portal::nether::NetherPortal;
|
use crate::world::portal::nether::NetherPortal;
|
||||||
@ -35,7 +33,7 @@ impl NetherPortalBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for NetherPortalBlock {
|
impl BlockBehaviour for NetherPortalBlock {
|
||||||
async fn get_state_for_neighbor_update(
|
async fn get_state_for_neighbor_update(
|
||||||
&self,
|
&self,
|
||||||
args: GetStateForNeighborUpdateArgs<'_>,
|
args: GetStateForNeighborUpdateArgs<'_>,
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
use crate::block::pumpkin_block::{
|
use crate::block::registry::BlockActionResult;
|
||||||
|
use crate::block::{
|
||||||
GetStateForNeighborUpdateArgs, NormalUseArgs, OnNeighborUpdateArgs, OnPlaceArgs,
|
GetStateForNeighborUpdateArgs, NormalUseArgs, OnNeighborUpdateArgs, OnPlaceArgs,
|
||||||
UseWithItemArgs,
|
UseWithItemArgs,
|
||||||
};
|
};
|
||||||
use crate::block::registry::BlockActionResult;
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::block_properties::Axis;
|
use pumpkin_data::block_properties::Axis;
|
||||||
use pumpkin_data::sound::{Sound, SoundCategory};
|
use pumpkin_data::sound::{Sound, SoundCategory};
|
||||||
@ -18,7 +18,7 @@ use pumpkin_world::BlockStateId;
|
|||||||
use pumpkin_world::world::BlockFlags;
|
use pumpkin_world::world::BlockFlags;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
block::pumpkin_block::{OnSyncedBlockEventArgs, PumpkinBlock},
|
block::{BlockBehaviour, OnSyncedBlockEventArgs},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ impl NoteBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for NoteBlock {
|
impl BlockBehaviour for NoteBlock {
|
||||||
async fn on_neighbor_update(&self, args: OnNeighborUpdateArgs<'_>) {
|
async fn on_neighbor_update(&self, args: OnNeighborUpdateArgs<'_>) {
|
||||||
let block_state = args.world.get_block_state(args.position).await;
|
let block_state = args.world.get_block_state(args.position).await;
|
||||||
let mut note_props = NoteBlockLikeProperties::from_state_id(block_state.id, args.block);
|
let mut note_props = NoteBlockLikeProperties::from_state_id(block_state.id, args.block);
|
||||||
|
|||||||
@ -18,9 +18,9 @@ use pumpkin_world::{
|
|||||||
use crate::{
|
use crate::{
|
||||||
block::{
|
block::{
|
||||||
blocks::redstone::is_emitting_redstone_power,
|
blocks::redstone::is_emitting_redstone_power,
|
||||||
pumpkin_block::{
|
{
|
||||||
BlockMetadata, OnNeighborUpdateArgs, OnPlaceArgs, OnSyncedBlockEventArgs, PlacedArgs,
|
BlockBehaviour, BlockMetadata, OnNeighborUpdateArgs, OnPlaceArgs,
|
||||||
PumpkinBlock,
|
OnSyncedBlockEventArgs, PlacedArgs,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
world::World,
|
world::World,
|
||||||
@ -85,7 +85,7 @@ impl PistonBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for PistonBlock {
|
impl BlockBehaviour for PistonBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut props = PistonProps::default(args.block);
|
let mut props = PistonProps::default(args.block);
|
||||||
props.extended = false;
|
props.extended = false;
|
||||||
|
|||||||
@ -4,8 +4,8 @@ use pumpkin_data::{Block, FacingExt};
|
|||||||
use pumpkin_macros::pumpkin_block;
|
use pumpkin_macros::pumpkin_block;
|
||||||
use pumpkin_world::world::BlockFlags;
|
use pumpkin_world::world::BlockFlags;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::BrokenArgs;
|
use crate::block::BlockBehaviour;
|
||||||
use crate::block::pumpkin_block::PumpkinBlock;
|
use crate::block::BrokenArgs;
|
||||||
|
|
||||||
use super::piston::PistonProps;
|
use super::piston::PistonProps;
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ pub(crate) type MovingPistonProps = pumpkin_data::block_properties::MovingPiston
|
|||||||
pub struct PistonExtensionBlock;
|
pub struct PistonExtensionBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for PistonExtensionBlock {
|
impl BlockBehaviour for PistonExtensionBlock {
|
||||||
async fn broken(&self, args: BrokenArgs<'_>) {
|
async fn broken(&self, args: BrokenArgs<'_>) {
|
||||||
let props = MovingPistonProps::from_state_id(args.state.id, &Block::MOVING_PISTON);
|
let props = MovingPistonProps::from_state_id(args.state.id, &Block::MOVING_PISTON);
|
||||||
let pos = args
|
let pos = args
|
||||||
|
|||||||
@ -4,8 +4,8 @@ use pumpkin_data::{Block, FacingExt};
|
|||||||
use pumpkin_macros::pumpkin_block;
|
use pumpkin_macros::pumpkin_block;
|
||||||
use pumpkin_world::world::BlockFlags;
|
use pumpkin_world::world::BlockFlags;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::BrokenArgs;
|
use crate::block::BlockBehaviour;
|
||||||
use crate::block::pumpkin_block::PumpkinBlock;
|
use crate::block::BrokenArgs;
|
||||||
|
|
||||||
use super::piston::PistonProps;
|
use super::piston::PistonProps;
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ pub(crate) type PistonHeadProperties = pumpkin_data::block_properties::PistonHea
|
|||||||
pub struct PistonHeadBlock;
|
pub struct PistonHeadBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for PistonHeadBlock {
|
impl BlockBehaviour for PistonHeadBlock {
|
||||||
async fn broken(&self, args: BrokenArgs<'_>) {
|
async fn broken(&self, args: BrokenArgs<'_>) {
|
||||||
let props = PistonHeadProperties::from_state_id(args.state.id, &Block::PISTON_HEAD);
|
let props = PistonHeadProperties::from_state_id(args.state.id, &Block::PISTON_HEAD);
|
||||||
let pos = args
|
let pos = args
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use async_trait::async_trait;
|
|||||||
use pumpkin_data::Block;
|
use pumpkin_data::Block;
|
||||||
|
|
||||||
use crate::block::blocks::plant::PlantBlockBase;
|
use crate::block::blocks::plant::PlantBlockBase;
|
||||||
use crate::block::pumpkin_block::{BlockMetadata, CanPlaceAtArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, BlockMetadata, CanPlaceAtArgs};
|
||||||
|
|
||||||
pub struct BushBlock;
|
pub struct BushBlock;
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ impl BlockMetadata for BushBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for BushBlock {
|
impl BlockBehaviour for BushBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
<Self as PlantBlockBase>::can_place_at(self, args.block_accessor, args.position).await
|
<Self as PlantBlockBase>::can_place_at(self, args.block_accessor, args.position).await
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,9 +9,7 @@ use rand::Rng;
|
|||||||
|
|
||||||
use crate::block::blocks::plant::PlantBlockBase;
|
use crate::block::blocks::plant::PlantBlockBase;
|
||||||
use crate::block::blocks::plant::crop::CropBlockBase;
|
use crate::block::blocks::plant::crop::CropBlockBase;
|
||||||
use crate::block::pumpkin_block::{
|
use crate::block::{BlockBehaviour, CanPlaceAtArgs, GetStateForNeighborUpdateArgs, RandomTickArgs};
|
||||||
CanPlaceAtArgs, GetStateForNeighborUpdateArgs, PumpkinBlock, RandomTickArgs,
|
|
||||||
};
|
|
||||||
|
|
||||||
type BeetrootProperties = NetherWartLikeProperties;
|
type BeetrootProperties = NetherWartLikeProperties;
|
||||||
|
|
||||||
@ -19,7 +17,7 @@ type BeetrootProperties = NetherWartLikeProperties;
|
|||||||
pub struct BeetrootBlock;
|
pub struct BeetrootBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for BeetrootBlock {
|
impl BlockBehaviour for BeetrootBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
<Self as CropBlockBase>::can_plant_on_top(self, args.block_accessor, &args.position.down())
|
<Self as CropBlockBase>::can_plant_on_top(self, args.block_accessor, &args.position.down())
|
||||||
.await
|
.await
|
||||||
|
|||||||
@ -4,15 +4,13 @@ use pumpkin_world::BlockStateId;
|
|||||||
|
|
||||||
use crate::block::blocks::plant::PlantBlockBase;
|
use crate::block::blocks::plant::PlantBlockBase;
|
||||||
use crate::block::blocks::plant::crop::CropBlockBase;
|
use crate::block::blocks::plant::crop::CropBlockBase;
|
||||||
use crate::block::pumpkin_block::{
|
use crate::block::{BlockBehaviour, CanPlaceAtArgs, GetStateForNeighborUpdateArgs, RandomTickArgs};
|
||||||
CanPlaceAtArgs, GetStateForNeighborUpdateArgs, PumpkinBlock, RandomTickArgs,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[pumpkin_block("minecraft:carrots")]
|
#[pumpkin_block("minecraft:carrots")]
|
||||||
pub struct CarrotBlock;
|
pub struct CarrotBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for CarrotBlock {
|
impl BlockBehaviour for CarrotBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
<Self as CropBlockBase>::can_plant_on_top(self, args.block_accessor, &args.position.down())
|
<Self as CropBlockBase>::can_plant_on_top(self, args.block_accessor, &args.position.down())
|
||||||
.await
|
.await
|
||||||
|
|||||||
@ -4,15 +4,13 @@ use pumpkin_world::BlockStateId;
|
|||||||
|
|
||||||
use crate::block::blocks::plant::PlantBlockBase;
|
use crate::block::blocks::plant::PlantBlockBase;
|
||||||
use crate::block::blocks::plant::crop::CropBlockBase;
|
use crate::block::blocks::plant::crop::CropBlockBase;
|
||||||
use crate::block::pumpkin_block::{
|
use crate::block::{BlockBehaviour, CanPlaceAtArgs, GetStateForNeighborUpdateArgs, RandomTickArgs};
|
||||||
CanPlaceAtArgs, GetStateForNeighborUpdateArgs, PumpkinBlock, RandomTickArgs,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[pumpkin_block("minecraft:potatoes")]
|
#[pumpkin_block("minecraft:potatoes")]
|
||||||
pub struct PotatoBlock;
|
pub struct PotatoBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for PotatoBlock {
|
impl BlockBehaviour for PotatoBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
<Self as CropBlockBase>::can_plant_on_top(self, args.block_accessor, &args.position.down())
|
<Self as CropBlockBase>::can_plant_on_top(self, args.block_accessor, &args.position.down())
|
||||||
.await
|
.await
|
||||||
|
|||||||
@ -9,9 +9,7 @@ use rand::Rng;
|
|||||||
|
|
||||||
use crate::block::blocks::plant::PlantBlockBase;
|
use crate::block::blocks::plant::PlantBlockBase;
|
||||||
use crate::block::blocks::plant::crop::CropBlockBase;
|
use crate::block::blocks::plant::crop::CropBlockBase;
|
||||||
use crate::block::pumpkin_block::{
|
use crate::block::{BlockBehaviour, CanPlaceAtArgs, GetStateForNeighborUpdateArgs, RandomTickArgs};
|
||||||
CanPlaceAtArgs, GetStateForNeighborUpdateArgs, PumpkinBlock, RandomTickArgs,
|
|
||||||
};
|
|
||||||
|
|
||||||
type TorchFlowerProperties = TorchflowerCropLikeProperties;
|
type TorchFlowerProperties = TorchflowerCropLikeProperties;
|
||||||
|
|
||||||
@ -19,7 +17,7 @@ type TorchFlowerProperties = TorchflowerCropLikeProperties;
|
|||||||
pub struct TorchFlowerBlock;
|
pub struct TorchFlowerBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for TorchFlowerBlock {
|
impl BlockBehaviour for TorchFlowerBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
<Self as CropBlockBase>::can_plant_on_top(self, args.block_accessor, &args.position.down())
|
<Self as CropBlockBase>::can_plant_on_top(self, args.block_accessor, &args.position.down())
|
||||||
.await
|
.await
|
||||||
|
|||||||
@ -4,15 +4,13 @@ use pumpkin_world::BlockStateId;
|
|||||||
|
|
||||||
use crate::block::blocks::plant::PlantBlockBase;
|
use crate::block::blocks::plant::PlantBlockBase;
|
||||||
use crate::block::blocks::plant::crop::CropBlockBase;
|
use crate::block::blocks::plant::crop::CropBlockBase;
|
||||||
use crate::block::pumpkin_block::{
|
use crate::block::{BlockBehaviour, CanPlaceAtArgs, GetStateForNeighborUpdateArgs, RandomTickArgs};
|
||||||
CanPlaceAtArgs, GetStateForNeighborUpdateArgs, PumpkinBlock, RandomTickArgs,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[pumpkin_block("minecraft:wheat")]
|
#[pumpkin_block("minecraft:wheat")]
|
||||||
pub struct WheatBlock;
|
pub struct WheatBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for WheatBlock {
|
impl BlockBehaviour for WheatBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
<Self as CropBlockBase>::can_plant_on_top(self, args.block_accessor, &args.position.down())
|
<Self as CropBlockBase>::can_plant_on_top(self, args.block_accessor, &args.position.down())
|
||||||
.await
|
.await
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use async_trait::async_trait;
|
|||||||
use pumpkin_data::tag;
|
use pumpkin_data::tag;
|
||||||
use pumpkin_data::tag::Taggable;
|
use pumpkin_data::tag::Taggable;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{BlockMetadata, CanPlaceAtArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, BlockMetadata, CanPlaceAtArgs};
|
||||||
|
|
||||||
pub struct DryVegetationBlock;
|
pub struct DryVegetationBlock;
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ impl BlockMetadata for DryVegetationBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for DryVegetationBlock {
|
impl BlockBehaviour for DryVegetationBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
let block_below = args.block_accessor.get_block(&args.position.down()).await;
|
let block_below = args.block_accessor.get_block(&args.position.down()).await;
|
||||||
block_below.is_tagged_with_by_tag(&tag::Block::MINECRAFT_DRY_VEGETATION_MAY_PLACE_ON)
|
block_below.is_tagged_with_by_tag(&tag::Block::MINECRAFT_DRY_VEGETATION_MAY_PLACE_ON)
|
||||||
|
|||||||
@ -6,11 +6,9 @@ use pumpkin_world::BlockStateId;
|
|||||||
use pumpkin_world::world::BlockFlags;
|
use pumpkin_world::world::BlockFlags;
|
||||||
|
|
||||||
use crate::block::blocks::plant::PlantBlockBase;
|
use crate::block::blocks::plant::PlantBlockBase;
|
||||||
use crate::block::pumpkin_block::{
|
use crate::block::{BlockBehaviour, BlockMetadata, CanPlaceAtArgs, GetStateForNeighborUpdateArgs};
|
||||||
BlockMetadata, CanPlaceAtArgs, GetStateForNeighborUpdateArgs, PumpkinBlock,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::block::pumpkin_block::RandomTickArgs;
|
use crate::block::RandomTickArgs;
|
||||||
|
|
||||||
pub struct FlowerBlock;
|
pub struct FlowerBlock;
|
||||||
|
|
||||||
@ -25,7 +23,7 @@ impl BlockMetadata for FlowerBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for FlowerBlock {
|
impl BlockBehaviour for FlowerBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
<Self as PlantBlockBase>::can_place_at(self, args.block_accessor, args.position).await
|
<Self as PlantBlockBase>::can_place_at(self, args.block_accessor, args.position).await
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,9 +5,9 @@ use pumpkin_world::BlockStateId;
|
|||||||
|
|
||||||
use crate::block::blocks::plant::PlantBlockBase;
|
use crate::block::blocks::plant::PlantBlockBase;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{
|
use crate::block::{
|
||||||
BlockMetadata, CanPlaceAtArgs, CanUpdateAtArgs, GetStateForNeighborUpdateArgs, OnPlaceArgs,
|
BlockBehaviour, BlockMetadata, CanPlaceAtArgs, CanUpdateAtArgs, GetStateForNeighborUpdateArgs,
|
||||||
PumpkinBlock,
|
OnPlaceArgs,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::segmented::Segmented;
|
use super::segmented::Segmented;
|
||||||
@ -27,7 +27,7 @@ impl BlockMetadata for FlowerbedBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for FlowerbedBlock {
|
impl BlockBehaviour for FlowerbedBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
let block_below = args.block_accessor.get_block(&args.position.down()).await;
|
let block_below = args.block_accessor.get_block(&args.position.down()).await;
|
||||||
block_below.is_tagged_with_by_tag(&tag::Block::MINECRAFT_DIRT)
|
block_below.is_tagged_with_by_tag(&tag::Block::MINECRAFT_DIRT)
|
||||||
|
|||||||
@ -2,9 +2,9 @@ use async_trait::async_trait;
|
|||||||
use pumpkin_data::{Block, BlockDirection};
|
use pumpkin_data::{Block, BlockDirection};
|
||||||
use pumpkin_world::BlockStateId;
|
use pumpkin_world::BlockStateId;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{
|
use crate::block::{
|
||||||
BlockMetadata, CanPlaceAtArgs, CanUpdateAtArgs, GetStateForNeighborUpdateArgs, OnPlaceArgs,
|
BlockBehaviour, BlockMetadata, CanPlaceAtArgs, CanUpdateAtArgs, GetStateForNeighborUpdateArgs,
|
||||||
PumpkinBlock,
|
OnPlaceArgs,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::segmented::Segmented;
|
use super::segmented::Segmented;
|
||||||
@ -24,7 +24,7 @@ impl BlockMetadata for LeafLitterBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for LeafLitterBlock {
|
impl BlockBehaviour for LeafLitterBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
let block_below = args
|
let block_below = args
|
||||||
.block_accessor
|
.block_accessor
|
||||||
|
|||||||
@ -7,15 +7,15 @@ use pumpkin_world::{
|
|||||||
world::{BlockAccessor, BlockFlags},
|
world::{BlockAccessor, BlockFlags},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::block::{blocks::plant::PlantBlockBase, pumpkin_block::GetStateForNeighborUpdateArgs};
|
use crate::block::{GetStateForNeighborUpdateArgs, blocks::plant::PlantBlockBase};
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{CanPlaceAtArgs, OnEntityCollisionArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, CanPlaceAtArgs, OnEntityCollisionArgs};
|
||||||
|
|
||||||
#[pumpkin_block("minecraft:lily_pad")]
|
#[pumpkin_block("minecraft:lily_pad")]
|
||||||
pub struct LilyPadBlock;
|
pub struct LilyPadBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for LilyPadBlock {
|
impl BlockBehaviour for LilyPadBlock {
|
||||||
async fn on_entity_collision(&self, args: OnEntityCollisionArgs<'_>) {
|
async fn on_entity_collision(&self, args: OnEntityCollisionArgs<'_>) {
|
||||||
// Proberbly not the best solution, but works
|
// Proberbly not the best solution, but works
|
||||||
if args
|
if args
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use async_trait::async_trait;
|
|||||||
use pumpkin_data::tag;
|
use pumpkin_data::tag;
|
||||||
use pumpkin_data::tag::Taggable;
|
use pumpkin_data::tag::Taggable;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{BlockMetadata, CanPlaceAtArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, BlockMetadata, CanPlaceAtArgs};
|
||||||
|
|
||||||
pub struct MushroomPlantBlock;
|
pub struct MushroomPlantBlock;
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ impl BlockMetadata for MushroomPlantBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for MushroomPlantBlock {
|
impl BlockBehaviour for MushroomPlantBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
let block_below = args.block_accessor.get_block(&args.position.down()).await;
|
let block_below = args.block_accessor.get_block(&args.position.down()).await;
|
||||||
if block_below.is_tagged_with_by_tag(&tag::Block::MINECRAFT_MUSHROOM_GROW_BLOCK) {
|
if block_below.is_tagged_with_by_tag(&tag::Block::MINECRAFT_MUSHROOM_GROW_BLOCK) {
|
||||||
|
|||||||
@ -6,13 +6,13 @@ use pumpkin_world::BlockStateId;
|
|||||||
use pumpkin_world::world::BlockAccessor;
|
use pumpkin_world::world::BlockAccessor;
|
||||||
|
|
||||||
use crate::block::blocks::plant::PlantBlockBase;
|
use crate::block::blocks::plant::PlantBlockBase;
|
||||||
use crate::block::pumpkin_block::{CanPlaceAtArgs, GetStateForNeighborUpdateArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, CanPlaceAtArgs, GetStateForNeighborUpdateArgs};
|
||||||
|
|
||||||
#[pumpkin_block("minecraft:nether_wart")]
|
#[pumpkin_block("minecraft:nether_wart")]
|
||||||
pub struct NetherWartBlock;
|
pub struct NetherWartBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for NetherWartBlock {
|
impl BlockBehaviour for NetherWartBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
<Self as PlantBlockBase>::can_place_at(self, args.block_accessor, args.position).await
|
<Self as PlantBlockBase>::can_place_at(self, args.block_accessor, args.position).await
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use async_trait::async_trait;
|
|||||||
use pumpkin_data::tag::Taggable;
|
use pumpkin_data::tag::Taggable;
|
||||||
use pumpkin_data::{Block, tag};
|
use pumpkin_data::{Block, tag};
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{BlockMetadata, CanPlaceAtArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, BlockMetadata, CanPlaceAtArgs};
|
||||||
|
|
||||||
pub struct RootsBlock;
|
pub struct RootsBlock;
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ impl BlockMetadata for RootsBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for RootsBlock {
|
impl BlockBehaviour for RootsBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
let block_below = args.block_accessor.get_block(&args.position.down()).await;
|
let block_below = args.block_accessor.get_block(&args.position.down()).await;
|
||||||
block_below.is_tagged_with_by_tag(&tag::Block::MINECRAFT_NYLIUM)
|
block_below.is_tagged_with_by_tag(&tag::Block::MINECRAFT_NYLIUM)
|
||||||
|
|||||||
@ -8,9 +8,7 @@ use pumpkin_world::world::BlockFlags;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::block::blocks::plant::PlantBlockBase;
|
use crate::block::blocks::plant::PlantBlockBase;
|
||||||
use crate::block::pumpkin_block::{
|
use crate::block::{BlockBehaviour, CanPlaceAtArgs, GetStateForNeighborUpdateArgs, RandomTickArgs};
|
||||||
CanPlaceAtArgs, GetStateForNeighborUpdateArgs, PumpkinBlock, RandomTickArgs,
|
|
||||||
};
|
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
|
|
||||||
type SaplingProperties = pumpkin_data::block_properties::OakSaplingLikeProperties;
|
type SaplingProperties = pumpkin_data::block_properties::OakSaplingLikeProperties;
|
||||||
@ -34,7 +32,7 @@ impl SaplingBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for SaplingBlock {
|
impl BlockBehaviour for SaplingBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
<Self as PlantBlockBase>::can_place_at(self, args.block_accessor, args.position).await
|
<Self as PlantBlockBase>::can_place_at(self, args.block_accessor, args.position).await
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,14 +5,14 @@ use pumpkin_world::BlockStateId;
|
|||||||
|
|
||||||
use crate::block::{
|
use crate::block::{
|
||||||
blocks::plant::PlantBlockBase,
|
blocks::plant::PlantBlockBase,
|
||||||
pumpkin_block::{CanPlaceAtArgs, GetStateForNeighborUpdateArgs, PumpkinBlock},
|
{BlockBehaviour, CanPlaceAtArgs, GetStateForNeighborUpdateArgs},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[pumpkin_block("minecraft:seagrass")]
|
#[pumpkin_block("minecraft:seagrass")]
|
||||||
pub struct SeaGrassBlock;
|
pub struct SeaGrassBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for SeaGrassBlock {
|
impl BlockBehaviour for SeaGrassBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
<Self as PlantBlockBase>::can_place_at(self, args.block_accessor, args.position).await
|
<Self as PlantBlockBase>::can_place_at(self, args.block_accessor, args.position).await
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
use crate::block::BlockIsReplacing;
|
use crate::block::BlockIsReplacing;
|
||||||
use crate::block::blocks::plant::PlantBlockBase;
|
use crate::block::blocks::plant::PlantBlockBase;
|
||||||
use crate::block::pumpkin_block::{
|
use crate::block::registry::BlockActionResult;
|
||||||
CanPlaceAtArgs, CanUpdateAtArgs, GetStateForNeighborUpdateArgs, OnPlaceArgs, PumpkinBlock,
|
use crate::block::{
|
||||||
|
BlockBehaviour, CanPlaceAtArgs, CanUpdateAtArgs, GetStateForNeighborUpdateArgs, OnPlaceArgs,
|
||||||
UseWithItemArgs,
|
UseWithItemArgs,
|
||||||
};
|
};
|
||||||
use crate::block::registry::BlockActionResult;
|
|
||||||
use crate::entity::EntityBase;
|
use crate::entity::EntityBase;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::block_properties::{BlockProperties, Integer1To4};
|
use pumpkin_data::block_properties::{BlockProperties, Integer1To4};
|
||||||
@ -24,7 +24,7 @@ type SeaPickleProperties = pumpkin_data::block_properties::SeaPickleLikeProperti
|
|||||||
pub struct SeaPickleBlock;
|
pub struct SeaPickleBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for SeaPickleBlock {
|
impl BlockBehaviour for SeaPickleBlock {
|
||||||
#[allow(clippy::many_single_char_names)]
|
#[allow(clippy::many_single_char_names)]
|
||||||
async fn use_with_item(&self, args: UseWithItemArgs<'_>) -> BlockActionResult {
|
async fn use_with_item(&self, args: UseWithItemArgs<'_>) -> BlockActionResult {
|
||||||
if args.item_stack.lock().await.item != &Item::BONE_MEAL
|
if args.item_stack.lock().await.item != &Item::BONE_MEAL
|
||||||
|
|||||||
@ -2,8 +2,8 @@ use async_trait::async_trait;
|
|||||||
use pumpkin_data::block_properties::{BlockProperties, HorizontalFacing, Integer1To4};
|
use pumpkin_data::block_properties::{BlockProperties, HorizontalFacing, Integer1To4};
|
||||||
use pumpkin_world::BlockStateId;
|
use pumpkin_world::BlockStateId;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{CanUpdateAtArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, CanUpdateAtArgs};
|
||||||
use crate::block::{BlockIsReplacing, pumpkin_block::OnPlaceArgs};
|
use crate::block::{BlockIsReplacing, OnPlaceArgs};
|
||||||
|
|
||||||
pub trait SegmentProperties {
|
pub trait SegmentProperties {
|
||||||
fn get_segment_amount(&self) -> Integer1To4;
|
fn get_segment_amount(&self) -> Integer1To4;
|
||||||
@ -44,7 +44,7 @@ impl_segment_properties!(
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait Segmented: PumpkinBlock {
|
pub trait Segmented: BlockBehaviour {
|
||||||
type Properties: BlockProperties + SegmentProperties;
|
type Properties: BlockProperties + SegmentProperties;
|
||||||
|
|
||||||
fn can_add_segment(&self, props: &Self::Properties) -> bool {
|
fn can_add_segment(&self, props: &Self::Properties) -> bool {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use async_trait::async_trait;
|
|||||||
use pumpkin_data::tag::Taggable;
|
use pumpkin_data::tag::Taggable;
|
||||||
use pumpkin_data::{Block, tag};
|
use pumpkin_data::{Block, tag};
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{BlockMetadata, CanPlaceAtArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, BlockMetadata, CanPlaceAtArgs};
|
||||||
|
|
||||||
pub struct ShortPlantBlock;
|
pub struct ShortPlantBlock;
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ impl BlockMetadata for ShortPlantBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for ShortPlantBlock {
|
impl BlockBehaviour for ShortPlantBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
let block_below = args.block_accessor.get_block(&args.position.down()).await;
|
let block_below = args.block_accessor.get_block(&args.position.down()).await;
|
||||||
block_below.is_tagged_with_by_tag(&tag::Block::MINECRAFT_DIRT)
|
block_below.is_tagged_with_by_tag(&tag::Block::MINECRAFT_DIRT)
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use async_trait::async_trait;
|
|||||||
use pumpkin_data::tag::Taggable;
|
use pumpkin_data::tag::Taggable;
|
||||||
use pumpkin_data::{Block, tag};
|
use pumpkin_data::{Block, tag};
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{BlockMetadata, CanPlaceAtArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, BlockMetadata, CanPlaceAtArgs};
|
||||||
|
|
||||||
pub struct TallPlantBlock;
|
pub struct TallPlantBlock;
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ impl BlockMetadata for TallPlantBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for TallPlantBlock {
|
impl BlockBehaviour for TallPlantBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
let (block, state) = args.block_accessor.get_block_and_state(args.position).await;
|
let (block, state) = args.block_accessor.get_block_and_state(args.position).await;
|
||||||
if let Some(props) = block.properties(state.id).map(|s| s.to_props()) {
|
if let Some(props) = block.properties(state.id).map(|s| s.to_props()) {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use crate::block::pumpkin_block::UseWithItemArgs;
|
use crate::block::UseWithItemArgs;
|
||||||
use crate::block::registry::BlockActionResult;
|
use crate::block::registry::BlockActionResult;
|
||||||
use crate::entity::Entity;
|
use crate::entity::Entity;
|
||||||
use crate::entity::item::ItemEntity;
|
use crate::entity::item::ItemEntity;
|
||||||
@ -16,7 +16,7 @@ use uuid::Uuid;
|
|||||||
pub struct PumpkinBlock;
|
pub struct PumpkinBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl crate::block::pumpkin_block::PumpkinBlock for PumpkinBlock {
|
impl crate::block::BlockBehaviour for PumpkinBlock {
|
||||||
async fn use_with_item(&self, args: UseWithItemArgs<'_>) -> BlockActionResult {
|
async fn use_with_item(&self, args: UseWithItemArgs<'_>) -> BlockActionResult {
|
||||||
if args.item_stack.lock().await.item != &Item::SHEARS {
|
if args.item_stack.lock().await.item != &Item::SHEARS {
|
||||||
return BlockActionResult::Pass;
|
return BlockActionResult::Pass;
|
||||||
|
|||||||
@ -16,9 +16,7 @@ use pumpkin_world::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
block::pumpkin_block::{
|
block::{GetRedstonePowerArgs, OnNeighborUpdateArgs, OnStateReplacedArgs, PlayerPlacedArgs},
|
||||||
GetRedstonePowerArgs, OnNeighborUpdateArgs, OnStateReplacedArgs, PlayerPlacedArgs,
|
|
||||||
},
|
|
||||||
entity::player::Player,
|
entity::player::Player,
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -16,17 +16,17 @@ use pumpkin_world::world::BlockFlags;
|
|||||||
|
|
||||||
type ButtonLikeProperties = pumpkin_data::block_properties::LeverLikeProperties;
|
type ButtonLikeProperties = pumpkin_data::block_properties::LeverLikeProperties;
|
||||||
|
|
||||||
|
use crate::block::CanPlaceAtArgs;
|
||||||
|
use crate::block::EmitsRedstonePowerArgs;
|
||||||
|
use crate::block::GetRedstonePowerArgs;
|
||||||
|
use crate::block::GetStateForNeighborUpdateArgs;
|
||||||
|
use crate::block::OnPlaceArgs;
|
||||||
|
use crate::block::OnScheduledTickArgs;
|
||||||
|
use crate::block::OnStateReplacedArgs;
|
||||||
use crate::block::blocks::abstruct_wall_mounting::WallMountedBlock;
|
use crate::block::blocks::abstruct_wall_mounting::WallMountedBlock;
|
||||||
use crate::block::blocks::redstone::lever::LeverLikePropertiesExt;
|
use crate::block::blocks::redstone::lever::LeverLikePropertiesExt;
|
||||||
use crate::block::pumpkin_block::CanPlaceAtArgs;
|
|
||||||
use crate::block::pumpkin_block::EmitsRedstonePowerArgs;
|
|
||||||
use crate::block::pumpkin_block::GetRedstonePowerArgs;
|
|
||||||
use crate::block::pumpkin_block::GetStateForNeighborUpdateArgs;
|
|
||||||
use crate::block::pumpkin_block::OnPlaceArgs;
|
|
||||||
use crate::block::pumpkin_block::OnScheduledTickArgs;
|
|
||||||
use crate::block::pumpkin_block::OnStateReplacedArgs;
|
|
||||||
use crate::block::pumpkin_block::{NormalUseArgs, PumpkinBlock};
|
|
||||||
use crate::block::registry::BlockActionResult;
|
use crate::block::registry::BlockActionResult;
|
||||||
|
use crate::block::{BlockBehaviour, NormalUseArgs};
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
|
|
||||||
async fn click_button(world: &Arc<World>, block_pos: &BlockPos) {
|
async fn click_button(world: &Arc<World>, block_pos: &BlockPos) {
|
||||||
@ -58,7 +58,7 @@ async fn click_button(world: &Arc<World>, block_pos: &BlockPos) {
|
|||||||
pub struct ButtonBlock;
|
pub struct ButtonBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for ButtonBlock {
|
impl BlockBehaviour for ButtonBlock {
|
||||||
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
||||||
click_button(args.world, args.position).await;
|
click_button(args.world, args.position).await;
|
||||||
|
|
||||||
|
|||||||
@ -17,13 +17,13 @@ use pumpkin_world::{
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
block::{
|
block::{
|
||||||
pumpkin_block::{
|
|
||||||
BrokenArgs, CanPlaceAtArgs, EmitsRedstonePowerArgs, GetComparatorOutputArgs,
|
|
||||||
GetRedstonePowerArgs, GetStateForNeighborUpdateArgs, NormalUseArgs,
|
|
||||||
OnNeighborUpdateArgs, OnPlaceArgs, OnScheduledTickArgs, OnStateReplacedArgs,
|
|
||||||
PlacedArgs, PlayerPlacedArgs, PumpkinBlock,
|
|
||||||
},
|
|
||||||
registry::BlockActionResult,
|
registry::BlockActionResult,
|
||||||
|
{
|
||||||
|
BlockBehaviour, BrokenArgs, CanPlaceAtArgs, EmitsRedstonePowerArgs,
|
||||||
|
GetComparatorOutputArgs, GetRedstonePowerArgs, GetStateForNeighborUpdateArgs,
|
||||||
|
NormalUseArgs, OnNeighborUpdateArgs, OnPlaceArgs, OnScheduledTickArgs,
|
||||||
|
OnStateReplacedArgs, PlacedArgs, PlayerPlacedArgs,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
@ -34,7 +34,7 @@ use super::abstruct_redstone_gate::{self, RedstoneGateBlock, RedstoneGateBlockPr
|
|||||||
pub struct ComparatorBlock;
|
pub struct ComparatorBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for ComparatorBlock {
|
impl BlockBehaviour for ComparatorBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
RedstoneGateBlock::on_place(self, args.player, args.block).await
|
RedstoneGateBlock::on_place(self, args.player, args.block).await
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use crate::block::blocks::redstone::block_receives_redstone_power;
|
use crate::block::blocks::redstone::block_receives_redstone_power;
|
||||||
use crate::block::pumpkin_block::{BlockMetadata, OnNeighborUpdateArgs, OnPlaceArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, BlockMetadata, OnNeighborUpdateArgs, OnPlaceArgs};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::block_properties::BlockProperties;
|
use pumpkin_data::block_properties::BlockProperties;
|
||||||
use pumpkin_data::sound::{Sound, SoundCategory};
|
use pumpkin_data::sound::{Sound, SoundCategory};
|
||||||
@ -30,7 +30,7 @@ impl BlockMetadata for CopperBulbBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for CopperBulbBlock {
|
impl BlockBehaviour for CopperBulbBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut props = CopperBulbLikeProperties::default(args.block);
|
let mut props = CopperBulbLikeProperties::default(args.block);
|
||||||
let is_receiving_power = block_receives_redstone_power(args.world, args.position).await;
|
let is_receiving_power = block_receives_redstone_power(args.world, args.position).await;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use crate::block::pumpkin_block::{OnPlaceArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, OnPlaceArgs};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::block_properties::{BlockProperties, DispenserLikeProperties};
|
use pumpkin_data::block_properties::{BlockProperties, DispenserLikeProperties};
|
||||||
use pumpkin_macros::pumpkin_block;
|
use pumpkin_macros::pumpkin_block;
|
||||||
@ -8,7 +8,7 @@ use pumpkin_world::BlockStateId;
|
|||||||
pub struct DispenserBlock;
|
pub struct DispenserBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for DispenserBlock {
|
impl BlockBehaviour for DispenserBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut props = DispenserLikeProperties::default(args.block);
|
let mut props = DispenserLikeProperties::default(args.block);
|
||||||
props.facing = args.player.living_entity.entity.get_facing().opposite();
|
props.facing = args.player.living_entity.entity.get_facing().opposite();
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
use crate::block::blocks::redstone::block_receives_redstone_power;
|
use crate::block::blocks::redstone::block_receives_redstone_power;
|
||||||
use crate::block::pumpkin_block::{
|
|
||||||
NormalUseArgs, OnNeighborUpdateArgs, OnPlaceArgs, OnScheduledTickArgs, PlacedArgs, PumpkinBlock,
|
|
||||||
};
|
|
||||||
use crate::block::registry::BlockActionResult;
|
use crate::block::registry::BlockActionResult;
|
||||||
|
use crate::block::{
|
||||||
|
BlockBehaviour, NormalUseArgs, OnNeighborUpdateArgs, OnPlaceArgs, OnScheduledTickArgs,
|
||||||
|
PlacedArgs,
|
||||||
|
};
|
||||||
use crate::entity::Entity;
|
use crate::entity::Entity;
|
||||||
use crate::entity::item::ItemEntity;
|
use crate::entity::item::ItemEntity;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
@ -81,7 +82,7 @@ const fn to_data3d(facing: Facing) -> i32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for DropperBlock {
|
impl BlockBehaviour for DropperBlock {
|
||||||
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
||||||
if let Some(block_entity) = args.world.get_block_entity(args.position).await {
|
if let Some(block_entity) = args.world.get_block_entity(args.position).await {
|
||||||
if let Some(inventory) = block_entity.get_inventory() {
|
if let Some(inventory) = block_entity.get_inventory() {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use crate::block::{
|
use crate::block::{
|
||||||
blocks::abstruct_wall_mounting::WallMountedBlock,
|
blocks::abstruct_wall_mounting::WallMountedBlock,
|
||||||
pumpkin_block::{
|
{
|
||||||
CanPlaceAtArgs, EmitsRedstonePowerArgs, GetRedstonePowerArgs,
|
CanPlaceAtArgs, EmitsRedstonePowerArgs, GetRedstonePowerArgs,
|
||||||
GetStateForNeighborUpdateArgs, OnPlaceArgs, OnStateReplacedArgs,
|
GetStateForNeighborUpdateArgs, OnPlaceArgs, OnStateReplacedArgs,
|
||||||
},
|
},
|
||||||
@ -18,8 +18,8 @@ use pumpkin_world::{BlockStateId, world::BlockFlags};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
block::{
|
block::{
|
||||||
pumpkin_block::{NormalUseArgs, PumpkinBlock},
|
|
||||||
registry::BlockActionResult,
|
registry::BlockActionResult,
|
||||||
|
{BlockBehaviour, NormalUseArgs},
|
||||||
},
|
},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
@ -44,7 +44,7 @@ async fn toggle_lever(world: &Arc<World>, block_pos: &BlockPos) {
|
|||||||
pub struct LeverBlock;
|
pub struct LeverBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for LeverBlock {
|
impl BlockBehaviour for LeverBlock {
|
||||||
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
||||||
toggle_lever(args.world, args.position).await;
|
toggle_lever(args.world, args.position).await;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{
|
use crate::block::{
|
||||||
EmitsRedstonePowerArgs, GetRedstonePowerArgs, GetStateForNeighborUpdateArgs, OnPlaceArgs,
|
EmitsRedstonePowerArgs, GetRedstonePowerArgs, GetStateForNeighborUpdateArgs, OnPlaceArgs,
|
||||||
OnScheduledTickArgs, OnStateReplacedArgs,
|
OnScheduledTickArgs, OnStateReplacedArgs,
|
||||||
};
|
};
|
||||||
@ -14,7 +14,7 @@ use pumpkin_util::math::position::BlockPos;
|
|||||||
use pumpkin_world::{BlockStateId, tick::TickPriority, world::BlockFlags};
|
use pumpkin_world::{BlockStateId, tick::TickPriority, world::BlockFlags};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
block::pumpkin_block::{OnNeighborUpdateArgs, PumpkinBlock},
|
block::{BlockBehaviour, OnNeighborUpdateArgs},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ use crate::{
|
|||||||
pub struct ObserverBlock;
|
pub struct ObserverBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for ObserverBlock {
|
impl BlockBehaviour for ObserverBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut props = ObserverLikeProperties::default(args.block);
|
let mut props = ObserverLikeProperties::default(args.block);
|
||||||
props.facing = args.player.living_entity.entity.get_facing();
|
props.facing = args.player.living_entity.entity.get_facing();
|
||||||
|
|||||||
@ -5,7 +5,7 @@ use pumpkin_util::math::position::BlockPos;
|
|||||||
use pumpkin_world::{BlockStateId, tick::TickPriority, world::BlockFlags};
|
use pumpkin_world::{BlockStateId, tick::TickPriority, world::BlockFlags};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
block::pumpkin_block::{OnEntityCollisionArgs, OnScheduledTickArgs, OnStateReplacedArgs},
|
block::{OnEntityCollisionArgs, OnScheduledTickArgs, OnStateReplacedArgs},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -8,10 +8,10 @@ use pumpkin_util::math::{boundingbox::BoundingBox, position::BlockPos};
|
|||||||
use pumpkin_world::{BlockStateId, world::BlockFlags};
|
use pumpkin_world::{BlockStateId, world::BlockFlags};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
block::pumpkin_block::{
|
block::{
|
||||||
BlockMetadata, CanPlaceAtArgs, EmitsRedstonePowerArgs, GetRedstonePowerArgs,
|
BlockBehaviour, BlockMetadata, CanPlaceAtArgs, EmitsRedstonePowerArgs,
|
||||||
OnEntityCollisionArgs, OnNeighborUpdateArgs, OnScheduledTickArgs, OnStateReplacedArgs,
|
GetRedstonePowerArgs, OnEntityCollisionArgs, OnNeighborUpdateArgs, OnScheduledTickArgs,
|
||||||
PumpkinBlock,
|
OnStateReplacedArgs,
|
||||||
},
|
},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
@ -41,7 +41,7 @@ impl BlockMetadata for PressurePlateBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for PressurePlateBlock {
|
impl BlockBehaviour for PressurePlateBlock {
|
||||||
async fn on_entity_collision(&self, args: OnEntityCollisionArgs<'_>) {
|
async fn on_entity_collision(&self, args: OnEntityCollisionArgs<'_>) {
|
||||||
self.on_entity_collision_pp(args).await;
|
self.on_entity_collision_pp(args).await;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,10 +7,10 @@ use pumpkin_util::math::{boundingbox::BoundingBox, position::BlockPos};
|
|||||||
use pumpkin_world::{BlockStateId, world::BlockFlags};
|
use pumpkin_world::{BlockStateId, world::BlockFlags};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
block::pumpkin_block::{
|
block::{
|
||||||
BlockMetadata, CanPlaceAtArgs, EmitsRedstonePowerArgs, GetRedstonePowerArgs,
|
BlockBehaviour, BlockMetadata, CanPlaceAtArgs, EmitsRedstonePowerArgs,
|
||||||
OnEntityCollisionArgs, OnNeighborUpdateArgs, OnScheduledTickArgs, OnStateReplacedArgs,
|
GetRedstonePowerArgs, OnEntityCollisionArgs, OnNeighborUpdateArgs, OnScheduledTickArgs,
|
||||||
PumpkinBlock,
|
OnStateReplacedArgs,
|
||||||
},
|
},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
@ -38,7 +38,7 @@ impl BlockMetadata for WeightedPressurePlateBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for WeightedPressurePlateBlock {
|
impl BlockBehaviour for WeightedPressurePlateBlock {
|
||||||
async fn on_entity_collision(&self, args: OnEntityCollisionArgs<'_>) {
|
async fn on_entity_collision(&self, args: OnEntityCollisionArgs<'_>) {
|
||||||
self.on_entity_collision_pp(args).await;
|
self.on_entity_collision_pp(args).await;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,12 +4,12 @@ use pumpkin_world::BlockStateId;
|
|||||||
use pumpkin_world::world::BlockFlags;
|
use pumpkin_world::world::BlockFlags;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::CanPlaceAtArgs;
|
use crate::block::BlockBehaviour;
|
||||||
use crate::block::pumpkin_block::OnNeighborUpdateArgs;
|
use crate::block::CanPlaceAtArgs;
|
||||||
use crate::block::pumpkin_block::OnPlaceArgs;
|
use crate::block::OnNeighborUpdateArgs;
|
||||||
use crate::block::pumpkin_block::OnStateReplacedArgs;
|
use crate::block::OnPlaceArgs;
|
||||||
use crate::block::pumpkin_block::PlacedArgs;
|
use crate::block::OnStateReplacedArgs;
|
||||||
use crate::block::pumpkin_block::PumpkinBlock;
|
use crate::block::PlacedArgs;
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
use pumpkin_data::Block;
|
use pumpkin_data::Block;
|
||||||
use pumpkin_util::math::position::BlockPos;
|
use pumpkin_util::math::position::BlockPos;
|
||||||
@ -38,7 +38,7 @@ use super::common::{
|
|||||||
pub struct ActivatorRailBlock;
|
pub struct ActivatorRailBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for ActivatorRailBlock {
|
impl BlockBehaviour for ActivatorRailBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut rail_props = RailProperties::default(args.block);
|
let mut rail_props = RailProperties::default(args.block);
|
||||||
let player_facing = args.player.living_entity.entity.get_horizontal_facing();
|
let player_facing = args.player.living_entity.entity.get_horizontal_facing();
|
||||||
@ -179,17 +179,11 @@ impl PumpkinBlock for ActivatorRailBlock {
|
|||||||
can_place_rail_at(args.block_accessor, args.position).await
|
can_place_rail_at(args.block_accessor, args.position).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn emits_redstone_power(
|
async fn emits_redstone_power(&self, _args: crate::block::EmitsRedstonePowerArgs<'_>) -> bool {
|
||||||
&self,
|
|
||||||
_args: crate::block::pumpkin_block::EmitsRedstonePowerArgs<'_>,
|
|
||||||
) -> bool {
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_weak_redstone_power(
|
async fn get_weak_redstone_power(&self, _args: crate::block::GetRedstonePowerArgs<'_>) -> u8 {
|
||||||
&self,
|
|
||||||
_args: crate::block::pumpkin_block::GetRedstonePowerArgs<'_>,
|
|
||||||
) -> u8 {
|
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,11 +3,11 @@ use pumpkin_macros::pumpkin_block;
|
|||||||
use pumpkin_world::BlockStateId;
|
use pumpkin_world::BlockStateId;
|
||||||
use pumpkin_world::world::BlockFlags;
|
use pumpkin_world::world::BlockFlags;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::CanPlaceAtArgs;
|
use crate::block::BlockBehaviour;
|
||||||
use crate::block::pumpkin_block::OnNeighborUpdateArgs;
|
use crate::block::CanPlaceAtArgs;
|
||||||
use crate::block::pumpkin_block::OnPlaceArgs;
|
use crate::block::OnNeighborUpdateArgs;
|
||||||
use crate::block::pumpkin_block::PlacedArgs;
|
use crate::block::OnPlaceArgs;
|
||||||
use crate::block::pumpkin_block::PumpkinBlock;
|
use crate::block::PlacedArgs;
|
||||||
|
|
||||||
use super::RailProperties;
|
use super::RailProperties;
|
||||||
use super::common::{
|
use super::common::{
|
||||||
@ -19,7 +19,7 @@ use super::common::{
|
|||||||
pub struct DetectorRailBlock;
|
pub struct DetectorRailBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for DetectorRailBlock {
|
impl BlockBehaviour for DetectorRailBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut rail_props = RailProperties::default(args.block);
|
let mut rail_props = RailProperties::default(args.block);
|
||||||
let player_facing = args.player.living_entity.entity.get_horizontal_facing();
|
let player_facing = args.player.living_entity.entity.get_horizontal_facing();
|
||||||
|
|||||||
@ -4,12 +4,12 @@ use pumpkin_world::BlockStateId;
|
|||||||
use pumpkin_world::world::BlockFlags;
|
use pumpkin_world::world::BlockFlags;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::CanPlaceAtArgs;
|
use crate::block::BlockBehaviour;
|
||||||
use crate::block::pumpkin_block::OnNeighborUpdateArgs;
|
use crate::block::CanPlaceAtArgs;
|
||||||
use crate::block::pumpkin_block::OnPlaceArgs;
|
use crate::block::OnNeighborUpdateArgs;
|
||||||
use crate::block::pumpkin_block::OnStateReplacedArgs;
|
use crate::block::OnPlaceArgs;
|
||||||
use crate::block::pumpkin_block::PlacedArgs;
|
use crate::block::OnStateReplacedArgs;
|
||||||
use crate::block::pumpkin_block::PumpkinBlock;
|
use crate::block::PlacedArgs;
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
use pumpkin_data::Block;
|
use pumpkin_data::Block;
|
||||||
use pumpkin_util::math::position::BlockPos;
|
use pumpkin_util::math::position::BlockPos;
|
||||||
@ -38,7 +38,7 @@ use super::common::{
|
|||||||
pub struct PoweredRailBlock;
|
pub struct PoweredRailBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for PoweredRailBlock {
|
impl BlockBehaviour for PoweredRailBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut rail_props = RailProperties::default(args.block);
|
let mut rail_props = RailProperties::default(args.block);
|
||||||
let player_facing = args.player.living_entity.entity.get_horizontal_facing();
|
let player_facing = args.player.living_entity.entity.get_horizontal_facing();
|
||||||
@ -180,17 +180,11 @@ impl PumpkinBlock for PoweredRailBlock {
|
|||||||
can_place_rail_at(args.block_accessor, args.position).await
|
can_place_rail_at(args.block_accessor, args.position).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn emits_redstone_power(
|
async fn emits_redstone_power(&self, _args: crate::block::EmitsRedstonePowerArgs<'_>) -> bool {
|
||||||
&self,
|
|
||||||
_args: crate::block::pumpkin_block::EmitsRedstonePowerArgs<'_>,
|
|
||||||
) -> bool {
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_weak_redstone_power(
|
async fn get_weak_redstone_power(&self, _args: crate::block::GetRedstonePowerArgs<'_>) -> u8 {
|
||||||
&self,
|
|
||||||
_args: crate::block::pumpkin_block::GetRedstonePowerArgs<'_>,
|
|
||||||
) -> u8 {
|
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,11 +5,11 @@ use pumpkin_macros::pumpkin_block;
|
|||||||
use pumpkin_world::BlockStateId;
|
use pumpkin_world::BlockStateId;
|
||||||
use pumpkin_world::world::BlockFlags;
|
use pumpkin_world::world::BlockFlags;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::CanPlaceAtArgs;
|
use crate::block::BlockBehaviour;
|
||||||
use crate::block::pumpkin_block::OnNeighborUpdateArgs;
|
use crate::block::CanPlaceAtArgs;
|
||||||
use crate::block::pumpkin_block::OnPlaceArgs;
|
use crate::block::OnNeighborUpdateArgs;
|
||||||
use crate::block::pumpkin_block::PlacedArgs;
|
use crate::block::OnPlaceArgs;
|
||||||
use crate::block::pumpkin_block::PumpkinBlock;
|
use crate::block::PlacedArgs;
|
||||||
|
|
||||||
use super::StraightRailShapeExt;
|
use super::StraightRailShapeExt;
|
||||||
use super::common::{can_place_rail_at, rail_placement_is_valid, update_flanking_rails_shape};
|
use super::common::{can_place_rail_at, rail_placement_is_valid, update_flanking_rails_shape};
|
||||||
@ -19,7 +19,7 @@ use super::{HorizontalFacingRailExt, Rail, RailElevation, RailProperties};
|
|||||||
pub struct RailBlock;
|
pub struct RailBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for RailBlock {
|
impl BlockBehaviour for RailBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let world = args.world;
|
let world = args.world;
|
||||||
let block_pos = args.position;
|
let block_pos = args.position;
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_macros::pumpkin_block;
|
use pumpkin_macros::pumpkin_block;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{EmitsRedstonePowerArgs, GetRedstonePowerArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, EmitsRedstonePowerArgs, GetRedstonePowerArgs};
|
||||||
|
|
||||||
#[pumpkin_block("minecraft:redstone_block")]
|
#[pumpkin_block("minecraft:redstone_block")]
|
||||||
pub struct RedstoneBlock;
|
pub struct RedstoneBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for RedstoneBlock {
|
impl BlockBehaviour for RedstoneBlock {
|
||||||
async fn get_weak_redstone_power(&self, _args: GetRedstonePowerArgs<'_>) -> u8 {
|
async fn get_weak_redstone_power(&self, _args: GetRedstonePowerArgs<'_>) -> u8 {
|
||||||
15
|
15
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
use crate::block::pumpkin_block::{OnNeighborUpdateArgs, OnPlaceArgs, OnScheduledTickArgs};
|
use crate::block::{OnNeighborUpdateArgs, OnPlaceArgs, OnScheduledTickArgs};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::block_properties::BlockProperties;
|
use pumpkin_data::block_properties::BlockProperties;
|
||||||
use pumpkin_macros::pumpkin_block;
|
use pumpkin_macros::pumpkin_block;
|
||||||
use pumpkin_world::{BlockStateId, tick::TickPriority, world::BlockFlags};
|
use pumpkin_world::{BlockStateId, tick::TickPriority, world::BlockFlags};
|
||||||
|
|
||||||
use crate::block::pumpkin_block::PumpkinBlock;
|
use crate::block::BlockBehaviour;
|
||||||
|
|
||||||
use super::block_receives_redstone_power;
|
use super::block_receives_redstone_power;
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ type RedstoneLampProperties = pumpkin_data::block_properties::RedstoneOreLikePro
|
|||||||
pub struct RedstoneLamp;
|
pub struct RedstoneLamp;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for RedstoneLamp {
|
impl BlockBehaviour for RedstoneLamp {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut props = RedstoneLampProperties::default(args.block);
|
let mut props = RedstoneLampProperties::default(args.block);
|
||||||
props.lit = block_receives_redstone_power(args.world, args.position).await;
|
props.lit = block_receives_redstone_power(args.world, args.position).await;
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::block::BlockIsReplacing;
|
use crate::block::BlockIsReplacing;
|
||||||
use crate::block::pumpkin_block::CanPlaceAtArgs;
|
use crate::block::CanPlaceAtArgs;
|
||||||
use crate::block::pumpkin_block::EmitsRedstonePowerArgs;
|
use crate::block::EmitsRedstonePowerArgs;
|
||||||
use crate::block::pumpkin_block::GetRedstonePowerArgs;
|
use crate::block::GetRedstonePowerArgs;
|
||||||
use crate::block::pumpkin_block::GetStateForNeighborUpdateArgs;
|
use crate::block::GetStateForNeighborUpdateArgs;
|
||||||
use crate::block::pumpkin_block::OnNeighborUpdateArgs;
|
use crate::block::OnNeighborUpdateArgs;
|
||||||
use crate::block::pumpkin_block::OnPlaceArgs;
|
use crate::block::OnPlaceArgs;
|
||||||
use crate::block::pumpkin_block::OnScheduledTickArgs;
|
use crate::block::OnScheduledTickArgs;
|
||||||
use crate::block::pumpkin_block::OnStateReplacedArgs;
|
use crate::block::OnStateReplacedArgs;
|
||||||
use crate::block::pumpkin_block::PlacedArgs;
|
use crate::block::PlacedArgs;
|
||||||
use crate::entity::EntityBase;
|
use crate::entity::EntityBase;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::Block;
|
use pumpkin_data::Block;
|
||||||
@ -27,7 +27,7 @@ use pumpkin_world::world::BlockFlags;
|
|||||||
type RWallTorchProps = pumpkin_data::block_properties::FurnaceLikeProperties;
|
type RWallTorchProps = pumpkin_data::block_properties::FurnaceLikeProperties;
|
||||||
type RTorchProps = pumpkin_data::block_properties::RedstoneOreLikeProperties;
|
type RTorchProps = pumpkin_data::block_properties::RedstoneOreLikeProperties;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{BlockMetadata, PumpkinBlock};
|
use crate::block::{BlockBehaviour, BlockMetadata};
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
|
|
||||||
use super::get_redstone_power;
|
use super::get_redstone_power;
|
||||||
@ -45,7 +45,7 @@ impl BlockMetadata for RedstoneTorchBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for RedstoneTorchBlock {
|
impl BlockBehaviour for RedstoneTorchBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let world = args.world;
|
let world = args.world;
|
||||||
let block = args.block;
|
let block = args.block;
|
||||||
|
|||||||
@ -12,13 +12,13 @@ use pumpkin_util::math::position::BlockPos;
|
|||||||
use pumpkin_world::BlockStateId;
|
use pumpkin_world::BlockStateId;
|
||||||
use pumpkin_world::world::{BlockAccessor, BlockFlags};
|
use pumpkin_world::world::{BlockAccessor, BlockFlags};
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{
|
use crate::block::registry::BlockActionResult;
|
||||||
|
use crate::block::{
|
||||||
BrokenArgs, CanPlaceAtArgs, GetRedstonePowerArgs, GetStateForNeighborUpdateArgs,
|
BrokenArgs, CanPlaceAtArgs, GetRedstonePowerArgs, GetStateForNeighborUpdateArgs,
|
||||||
OnNeighborUpdateArgs, OnPlaceArgs, PlacedArgs, PrepareArgs,
|
OnNeighborUpdateArgs, OnPlaceArgs, PlacedArgs, PrepareArgs,
|
||||||
};
|
};
|
||||||
use crate::block::registry::BlockActionResult;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
block::pumpkin_block::{NormalUseArgs, PumpkinBlock},
|
block::{BlockBehaviour, NormalUseArgs},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ type RedstoneWireProperties = RedstoneWireLikeProperties;
|
|||||||
pub struct RedstoneWireBlock;
|
pub struct RedstoneWireBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for RedstoneWireBlock {
|
impl BlockBehaviour for RedstoneWireBlock {
|
||||||
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
async fn can_place_at(&self, args: CanPlaceAtArgs<'_>) -> bool {
|
||||||
can_place_at(args.block_accessor, args.position).await
|
can_place_at(args.block_accessor, args.position).await
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,12 +12,12 @@ use pumpkin_world::{BlockStateId, tick::TickPriority};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
block::{
|
block::{
|
||||||
pumpkin_block::{
|
|
||||||
CanPlaceAtArgs, EmitsRedstonePowerArgs, GetRedstonePowerArgs,
|
|
||||||
GetStateForNeighborUpdateArgs, NormalUseArgs, OnNeighborUpdateArgs, OnPlaceArgs,
|
|
||||||
OnScheduledTickArgs, OnStateReplacedArgs, PlacedArgs, PlayerPlacedArgs, PumpkinBlock,
|
|
||||||
},
|
|
||||||
registry::BlockActionResult,
|
registry::BlockActionResult,
|
||||||
|
{
|
||||||
|
BlockBehaviour, CanPlaceAtArgs, EmitsRedstonePowerArgs, GetRedstonePowerArgs,
|
||||||
|
GetStateForNeighborUpdateArgs, NormalUseArgs, OnNeighborUpdateArgs, OnPlaceArgs,
|
||||||
|
OnScheduledTickArgs, OnStateReplacedArgs, PlacedArgs, PlayerPlacedArgs,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
@ -30,7 +30,7 @@ type RepeaterProperties = pumpkin_data::block_properties::RepeaterLikeProperties
|
|||||||
pub struct RepeaterBlock;
|
pub struct RepeaterBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for RepeaterBlock {
|
impl BlockBehaviour for RepeaterBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let state_id = RedstoneGateBlock::on_place(self, args.player, args.block).await;
|
let state_id = RedstoneGateBlock::on_place(self, args.player, args.block).await;
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_macros::pumpkin_block;
|
use pumpkin_macros::pumpkin_block;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{EmitsRedstonePowerArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, EmitsRedstonePowerArgs};
|
||||||
|
|
||||||
#[pumpkin_block("minecraft:target")]
|
#[pumpkin_block("minecraft:target")]
|
||||||
pub struct TargetBlock;
|
pub struct TargetBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for TargetBlock {
|
impl BlockBehaviour for TargetBlock {
|
||||||
async fn emits_redstone_power(&self, _args: EmitsRedstonePowerArgs<'_>) -> bool {
|
async fn emits_redstone_power(&self, _args: EmitsRedstonePowerArgs<'_>) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,9 +11,9 @@ use pumpkin_util::math::{boundingbox::BoundingBox, position::BlockPos};
|
|||||||
use pumpkin_world::{BlockStateId, tick::TickPriority, world::BlockFlags};
|
use pumpkin_world::{BlockStateId, tick::TickPriority, world::BlockFlags};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
block::pumpkin_block::{
|
block::{
|
||||||
BrokenArgs, GetStateForNeighborUpdateArgs, OnEntityCollisionArgs, OnPlaceArgs,
|
BlockBehaviour, BrokenArgs, GetStateForNeighborUpdateArgs, OnEntityCollisionArgs,
|
||||||
OnScheduledTickArgs, OnStateReplacedArgs, PlacedArgs, PumpkinBlock,
|
OnPlaceArgs, OnScheduledTickArgs, OnStateReplacedArgs, PlacedArgs,
|
||||||
},
|
},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
@ -27,7 +27,7 @@ type TripwireHookProperties = pumpkin_data::block_properties::TripwireHookLikePr
|
|||||||
pub struct TripwireBlock;
|
pub struct TripwireBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for TripwireBlock {
|
impl BlockBehaviour for TripwireBlock {
|
||||||
async fn on_entity_collision(&self, args: OnEntityCollisionArgs<'_>) {
|
async fn on_entity_collision(&self, args: OnEntityCollisionArgs<'_>) {
|
||||||
let mut props = TripwireProperties::from_state_id(args.state.id, args.block);
|
let mut props = TripwireProperties::from_state_id(args.state.id, args.block);
|
||||||
if props.powered {
|
if props.powered {
|
||||||
|
|||||||
@ -16,10 +16,10 @@ use pumpkin_world::{
|
|||||||
use rand::{Rng, rng};
|
use rand::{Rng, rng};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
block::pumpkin_block::{
|
block::{
|
||||||
CanPlaceAtArgs, EmitsRedstonePowerArgs, GetRedstonePowerArgs,
|
BlockBehaviour, CanPlaceAtArgs, EmitsRedstonePowerArgs, GetRedstonePowerArgs,
|
||||||
GetStateForNeighborUpdateArgs, OnPlaceArgs, OnScheduledTickArgs, OnStateReplacedArgs,
|
GetStateForNeighborUpdateArgs, OnPlaceArgs, OnScheduledTickArgs, OnStateReplacedArgs,
|
||||||
PlayerPlacedArgs, PumpkinBlock,
|
PlayerPlacedArgs,
|
||||||
},
|
},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
@ -31,7 +31,7 @@ type TripwireHookProperties = pumpkin_data::block_properties::TripwireHookLikePr
|
|||||||
pub struct TripwireHookBlock;
|
pub struct TripwireHookBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for TripwireHookBlock {
|
impl BlockBehaviour for TripwireHookBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut props = TripwireHookProperties::default(args.block);
|
let mut props = TripwireHookProperties::default(args.block);
|
||||||
props.powered = false;
|
props.powered = false;
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{BlockMetadata, OnPlaceArgs, PlacedArgs};
|
use crate::block::{BlockMetadata, OnPlaceArgs, PlacedArgs};
|
||||||
use crate::block::{
|
use crate::block::{
|
||||||
pumpkin_block::{NormalUseArgs, PumpkinBlock},
|
|
||||||
registry::BlockActionResult,
|
registry::BlockActionResult,
|
||||||
|
{BlockBehaviour, NormalUseArgs},
|
||||||
};
|
};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::block_properties::BlockProperties;
|
use pumpkin_data::block_properties::BlockProperties;
|
||||||
@ -54,7 +54,7 @@ impl BlockMetadata for ShulkerBoxBlock {
|
|||||||
type EndRodLikeProperties = pumpkin_data::block_properties::EndRodLikeProperties;
|
type EndRodLikeProperties = pumpkin_data::block_properties::EndRodLikeProperties;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for ShulkerBoxBlock {
|
impl BlockBehaviour for ShulkerBoxBlock {
|
||||||
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
||||||
if let Some(block_entity) = args.world.get_block_entity(args.position).await {
|
if let Some(block_entity) = args.world.get_block_entity(args.position).await {
|
||||||
if let Some(inventory) = block_entity.get_inventory() {
|
if let Some(inventory) = block_entity.get_inventory() {
|
||||||
|
|||||||
@ -7,10 +7,10 @@ use pumpkin_data::tag::get_tag_values;
|
|||||||
use pumpkin_macros::pumpkin_block_from_tag;
|
use pumpkin_macros::pumpkin_block_from_tag;
|
||||||
use pumpkin_world::block::entities::sign::SignBlockEntity;
|
use pumpkin_world::block::entities::sign::SignBlockEntity;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::OnPlaceArgs;
|
use crate::block::BlockBehaviour;
|
||||||
use crate::block::pumpkin_block::PlacedArgs;
|
use crate::block::OnPlaceArgs;
|
||||||
use crate::block::pumpkin_block::PlayerPlacedArgs;
|
use crate::block::PlacedArgs;
|
||||||
use crate::block::pumpkin_block::PumpkinBlock;
|
use crate::block::PlayerPlacedArgs;
|
||||||
use crate::entity::EntityBase;
|
use crate::entity::EntityBase;
|
||||||
|
|
||||||
type SignProperties = pumpkin_data::block_properties::OakSignLikeProperties;
|
type SignProperties = pumpkin_data::block_properties::OakSignLikeProperties;
|
||||||
@ -19,7 +19,7 @@ type SignProperties = pumpkin_data::block_properties::OakSignLikeProperties;
|
|||||||
pub struct SignBlock;
|
pub struct SignBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for SignBlock {
|
impl BlockBehaviour for SignBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> u16 {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> u16 {
|
||||||
let mut sign_props = SignProperties::default(args.block);
|
let mut sign_props = SignProperties::default(args.block);
|
||||||
sign_props.waterlogged = args.replacing.water_source();
|
sign_props.waterlogged = args.replacing.water_source();
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use crate::block::blocks::redstone::block_receives_redstone_power;
|
use crate::block::blocks::redstone::block_receives_redstone_power;
|
||||||
use crate::block::pumpkin_block::{BlockMetadata, OnNeighborUpdateArgs, OnPlaceArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, BlockMetadata, OnNeighborUpdateArgs, OnPlaceArgs};
|
||||||
use crate::entity::EntityBase;
|
use crate::entity::EntityBase;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::block_properties::BlockProperties;
|
use pumpkin_data::block_properties::BlockProperties;
|
||||||
@ -29,7 +29,7 @@ impl BlockMetadata for SkullBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for SkullBlock {
|
impl BlockBehaviour for SkullBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut props = SkeletonSkullLikeProperties::default(args.block);
|
let mut props = SkeletonSkullLikeProperties::default(args.block);
|
||||||
props.rotation = args.player.get_entity().get_rotation_16();
|
props.rotation = args.player.get_entity().get_rotation_16();
|
||||||
|
|||||||
@ -7,10 +7,10 @@ use pumpkin_data::tag::get_tag_values;
|
|||||||
use pumpkin_macros::pumpkin_block_from_tag;
|
use pumpkin_macros::pumpkin_block_from_tag;
|
||||||
use pumpkin_world::BlockStateId;
|
use pumpkin_world::BlockStateId;
|
||||||
|
|
||||||
|
use crate::block::BlockBehaviour;
|
||||||
use crate::block::BlockIsReplacing;
|
use crate::block::BlockIsReplacing;
|
||||||
use crate::block::pumpkin_block::CanUpdateAtArgs;
|
use crate::block::CanUpdateAtArgs;
|
||||||
use crate::block::pumpkin_block::OnPlaceArgs;
|
use crate::block::OnPlaceArgs;
|
||||||
use crate::block::pumpkin_block::PumpkinBlock;
|
|
||||||
|
|
||||||
type SlabProperties = pumpkin_data::block_properties::ResinBrickSlabLikeProperties;
|
type SlabProperties = pumpkin_data::block_properties::ResinBrickSlabLikeProperties;
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ type SlabProperties = pumpkin_data::block_properties::ResinBrickSlabLikeProperti
|
|||||||
pub struct SlabBlock;
|
pub struct SlabBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for SlabBlock {
|
impl BlockBehaviour for SlabBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
if let BlockIsReplacing::Itself(state_id) = args.replacing {
|
if let BlockIsReplacing::Itself(state_id) = args.replacing {
|
||||||
let mut slab_props = SlabProperties::from_state_id(state_id, args.block);
|
let mut slab_props = SlabProperties::from_state_id(state_id, args.block);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use crate::block::pumpkin_block::{OnPlaceArgs, PumpkinBlock};
|
use crate::block::{BlockBehaviour, OnPlaceArgs};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use pumpkin_data::block_properties::{BlockProperties, FurnaceLikeProperties};
|
use pumpkin_data::block_properties::{BlockProperties, FurnaceLikeProperties};
|
||||||
use pumpkin_macros::pumpkin_block;
|
use pumpkin_macros::pumpkin_block;
|
||||||
@ -8,7 +8,7 @@ use pumpkin_world::BlockStateId;
|
|||||||
pub struct SmokerBlock;
|
pub struct SmokerBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for SmokerBlock {
|
impl BlockBehaviour for SmokerBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut props = FurnaceLikeProperties::default(args.block);
|
let mut props = FurnaceLikeProperties::default(args.block);
|
||||||
props.facing = args
|
props.facing = args
|
||||||
|
|||||||
@ -12,9 +12,9 @@ use pumpkin_util::math::position::BlockPos;
|
|||||||
use pumpkin_world::BlockStateId;
|
use pumpkin_world::BlockStateId;
|
||||||
use pumpkin_world::world::BlockFlags;
|
use pumpkin_world::world::BlockFlags;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::OnNeighborUpdateArgs;
|
use crate::block::BlockBehaviour;
|
||||||
use crate::block::pumpkin_block::OnPlaceArgs;
|
use crate::block::OnNeighborUpdateArgs;
|
||||||
use crate::block::pumpkin_block::PumpkinBlock;
|
use crate::block::OnPlaceArgs;
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
|
|
||||||
type StairsProperties = pumpkin_data::block_properties::OakStairsLikeProperties;
|
type StairsProperties = pumpkin_data::block_properties::OakStairsLikeProperties;
|
||||||
@ -23,7 +23,7 @@ type StairsProperties = pumpkin_data::block_properties::OakStairsLikeProperties;
|
|||||||
pub struct StairBlock;
|
pub struct StairBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for StairBlock {
|
impl BlockBehaviour for StairBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
let mut stair_props = StairsProperties::default(args.block);
|
let mut stair_props = StairsProperties::default(args.block);
|
||||||
stair_props.waterlogged = args.replacing.water_source();
|
stair_props.waterlogged = args.replacing.water_source();
|
||||||
|
|||||||
@ -12,8 +12,8 @@ use pumpkin_world::BlockStateId;
|
|||||||
use pumpkin_world::tick::TickPriority;
|
use pumpkin_world::tick::TickPriority;
|
||||||
use pumpkin_world::world::{BlockAccessor, BlockFlags};
|
use pumpkin_world::world::{BlockAccessor, BlockFlags};
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{
|
use crate::block::{
|
||||||
CanPlaceAtArgs, GetStateForNeighborUpdateArgs, OnScheduledTickArgs, PumpkinBlock,
|
BlockBehaviour, CanPlaceAtArgs, GetStateForNeighborUpdateArgs, OnScheduledTickArgs,
|
||||||
RandomTickArgs,
|
RandomTickArgs,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ use crate::block::pumpkin_block::{
|
|||||||
pub struct SugarCaneBlock;
|
pub struct SugarCaneBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for SugarCaneBlock {
|
impl BlockBehaviour for SugarCaneBlock {
|
||||||
async fn on_scheduled_tick(&self, args: OnScheduledTickArgs<'_>) {
|
async fn on_scheduled_tick(&self, args: OnScheduledTickArgs<'_>) {
|
||||||
if !can_place_at(args.world.as_ref(), args.position).await {
|
if !can_place_at(args.world.as_ref(), args.position).await {
|
||||||
args.world
|
args.world
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
use pumpkin_data::item::Item;
|
use pumpkin_data::item::Item;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{
|
|
||||||
ExplodeArgs, OnNeighborUpdateArgs, PlacedArgs, PumpkinBlock, UseWithItemArgs,
|
|
||||||
};
|
|
||||||
use crate::block::registry::BlockActionResult;
|
use crate::block::registry::BlockActionResult;
|
||||||
|
use crate::block::{
|
||||||
|
BlockBehaviour, ExplodeArgs, OnNeighborUpdateArgs, PlacedArgs, UseWithItemArgs,
|
||||||
|
};
|
||||||
use crate::entity::Entity;
|
use crate::entity::Entity;
|
||||||
use crate::entity::tnt::TNTEntity;
|
use crate::entity::tnt::TNTEntity;
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
@ -52,7 +52,7 @@ const DEFAULT_FUSE: u32 = 80;
|
|||||||
const DEFAULT_POWER: f32 = 4.0;
|
const DEFAULT_POWER: f32 = 4.0;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for TNTBlock {
|
impl BlockBehaviour for TNTBlock {
|
||||||
async fn use_with_item(&self, args: UseWithItemArgs<'_>) -> BlockActionResult {
|
async fn use_with_item(&self, args: UseWithItemArgs<'_>) -> BlockActionResult {
|
||||||
let item = args.item_stack.lock().await.item;
|
let item = args.item_stack.lock().await.item;
|
||||||
if item != &Item::FLINT_AND_STEEL || item == &Item::FIRE_CHARGE {
|
if item != &Item::FLINT_AND_STEEL || item == &Item::FIRE_CHARGE {
|
||||||
|
|||||||
@ -11,8 +11,8 @@ use pumpkin_world::world::BlockAccessor;
|
|||||||
type WallTorchProps = pumpkin_data::block_properties::WallTorchLikeProperties;
|
type WallTorchProps = pumpkin_data::block_properties::WallTorchLikeProperties;
|
||||||
// Normal tourches don't have properties
|
// Normal tourches don't have properties
|
||||||
|
|
||||||
use crate::block::pumpkin_block::{
|
use crate::block::{
|
||||||
BlockMetadata, CanPlaceAtArgs, GetStateForNeighborUpdateArgs, OnPlaceArgs, PumpkinBlock,
|
BlockBehaviour, BlockMetadata, CanPlaceAtArgs, GetStateForNeighborUpdateArgs, OnPlaceArgs,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct TorchBlock;
|
pub struct TorchBlock;
|
||||||
@ -33,7 +33,7 @@ impl BlockMetadata for TorchBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for TorchBlock {
|
impl BlockBehaviour for TorchBlock {
|
||||||
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
async fn on_place(&self, args: OnPlaceArgs<'_>) -> BlockStateId {
|
||||||
if args.direction == BlockDirection::Down {
|
if args.direction == BlockDirection::Down {
|
||||||
let support_block = args.world.get_block_state(&args.position.down()).await;
|
let support_block = args.world.get_block_state(&args.position.down()).await;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use crate::block::blocks::redstone::block_receives_redstone_power;
|
use crate::block::blocks::redstone::block_receives_redstone_power;
|
||||||
use crate::block::pumpkin_block::{NormalUseArgs, OnNeighborUpdateArgs, OnPlaceArgs, PumpkinBlock};
|
|
||||||
use crate::block::registry::BlockActionResult;
|
use crate::block::registry::BlockActionResult;
|
||||||
|
use crate::block::{BlockBehaviour, NormalUseArgs, OnNeighborUpdateArgs, OnPlaceArgs};
|
||||||
use crate::entity::player::Player;
|
use crate::entity::player::Player;
|
||||||
use crate::world::World;
|
use crate::world::World;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
@ -70,7 +70,7 @@ fn get_sound(block: &Block, open: bool) -> Sound {
|
|||||||
pub struct TrapDoorBlock;
|
pub struct TrapDoorBlock;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl PumpkinBlock for TrapDoorBlock {
|
impl BlockBehaviour for TrapDoorBlock {
|
||||||
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
async fn normal_use(&self, args: NormalUseArgs<'_>) -> BlockActionResult {
|
||||||
if !can_open_trapdoor(args.block) {
|
if !can_open_trapdoor(args.block) {
|
||||||
return BlockActionResult::Pass;
|
return BlockActionResult::Pass;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user