Skip to content

Commit 235239a

Browse files
committed
Fixed that a block could be placed with a piston out of range. #98
Fixed behavior when piston is pulled.
1 parent 346c7e1 commit 235239a

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/tedo0627/redstonecircuit/block/PistonResolver.php

+20-2
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,35 @@ private function calculateBlocks(Block $block, int $face, int $breakFace): bool
6565

6666
$this->checked[] = $hash;
6767
if ($block->getId() === Ids::AIR) return true;
68-
if (!$this->canMove($block)) return $face !== $breakFace;
68+
if (!$this->canMove($block)) {
69+
$result = $face !== $breakFace;
70+
if (!$result) {
71+
$this->break = [];
72+
$this->attach = [];
73+
}
74+
return $result;
75+
}
6976

7077
if ($this->canBreak($block)) {
7178
if ($face === $breakFace) $this->break[] = $block;
7279
return true;
7380
}
7481

82+
$y = $block->getPosition()->getSide($breakFace)->getY();
83+
if ($y < 0 || 255 < $y) {
84+
$this->break = [];
85+
$this->attach = [];
86+
return false;
87+
}
88+
7589
if ($block instanceof GlazedTerracotta && $face !== $breakFace) return true;
7690

7791
$this->attach[] = $block;
78-
if (count($this->attach) >= 13) return false;
92+
if (count($this->attach) >= 13) {
93+
$this->break = [];
94+
$this->attach = [];
95+
return false;
96+
}
7997

8098
if ($block->getId() === Ids::SLIME) {
8199
for ($i = 0; $i < 6; $i++) {

0 commit comments

Comments
 (0)