Skip to content

Commit 95d874c

Browse files
authored
fix: wrong piston break check (#1787)
1 parent b03e6db commit 95d874c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

pumpkin/src/block/blocks/piston/piston.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ use rustc_hash::FxHashMap;
2020
use crate::{
2121
block::{
2222
BlockBehaviour, BlockFuture, BlockMetadata, BrokenArgs, OnNeighborUpdateArgs, OnPlaceArgs,
23-
OnSyncedBlockEventArgs, PlacedArgs, blocks::redstone::is_emitting_redstone_power,
23+
OnSyncedBlockEventArgs, PlacedArgs,
24+
blocks::{piston::piston_head::PistonHeadProperties, redstone::is_emitting_redstone_power},
2425
},
2526
world::World,
2627
};
@@ -93,8 +94,19 @@ impl BlockBehaviour for PistonBlock {
9394
let pos = args
9495
.position
9596
.offset(props.facing.to_block_direction().to_offset());
96-
let (block_to_check, _) = args.world.get_block_and_state_id(&pos).await;
97+
let (block_to_check, block_to_check_state_id) =
98+
args.world.get_block_and_state_id(&pos).await;
9799
if &Block::PISTON_HEAD == block_to_check || &Block::MOVING_PISTON == block_to_check {
100+
let head_props =
101+
PistonHeadProperties::from_state_id(block_to_check_state_id, block_to_check);
102+
103+
if (head_props.facing.to_block_direction() != props.facing.to_block_direction())
104+
&& &Block::PISTON_HEAD == block_to_check
105+
{
106+
//Then this is a head of some other piston.
107+
return;
108+
}
109+
98110
args.world
99111
.break_block(&pos, None, BlockFlags::SKIP_DROPS)
100112
.await;

0 commit comments

Comments
 (0)