From 8328da52142b5f7f76a9d01714c0c57f00059fb3 Mon Sep 17 00:00:00 2001 From: ch4rindo <103165856+ch4rindo@users.noreply.github.com> Date: Sat, 26 Nov 2022 09:27:18 +0900 Subject: [PATCH 1/2] Fixed pressure plate can be pressed even with Spectator --- .../redstonecircuit/block/power/BlockStonePressurePlate.php | 2 ++ .../block/power/BlockWeightedPressurePlateHeavy.php | 2 ++ .../block/power/BlockWeightedPressurePlateLight.php | 2 ++ .../redstonecircuit/block/power/BlockWoodenPressurePlate.php | 2 ++ 4 files changed, 8 insertions(+) diff --git a/src/tedo0627/redstonecircuit/block/power/BlockStonePressurePlate.php b/src/tedo0627/redstonecircuit/block/power/BlockStonePressurePlate.php index 55483e3..1068244 100644 --- a/src/tedo0627/redstonecircuit/block/power/BlockStonePressurePlate.php +++ b/src/tedo0627/redstonecircuit/block/power/BlockStonePressurePlate.php @@ -59,6 +59,8 @@ public function onScheduledUpdate(): void { } public function onEntityInside(Entity $entity): bool { + if ($entity instanceof Player && $entity->isSpectator()) return true; + $entities = $this->getPosition()->getWorld()->getNearbyEntities($this->getHitCollision()); $entities = array_filter($entities, fn($entity) => $entity instanceof Living); if (count($entities) <= 0) return true; diff --git a/src/tedo0627/redstonecircuit/block/power/BlockWeightedPressurePlateHeavy.php b/src/tedo0627/redstonecircuit/block/power/BlockWeightedPressurePlateHeavy.php index f2113d0..d853740 100644 --- a/src/tedo0627/redstonecircuit/block/power/BlockWeightedPressurePlateHeavy.php +++ b/src/tedo0627/redstonecircuit/block/power/BlockWeightedPressurePlateHeavy.php @@ -64,6 +64,8 @@ public function onScheduledUpdate(): void { } public function onEntityInside(Entity $entity): bool { + if ($entity instanceof Player && $entity->isSpectator()) return true; + $entities = $this->getPosition()->getWorld()->getNearbyEntities($this->getHitCollision()); $count = count($entities); if ($count <= 0) return true; diff --git a/src/tedo0627/redstonecircuit/block/power/BlockWeightedPressurePlateLight.php b/src/tedo0627/redstonecircuit/block/power/BlockWeightedPressurePlateLight.php index 41ea3cc..910774a 100644 --- a/src/tedo0627/redstonecircuit/block/power/BlockWeightedPressurePlateLight.php +++ b/src/tedo0627/redstonecircuit/block/power/BlockWeightedPressurePlateLight.php @@ -64,6 +64,8 @@ public function onScheduledUpdate(): void { } public function onEntityInside(Entity $entity): bool { + if ($entity instanceof Player && $entity->isSpectator()) return true; + $entities = $this->getPosition()->getWorld()->getNearbyEntities($this->getHitCollision()); $count = count($entities); if ($count <= 0) return true; diff --git a/src/tedo0627/redstonecircuit/block/power/BlockWoodenPressurePlate.php b/src/tedo0627/redstonecircuit/block/power/BlockWoodenPressurePlate.php index f7fbe9d..1f033a8 100644 --- a/src/tedo0627/redstonecircuit/block/power/BlockWoodenPressurePlate.php +++ b/src/tedo0627/redstonecircuit/block/power/BlockWoodenPressurePlate.php @@ -57,6 +57,8 @@ public function onScheduledUpdate(): void { } public function onEntityInside(Entity $entity): bool { + if ($entity instanceof Player && $entity->isSpectator()) return true; + $entities = $this->getPosition()->getWorld()->getNearbyEntities($this->getHitCollision()); if (count($entities) <= 0) return true; From 859b58a031818722d786fbd9e24ea7af8f9f0fb3 Mon Sep 17 00:00:00 2001 From: ch4rindo <103165856+ch4rindo@users.noreply.github.com> Date: Sat, 26 Nov 2022 20:54:42 +0900 Subject: [PATCH 2/2] Fixed indentation --- .../redstonecircuit/block/power/BlockStonePressurePlate.php | 2 +- .../block/power/BlockWeightedPressurePlateHeavy.php | 2 +- .../block/power/BlockWeightedPressurePlateLight.php | 2 +- .../redstonecircuit/block/power/BlockWoodenPressurePlate.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tedo0627/redstonecircuit/block/power/BlockStonePressurePlate.php b/src/tedo0627/redstonecircuit/block/power/BlockStonePressurePlate.php index 1068244..bbd8ec4 100644 --- a/src/tedo0627/redstonecircuit/block/power/BlockStonePressurePlate.php +++ b/src/tedo0627/redstonecircuit/block/power/BlockStonePressurePlate.php @@ -59,7 +59,7 @@ public function onScheduledUpdate(): void { } public function onEntityInside(Entity $entity): bool { - if ($entity instanceof Player && $entity->isSpectator()) return true; + if ($entity instanceof Player && $entity->isSpectator()) return true; $entities = $this->getPosition()->getWorld()->getNearbyEntities($this->getHitCollision()); $entities = array_filter($entities, fn($entity) => $entity instanceof Living); diff --git a/src/tedo0627/redstonecircuit/block/power/BlockWeightedPressurePlateHeavy.php b/src/tedo0627/redstonecircuit/block/power/BlockWeightedPressurePlateHeavy.php index d853740..c2e258a 100644 --- a/src/tedo0627/redstonecircuit/block/power/BlockWeightedPressurePlateHeavy.php +++ b/src/tedo0627/redstonecircuit/block/power/BlockWeightedPressurePlateHeavy.php @@ -64,7 +64,7 @@ public function onScheduledUpdate(): void { } public function onEntityInside(Entity $entity): bool { - if ($entity instanceof Player && $entity->isSpectator()) return true; + if ($entity instanceof Player && $entity->isSpectator()) return true; $entities = $this->getPosition()->getWorld()->getNearbyEntities($this->getHitCollision()); $count = count($entities); diff --git a/src/tedo0627/redstonecircuit/block/power/BlockWeightedPressurePlateLight.php b/src/tedo0627/redstonecircuit/block/power/BlockWeightedPressurePlateLight.php index 910774a..7b6321e 100644 --- a/src/tedo0627/redstonecircuit/block/power/BlockWeightedPressurePlateLight.php +++ b/src/tedo0627/redstonecircuit/block/power/BlockWeightedPressurePlateLight.php @@ -64,7 +64,7 @@ public function onScheduledUpdate(): void { } public function onEntityInside(Entity $entity): bool { - if ($entity instanceof Player && $entity->isSpectator()) return true; + if ($entity instanceof Player && $entity->isSpectator()) return true; $entities = $this->getPosition()->getWorld()->getNearbyEntities($this->getHitCollision()); $count = count($entities); diff --git a/src/tedo0627/redstonecircuit/block/power/BlockWoodenPressurePlate.php b/src/tedo0627/redstonecircuit/block/power/BlockWoodenPressurePlate.php index 1f033a8..e17428f 100644 --- a/src/tedo0627/redstonecircuit/block/power/BlockWoodenPressurePlate.php +++ b/src/tedo0627/redstonecircuit/block/power/BlockWoodenPressurePlate.php @@ -57,7 +57,7 @@ public function onScheduledUpdate(): void { } public function onEntityInside(Entity $entity): bool { - if ($entity instanceof Player && $entity->isSpectator()) return true; + if ($entity instanceof Player && $entity->isSpectator()) return true; $entities = $this->getPosition()->getWorld()->getNearbyEntities($this->getHitCollision()); if (count($entities) <= 0) return true;