@@ -44,9 +44,24 @@ public function onNearbyBlockChange(): void {
44
44
}
45
45
46
46
public function onScheduledUpdate (): void {
47
- $ this ->setPowered (!$ this ->isPowered ());
48
- $ this ->getPosition ()->getWorld ()->setBlock ($ this ->getPosition (), $ this );
49
- BlockUpdateHelper::updateDiodeRedstone ($ this , Facing::opposite ($ this ->getFacing ()));
47
+ if ($ this ->isLocked ()) return ;
48
+
49
+ $ powered = $ this ->isPowered ();
50
+ $ side = BlockPowerHelper::isSidePowered ($ this , $ this ->getFacing ());
51
+ if ($ powered && !$ side ) {
52
+ $ this ->setPowered (false );
53
+ $ this ->getPosition ()->getWorld ()->setBlock ($ this ->getPosition (), $ this );
54
+ BlockUpdateHelper::updateDiodeRedstone ($ this , Facing::opposite ($ this ->getFacing ()));
55
+ return ;
56
+ }
57
+
58
+ if (!$ powered ) {
59
+ $ this ->setPowered (true );
60
+ $ this ->getPosition ()->getWorld ()->setBlock ($ this ->getPosition (), $ this );
61
+ BlockUpdateHelper::updateDiodeRedstone ($ this , Facing::opposite ($ this ->getFacing ()));
62
+
63
+ if (!$ side ) $ this ->getPosition ()->getWorld ()->scheduleDelayedBlockUpdate ($ this ->getPosition (), $ this ->getDelay () * 2 );
64
+ }
50
65
}
51
66
52
67
public function isLocked (): bool {
@@ -73,8 +88,14 @@ public function isPowerSource(): bool {
73
88
74
89
public function onRedstoneUpdate (): void {
75
90
if ($ this ->isLocked ()) return ;
76
- if (BlockPowerHelper::isSidePowered ($ this , $ this ->getFacing ()) === $ this ->isPowered ()) return ;
77
91
92
+ $ side = BlockPowerHelper::isSidePowered ($ this , $ this ->getFacing ());
93
+ if ($ side && !$ this ->isPowered ()) {
94
+ $ this ->getPosition ()->getWorld ()->scheduleDelayedBlockUpdate ($ this ->getPosition (), $ this ->getDelay () * 2 );
95
+ return ;
96
+ }
97
+
98
+ if ($ side || !$ this ->isPowered ()) return ;
78
99
$ this ->getPosition ()->getWorld ()->scheduleDelayedBlockUpdate ($ this ->getPosition (), $ this ->getDelay () * 2 );
79
100
}
80
101
0 commit comments