Unnecessary "?:"

This commit is contained in:
Sunch 2024-08-17 20:01:40 +08:00
parent 4630481d54
commit 4eb6bd14a2
6 changed files with 9 additions and 9 deletions

View file

@ -7,7 +7,7 @@ require_once(FILE_PATH . "/src/functions.php");
/***REM_END***/ /***REM_END***/
define("DATA_PATH", realpath(arg("data-path", FILE_PATH)) . "/"); 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); define("ENABLE_ANSI", true);
}else{ }else{
define("ENABLE_ANSI", false); define("ENABLE_ANSI", false);

View file

@ -383,7 +383,7 @@ class Entity extends Position
* @return boolean * @return boolean
*/ */
public function isPickable(){ public function isPickable(){
return $this->isPlayer() ? !$this->dead : false; return $this->isPlayer() && !$this->dead;
} }
public function handleLavaMovement(){ //TODO maybe try merging with water? public function handleLavaMovement(){ //TODO maybe try merging with water?

View file

@ -163,15 +163,15 @@ abstract class Block extends Position{
} }
public static function containsX($id, $v){ 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){ 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){ 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){ public static function updateShape(Level $level, $x, $y, $z){

View file

@ -63,7 +63,7 @@ class RailLogic
} }
public function canConnectTo(RailLogic $rail){ 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){ public function hasNeighborRail($x, $y, $z){

View file

@ -581,7 +581,7 @@ class Utils{
} }
public static function readBool($b){ public static function readBool($b){
return Utils::readByte($b, false) === 0 ? false : true; return !(Utils::readByte($b, false) === 0);
} }
public static function writeBool($b){ public static function writeBool($b){

View file

@ -133,8 +133,8 @@ class MobSpawner{
$b1 = $this->level->level->getBlockID($x, $y - 1, $z); $b1 = $this->level->level->getBlockID($x, $y - 1, $z);
if( if(
!StaticBlock::getIsSolid($b) && !StaticBlock::getIsLiquid($b) && !StaticBlock::getIsSolid($b) && !StaticBlock::getIsLiquid($b) &&
(StaticBlock::getIsSolid($b1) && ($grassOnly ? $b1 === GRASS : true) && (StaticBlock::getIsSolid($b1) && (!$grassOnly || $b1 === GRASS) &&
($highMob ? !StaticBlock::getIsSolid($b2) && !StaticBlock::getIsLiquid($b2) : true)) (!$highMob || !StaticBlock::getIsSolid($b2) && !StaticBlock::getIsLiquid($b2)))
){ ){
$allowed[] = $y; $allowed[] = $y;
} }