From 4eb6bd14a2defcb069063172e1ecc85a33a697ed Mon Sep 17 00:00:00 2001 From: Sunch <120295462+Sunch233@users.noreply.github.com> Date: Sat, 17 Aug 2024 20:01:40 +0800 Subject: [PATCH] Unnecessary "?:" --- src/dependencies.php | 2 +- src/entity/Entity.php | 2 +- src/material/Block.php | 6 +++--- src/utils/RailLogic.php | 2 +- src/utils/Utils.php | 2 +- src/world/MobSpawner.php | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/dependencies.php b/src/dependencies.php index 0466394e..097eaed1 100644 --- a/src/dependencies.php +++ b/src/dependencies.php @@ -7,7 +7,7 @@ require_once(FILE_PATH . "/src/functions.php"); /***REM_END***/ define("DATA_PATH", realpath(arg("data-path", FILE_PATH)) . "/"); -if(arg("enable-ansi", strpos(strtoupper(php_uname("s")), "WIN") === 0 ? false : true) === true and arg("disable-ansi", false) !== true){ +if(arg("enable-ansi", !(strpos(strtoupper(php_uname("s")), "WIN") === 0)) === true and arg("disable-ansi", false) !== true){ define("ENABLE_ANSI", true); }else{ define("ENABLE_ANSI", false); diff --git a/src/entity/Entity.php b/src/entity/Entity.php index eba2d156..7211dd2c 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -383,7 +383,7 @@ class Entity extends Position * @return boolean */ public function isPickable(){ - return $this->isPlayer() ? !$this->dead : false; + return $this->isPlayer() && !$this->dead; } public function handleLavaMovement(){ //TODO maybe try merging with water? diff --git a/src/material/Block.php b/src/material/Block.php index dc4653b1..459c1e91 100755 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -163,15 +163,15 @@ abstract class Block extends Position{ } public static function containsX($id, $v){ - return $v == null ? false : $v->y >= StaticBlock::$minYs[$id] && $v->y <= StaticBlock::$maxYs[$id] && $v->z >= StaticBlock::$minZs[$id] && $v->z <= StaticBlock::$maxZs[$id]; + return !($v == null) && $v->y >= StaticBlock::$minYs[$id] && $v->y <= StaticBlock::$maxYs[$id] && $v->z >= StaticBlock::$minZs[$id] && $v->z <= StaticBlock::$maxZs[$id]; } public static function containsY($id, $v){ - return $v == null ? false : $v->x >= StaticBlock::$minXs[$id] && $v->x <= StaticBlock::$maxXs[$id] && $v->z >= StaticBlock::$minZs[$id] && $v->z <= StaticBlock::$maxZs[$id]; + return !($v == null) && $v->x >= StaticBlock::$minXs[$id] && $v->x <= StaticBlock::$maxXs[$id] && $v->z >= StaticBlock::$minZs[$id] && $v->z <= StaticBlock::$maxZs[$id]; } public static function containsZ($id, $v){ - return $v == null ? false : $v->x >= StaticBlock::$minXs[$id] && $v->x <= StaticBlock::$maxXs[$id] && $v->y >= StaticBlock::$minYs[$id] && $v->y <= StaticBlock::$maxYs[$id]; + return !($v == null) && $v->x >= StaticBlock::$minXs[$id] && $v->x <= StaticBlock::$maxXs[$id] && $v->y >= StaticBlock::$minYs[$id] && $v->y <= StaticBlock::$maxYs[$id]; } public static function updateShape(Level $level, $x, $y, $z){ diff --git a/src/utils/RailLogic.php b/src/utils/RailLogic.php index 2352d4e8..6f293a5f 100644 --- a/src/utils/RailLogic.php +++ b/src/utils/RailLogic.php @@ -63,7 +63,7 @@ class RailLogic } public function canConnectTo(RailLogic $rail){ - return $this->connectsTo($rail) ? true : (count($this->railPositions) == 2 ? false : (empty($this->railPositions) ? true : true)); + return $this->connectsTo($rail) || ((count($this->railPositions) == 2 ? false : (empty($this->railPositions) ? true : true))); } public function hasNeighborRail($x, $y, $z){ diff --git a/src/utils/Utils.php b/src/utils/Utils.php index 2131b6e2..98f3666d 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -581,7 +581,7 @@ class Utils{ } public static function readBool($b){ - return Utils::readByte($b, false) === 0 ? false : true; + return !(Utils::readByte($b, false) === 0); } public static function writeBool($b){ diff --git a/src/world/MobSpawner.php b/src/world/MobSpawner.php index 45f6125d..48d63306 100644 --- a/src/world/MobSpawner.php +++ b/src/world/MobSpawner.php @@ -133,8 +133,8 @@ class MobSpawner{ $b1 = $this->level->level->getBlockID($x, $y - 1, $z); if( !StaticBlock::getIsSolid($b) && !StaticBlock::getIsLiquid($b) && - (StaticBlock::getIsSolid($b1) && ($grassOnly ? $b1 === GRASS : true) && - ($highMob ? !StaticBlock::getIsSolid($b2) && !StaticBlock::getIsLiquid($b2) : true)) + (StaticBlock::getIsSolid($b1) && (!$grassOnly || $b1 === GRASS) && + (!$highMob || !StaticBlock::getIsSolid($b2) && !StaticBlock::getIsLiquid($b2))) ){ $allowed[] = $y; }