File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ use crate :: block:: { BlockBehaviour , GetStateForNeighborUpdateArgs , OnPlaceArgs } ;
2
+ use async_trait:: async_trait;
3
+ use pumpkin_data:: block_properties:: { BlockProperties , MangroveRootsLikeProperties as BarrierLikeProperties } ;
4
+ use pumpkin_data:: fluid:: Fluid ;
5
+ use pumpkin_macros:: pumpkin_block;
6
+ use pumpkin_world:: tick:: TickPriority ;
7
+ use pumpkin_world:: BlockStateId ;
8
+
9
+ #[ pumpkin_block( "minecraft:barrier" ) ]
10
+ pub struct BarrierBlock ;
11
+
12
+ #[ async_trait]
13
+ impl BlockBehaviour for BarrierBlock {
14
+ async fn on_place ( & self , args : OnPlaceArgs < ' _ > ) -> BlockStateId {
15
+ let mut props = BarrierLikeProperties :: default ( args. block ) ;
16
+ props. waterlogged = args. replacing . water_source ( ) ;
17
+ props. to_state_id ( args. block )
18
+ }
19
+
20
+ async fn get_state_for_neighbor_update (
21
+ & self ,
22
+ args : GetStateForNeighborUpdateArgs < ' _ > ,
23
+ ) -> BlockStateId {
24
+ let props = BarrierLikeProperties :: from_state_id ( args. state_id , args. block ) ;
25
+ if props. waterlogged {
26
+ args. world
27
+ . schedule_fluid_tick (
28
+ & Fluid :: WATER ,
29
+ * args. position ,
30
+ Fluid :: WATER . flow_speed as u8 ,
31
+ TickPriority :: Normal
32
+ )
33
+ . await ;
34
+ }
35
+ props. to_state_id ( args. block )
36
+ }
37
+ }
Original file line number Diff line number Diff line change 1
1
pub mod anvil;
2
2
pub mod bamboo;
3
3
pub mod barrel;
4
+ pub mod barrier;
4
5
pub mod bed;
5
6
pub mod cactus;
6
7
pub mod cake;
Original file line number Diff line number Diff line change 1
1
use crate :: block:: blocks:: anvil:: AnvilBlock ;
2
2
use crate :: block:: blocks:: bamboo:: BambooBlock ;
3
3
use crate :: block:: blocks:: barrel:: BarrelBlock ;
4
+ use crate :: block:: blocks:: barrier:: BarrierBlock ;
4
5
use crate :: block:: blocks:: bed:: BedBlock ;
5
6
use crate :: block:: blocks:: cactus:: CactusBlock ;
6
7
use crate :: block:: blocks:: carpet:: { CarpetBlock , MossCarpetBlock , PaleMossCarpetBlock } ;
@@ -216,6 +217,7 @@ pub fn default_registry() -> Arc<BlockRegistry> {
216
217
manager. register ( ChainBlock ) ;
217
218
manager. register ( LanternBlock ) ;
218
219
manager. register ( EndRodBlock ) ;
220
+ manager. register ( BarrierBlock ) ;
219
221
manager. register ( MangroveRootsBlock ) ;
220
222
221
223
manager. register ( FallingBlock ) ;
You can’t perform that action at this time.
0 commit comments