diff --git a/src/block/Bamboo.php b/src/block/Bamboo.php index 08817d12d..7fdf226a0 100644 --- a/src/block/Bamboo.php +++ b/src/block/Bamboo.php @@ -160,7 +160,7 @@ class Bamboo extends Transparent{ public function onNearbyBlockChange() : void{ $below = $this->position->getWorld()->getBlock($this->position->down()); - if(!$this->canBeSupportedBy($below) and !$below->isSameType($this)){ + if(!$this->canBeSupportedBy($below) && !$below->isSameType($this)){ $this->position->getWorld()->useBreakOn($this->position); } } diff --git a/src/block/BaseBanner.php b/src/block/BaseBanner.php index 0f7d55ae5..64e767897 100644 --- a/src/block/BaseBanner.php +++ b/src/block/BaseBanner.php @@ -130,7 +130,7 @@ abstract class BaseBanner extends Transparent{ public function getDropsForCompatibleTool(Item $item) : array{ $drop = $this->asItem(); - if($drop instanceof ItemBanner and count($this->patterns) > 0){ + if($drop instanceof ItemBanner && count($this->patterns) > 0){ $drop->setPatterns($this->patterns); } @@ -139,7 +139,7 @@ abstract class BaseBanner extends Transparent{ public function getPickedItem(bool $addUserData = false) : Item{ $result = $this->asItem(); - if($addUserData and $result instanceof ItemBanner and count($this->patterns) > 0){ + if($addUserData && $result instanceof ItemBanner && count($this->patterns) > 0){ $result->setPatterns($this->patterns); } return $result; diff --git a/src/block/BaseRail.php b/src/block/BaseRail.php index bf117cd7c..0344cdba8 100644 --- a/src/block/BaseRail.php +++ b/src/block/BaseRail.php @@ -101,7 +101,7 @@ abstract class BaseRail extends Flowable{ } if( - $other instanceof BaseRail and + $other instanceof BaseRail && in_array($otherConnection, $other->getCurrentShapeConnections(), true) ){ $connections[] = $connection; @@ -179,7 +179,7 @@ abstract class BaseRail extends Flowable{ $otherSide |= RailConnectionInfo::FLAG_ASCEND; } - if(!($other instanceof BaseRail) or count($otherConnections = $other->getConnectedDirections()) >= 2){ + if(!($other instanceof BaseRail) || count($otherConnections = $other->getConnectedDirections()) >= 2){ //we can only connect to a rail that has less than 2 connections continue; } @@ -224,7 +224,7 @@ abstract class BaseRail extends Flowable{ $this->position->getWorld()->useBreakOn($this->position); }else{ foreach($this->getCurrentShapeConnections() as $connection){ - if(($connection & RailConnectionInfo::FLAG_ASCEND) !== 0 and $this->getSide($connection & ~RailConnectionInfo::FLAG_ASCEND)->isTransparent()){ + if(($connection & RailConnectionInfo::FLAG_ASCEND) !== 0 && $this->getSide($connection & ~RailConnectionInfo::FLAG_ASCEND)->isTransparent()){ $this->position->getWorld()->useBreakOn($this->position); break; } diff --git a/src/block/Bed.php b/src/block/Bed.php index 731cf664e..fd566bca3 100644 --- a/src/block/Bed.php +++ b/src/block/Bed.php @@ -120,7 +120,7 @@ class Bed extends Transparent{ public function getOtherHalf() : ?Bed{ $other = $this->getSide($this->getOtherHalfSide()); - if($other instanceof Bed and $other->head !== $this->head and $other->facing === $this->facing){ + if($other instanceof Bed && $other->head !== $this->head && $other->facing === $this->facing){ return $other; } @@ -135,14 +135,14 @@ class Bed extends Transparent{ $player->sendMessage(TextFormat::GRAY . "This bed is incomplete"); return true; - }elseif($playerPos->distanceSquared($this->position) > 4 and $playerPos->distanceSquared($other->position) > 4){ + }elseif($playerPos->distanceSquared($this->position) > 4 && $playerPos->distanceSquared($other->position) > 4){ $player->sendMessage(KnownTranslationFactory::tile_bed_tooFar()->prefix(TextFormat::GRAY)); return true; } $time = $this->position->getWorld()->getTimeOfDay(); - $isNight = ($time >= World::TIME_NIGHT and $time < World::TIME_SUNRISE); + $isNight = ($time >= World::TIME_NIGHT && $time < World::TIME_SUNRISE); if(!$isNight){ $player->sendMessage(KnownTranslationFactory::tile_bed_noSleep()->prefix(TextFormat::GRAY)); @@ -166,7 +166,7 @@ class Bed extends Transparent{ } public function onNearbyBlockChange() : void{ - if(($other = $this->getOtherHalf()) !== null and $other->occupied !== $this->occupied){ + if(($other = $this->getOtherHalf()) !== null && $other->occupied !== $this->occupied){ $this->occupied = $other->occupied; $this->position->getWorld()->setBlock($this->position, $this); } @@ -186,7 +186,7 @@ class Bed extends Transparent{ $this->facing = $player !== null ? $player->getHorizontalFacing() : Facing::NORTH; $next = $this->getSide($this->getOtherHalfSide()); - if($next->canBeReplaced() and !$next->getSide(Facing::DOWN)->isTransparent()){ + if($next->canBeReplaced() && !$next->getSide(Facing::DOWN)->isTransparent()){ $nextState = clone $this; $nextState->head = true; $tx->addBlock($blockReplace->position, $this)->addBlock($next->position, $nextState); diff --git a/src/block/Block.php b/src/block/Block.php index d49206f6c..ef2ba2b81 100644 --- a/src/block/Block.php +++ b/src/block/Block.php @@ -148,14 +148,14 @@ class Block{ $tileType = $this->idInfo->getTileClass(); $oldTile = $this->position->getWorld()->getTile($this->position); if($oldTile !== null){ - if($tileType === null or !($oldTile instanceof $tileType)){ + if($tileType === null || !($oldTile instanceof $tileType)){ $oldTile->close(); $oldTile = null; }elseif($oldTile instanceof Spawnable){ $oldTile->setDirty(); //destroy old network cache } } - if($oldTile === null and $tileType !== null){ + if($oldTile === null && $tileType !== null){ /** * @var Tile $tile * @see Tile::__construct() @@ -361,7 +361,7 @@ class Block{ */ public function getDrops(Item $item) : array{ if($this->breakInfo->isToolCompatible($item)){ - if($this->isAffectedBySilkTouch() and $item->hasEnchantment(VanillaEnchantments::SILK_TOUCH())){ + if($this->isAffectedBySilkTouch() && $item->hasEnchantment(VanillaEnchantments::SILK_TOUCH())){ return $this->getSilkTouchDrops($item); } @@ -402,7 +402,7 @@ class Block{ * Returns how much XP will be dropped by breaking this block with the given item. */ public function getXpDropForTool(Item $item) : int{ - if($item->hasEnchantment(VanillaEnchantments::SILK_TOUCH()) or !$this->breakInfo->isToolCompatible($item)){ + if($item->hasEnchantment(VanillaEnchantments::SILK_TOUCH()) || !$this->breakInfo->isToolCompatible($item)){ return 0; } @@ -613,7 +613,7 @@ class Block{ public function isFullCube() : bool{ $bb = $this->getCollisionBoxes(); - return count($bb) === 1 and $bb[0]->getAverageEdgeLength() >= 1 and $bb[0]->isCube(); + return count($bb) === 1 && $bb[0]->getAverageEdgeLength() >= 1 && $bb[0]->isCube(); } public function calculateIntercept(Vector3 $pos1, Vector3 $pos2) : ?RayTraceResult{ diff --git a/src/block/BlockBreakInfo.php b/src/block/BlockBreakInfo.php index 0290b02ab..184195aee 100644 --- a/src/block/BlockBreakInfo.php +++ b/src/block/BlockBreakInfo.php @@ -119,8 +119,8 @@ class BlockBreakInfo{ return false; } - return $this->toolType === BlockToolType::NONE or $this->toolHarvestLevel === 0 or ( - ($this->toolType & $tool->getBlockToolType()) !== 0 and $tool->getBlockToolHarvestLevel() >= $this->toolHarvestLevel); + return $this->toolType === BlockToolType::NONE || $this->toolHarvestLevel === 0 || ( + ($this->toolType & $tool->getBlockToolType()) !== 0 && $tool->getBlockToolHarvestLevel() >= $this->toolHarvestLevel); } /** diff --git a/src/block/BlockFactory.php b/src/block/BlockFactory.php index 5a6f2ce50..914e1edca 100644 --- a/src/block/BlockFactory.php +++ b/src/block/BlockFactory.php @@ -974,7 +974,7 @@ class BlockFactory{ } foreach($block->getIdInfo()->getAllBlockIds() as $id){ - if(!$override and $this->isRegistered($id, $variant)){ + if(!$override && $this->isRegistered($id, $variant)){ throw new \InvalidArgumentException("Block registration $id:$variant conflicts with an existing block"); } @@ -983,7 +983,7 @@ class BlockFactory{ continue; } - if(!$override and $this->isRegistered($id, $m)){ + if(!$override && $this->isRegistered($id, $m)){ throw new \InvalidArgumentException("Block registration " . get_class($block) . " has states which conflict with other blocks"); } @@ -1036,7 +1036,7 @@ class BlockFactory{ * Deserializes a block from the provided legacy ID and legacy meta. */ public function get(int $id, int $meta) : Block{ - if($meta < 0 or $meta >= (1 << Block::INTERNAL_METADATA_BITS)){ + if($meta < 0 || $meta >= (1 << Block::INTERNAL_METADATA_BITS)){ throw new \InvalidArgumentException("Block meta value $meta is out of bounds"); } @@ -1062,7 +1062,7 @@ class BlockFactory{ */ public function isRegistered(int $id, int $meta = 0) : bool{ $b = $this->fullList[($id << Block::INTERNAL_METADATA_BITS) | $meta]; - return $b !== null and !($b instanceof UnknownBlock); + return $b !== null && !($b instanceof UnknownBlock); } /** diff --git a/src/block/BrewingStand.php b/src/block/BrewingStand.php index 87f8d3c1f..e0366b7d3 100644 --- a/src/block/BrewingStand.php +++ b/src/block/BrewingStand.php @@ -116,7 +116,7 @@ class BrewingStand extends Transparent{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($player instanceof Player){ $stand = $this->position->getWorld()->getTile($this->position); - if($stand instanceof TileBrewingStand and $stand->canOpenWith($item->getCustomName())){ + if($stand instanceof TileBrewingStand && $stand->canOpenWith($item->getCustomName())){ $player->setCurrentWindow($stand->getInventory()); } } diff --git a/src/block/Cactus.php b/src/block/Cactus.php index 56ee7017f..2802c4966 100644 --- a/src/block/Cactus.php +++ b/src/block/Cactus.php @@ -82,7 +82,7 @@ class Cactus extends Transparent{ public function onNearbyBlockChange() : void{ $down = $this->getSide(Facing::DOWN); - if($down->getId() !== BlockLegacyIds::SAND and !$down->isSameType($this)){ + if($down->getId() !== BlockLegacyIds::SAND && !$down->isSameType($this)){ $this->position->getWorld()->useBreakOn($this->position); }else{ foreach(Facing::HORIZONTAL as $side){ @@ -129,7 +129,7 @@ class Cactus extends Transparent{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $down = $this->getSide(Facing::DOWN); - if($down->getId() === BlockLegacyIds::SAND or $down->isSameType($this)){ + if($down->getId() === BlockLegacyIds::SAND || $down->isSameType($this)){ foreach(Facing::HORIZONTAL as $side){ if($this->getSide($side)->isSolid()){ return false; diff --git a/src/block/Chest.php b/src/block/Chest.php index 92cc44f9b..c270246e5 100644 --- a/src/block/Chest.php +++ b/src/block/Chest.php @@ -51,10 +51,10 @@ class Chest extends Transparent{ foreach([false, true] as $clockwise){ $side = Facing::rotateY($this->facing, $clockwise); $c = $this->getSide($side); - if($c instanceof Chest and $c->isSameType($this) and $c->facing === $this->facing){ + if($c instanceof Chest && $c->isSameType($this) && $c->facing === $this->facing){ $world = $this->position->getWorld(); $pair = $world->getTile($c->position); - if($pair instanceof TileChest and !$pair->isPaired()){ + if($pair instanceof TileChest && !$pair->isPaired()){ [$left, $right] = $clockwise ? [$c, $this] : [$this, $c]; $ev = new ChestPairEvent($left, $right); $ev->call(); @@ -75,8 +75,8 @@ class Chest extends Transparent{ $chest = $this->position->getWorld()->getTile($this->position); if($chest instanceof TileChest){ if( - !$this->getSide(Facing::UP)->isTransparent() or - (($pair = $chest->getPair()) !== null and !$pair->getBlock()->getSide(Facing::UP)->isTransparent()) or + !$this->getSide(Facing::UP)->isTransparent() || + (($pair = $chest->getPair()) !== null && !$pair->getBlock()->getSide(Facing::UP)->isTransparent()) || !$chest->canOpenWith($item->getCustomName()) ){ return true; diff --git a/src/block/CocoaBlock.php b/src/block/CocoaBlock.php index efcc4590f..ef19356e8 100644 --- a/src/block/CocoaBlock.php +++ b/src/block/CocoaBlock.php @@ -86,7 +86,7 @@ class CocoaBlock extends Transparent{ } public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ - if(Facing::axis($face) !== Axis::Y and $this->canAttachTo($blockClicked)){ + if(Facing::axis($face) !== Axis::Y && $this->canAttachTo($blockClicked)){ $this->facing = $face; return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); } diff --git a/src/block/Crops.php b/src/block/Crops.php index c7f201b41..054fed254 100644 --- a/src/block/Crops.php +++ b/src/block/Crops.php @@ -69,7 +69,7 @@ abstract class Crops extends Flowable{ } public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ - if($this->age < 7 and $item instanceof Fertilizer){ + if($this->age < 7 && $item instanceof Fertilizer){ $block = clone $this; $block->age += mt_rand(2, 5); if($block->age > 7){ @@ -100,7 +100,7 @@ abstract class Crops extends Flowable{ } public function onRandomTick() : void{ - if($this->age < 7 and mt_rand(0, 2) === 1){ + if($this->age < 7 && mt_rand(0, 2) === 1){ $block = clone $this; ++$block->age; $ev = new BlockGrowEvent($this, $block); diff --git a/src/block/Dirt.php b/src/block/Dirt.php index 9264c0808..390098216 100644 --- a/src/block/Dirt.php +++ b/src/block/Dirt.php @@ -59,7 +59,7 @@ class Dirt extends Opaque{ } public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ - if($face === Facing::UP and $item instanceof Hoe){ + if($face === Facing::UP && $item instanceof Hoe){ $item->applyDamage(1); $newBlock = $this->coarse ? VanillaBlocks::DIRT() : VanillaBlocks::FARMLAND(); diff --git a/src/block/Door.php b/src/block/Door.php index 74a9f1b78..a52e51d9d 100644 --- a/src/block/Door.php +++ b/src/block/Door.php @@ -72,7 +72,7 @@ class Door extends Transparent{ //copy door properties from other half $other = $this->getSide($this->top ? Facing::DOWN : Facing::UP); - if($other instanceof Door and $other->isSameType($this)){ + if($other instanceof Door && $other->isSameType($this)){ if($this->top){ $this->facing = $other->facing; $this->open = $other->open; @@ -129,7 +129,7 @@ class Door extends Transparent{ if($face === Facing::UP){ $blockUp = $this->getSide(Facing::UP); $blockDown = $this->getSide(Facing::DOWN); - if(!$blockUp->canBeReplaced() or $blockDown->isTransparent()){ + if(!$blockUp->canBeReplaced() || $blockDown->isTransparent()){ return false; } @@ -140,7 +140,7 @@ class Door extends Transparent{ $next = $this->getSide(Facing::rotateY($this->facing, false)); $next2 = $this->getSide(Facing::rotateY($this->facing, true)); - if($next->isSameType($this) or (!$next2->isTransparent() and $next->isTransparent())){ //Door hinge + if($next->isSameType($this) || (!$next2->isTransparent() && $next->isTransparent())){ //Door hinge $this->hingeRight = true; } @@ -158,7 +158,7 @@ class Door extends Transparent{ $this->open = !$this->open; $other = $this->getSide($this->top ? Facing::DOWN : Facing::UP); - if($other instanceof Door and $other->isSameType($this)){ + if($other instanceof Door && $other->isSameType($this)){ $other->open = $this->open; $this->position->getWorld()->setBlock($other->position, $other); } diff --git a/src/block/DoublePlant.php b/src/block/DoublePlant.php index 00d361832..155a8e59d 100644 --- a/src/block/DoublePlant.php +++ b/src/block/DoublePlant.php @@ -55,7 +55,7 @@ class DoublePlant extends Flowable{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $id = $blockReplace->getSide(Facing::DOWN)->getId(); - if(($id === BlockLegacyIds::GRASS or $id === BlockLegacyIds::DIRT) and $blockReplace->getSide(Facing::UP)->canBeReplaced()){ + if(($id === BlockLegacyIds::GRASS || $id === BlockLegacyIds::DIRT) && $blockReplace->getSide(Facing::UP)->canBeReplaced()){ $top = clone $this; $top->top = true; $tx->addBlock($blockReplace->position, $this)->addBlock($blockReplace->position->getSide(Facing::UP), $top); @@ -72,14 +72,14 @@ class DoublePlant extends Flowable{ $other = $this->getSide($this->top ? Facing::DOWN : Facing::UP); return ( - $other instanceof DoublePlant and - $other->isSameType($this) and + $other instanceof DoublePlant && + $other->isSameType($this) && $other->top !== $this->top ); } public function onNearbyBlockChange() : void{ - if(!$this->isValidHalfPlant() or (!$this->top and $this->getSide(Facing::DOWN)->isTransparent())){ + if(!$this->isValidHalfPlant() || (!$this->top && $this->getSide(Facing::DOWN)->isTransparent())){ $this->position->getWorld()->useBreakOn($this->position); } } diff --git a/src/block/DoubleTallGrass.php b/src/block/DoubleTallGrass.php index 6fee40e32..f3d98b265 100644 --- a/src/block/DoubleTallGrass.php +++ b/src/block/DoubleTallGrass.php @@ -34,7 +34,7 @@ class DoubleTallGrass extends DoublePlant{ } public function getDropsForIncompatibleTool(Item $item) : array{ - if($this->top and mt_rand(0, 7) === 0){ + if($this->top && mt_rand(0, 7) === 0){ return [VanillaItems::WHEAT_SEEDS()]; } return []; diff --git a/src/block/EndRod.php b/src/block/EndRod.php index 39c28a097..18fd438b5 100644 --- a/src/block/EndRod.php +++ b/src/block/EndRod.php @@ -46,7 +46,7 @@ class EndRod extends Flowable{ } public function readStateFromData(int $id, int $stateMeta) : void{ - if($stateMeta !== 0 and $stateMeta !== 1){ + if($stateMeta !== 0 && $stateMeta !== 1){ $stateMeta ^= 1; } @@ -59,7 +59,7 @@ class EndRod extends Flowable{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $this->facing = $face; - if($blockClicked instanceof EndRod and $blockClicked->facing === $this->facing){ + if($blockClicked instanceof EndRod && $blockClicked->facing === $this->facing){ $this->facing = Facing::opposite($face); } diff --git a/src/block/EnderChest.php b/src/block/EnderChest.php index e37632008..54dba5277 100644 --- a/src/block/EnderChest.php +++ b/src/block/EnderChest.php @@ -52,7 +52,7 @@ class EnderChest extends Transparent{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($player instanceof Player){ $enderChest = $this->position->getWorld()->getTile($this->position); - if($enderChest instanceof TileEnderChest and $this->getSide(Facing::UP)->isTransparent()){ + if($enderChest instanceof TileEnderChest && $this->getSide(Facing::UP)->isTransparent()){ $enderChest->setViewerCount($enderChest->getViewerCount() + 1); $player->setCurrentWindow(new EnderChestInventory($this->position, $player->getEnderInventory())); } diff --git a/src/block/Fence.php b/src/block/Fence.php index 0ee3cdaf1..cbcdd62e9 100644 --- a/src/block/Fence.php +++ b/src/block/Fence.php @@ -41,7 +41,7 @@ class Fence extends Transparent{ foreach(Facing::HORIZONTAL as $facing){ $block = $this->getSide($facing); - if($block instanceof static or $block instanceof FenceGate or ($block->isSolid() and !$block->isTransparent())){ + if($block instanceof static || $block instanceof FenceGate || ($block->isSolid() && !$block->isTransparent())){ $this->connections[$facing] = true; }else{ unset($this->connections[$facing]); @@ -61,7 +61,7 @@ class Fence extends Transparent{ $connectWest = isset($this->connections[Facing::WEST]); $connectEast = isset($this->connections[Facing::EAST]); - if($connectWest or $connectEast){ + if($connectWest || $connectEast){ //X axis (west/east) $bbs[] = AxisAlignedBB::one() ->squash(Axis::Z, $inset) @@ -73,7 +73,7 @@ class Fence extends Transparent{ $connectNorth = isset($this->connections[Facing::NORTH]); $connectSouth = isset($this->connections[Facing::SOUTH]); - if($connectNorth or $connectSouth){ + if($connectNorth || $connectSouth){ //Z axis (north/south) $bbs[] = AxisAlignedBB::one() ->squash(Axis::X, $inset) diff --git a/src/block/FenceGate.php b/src/block/FenceGate.php index 32d79eba3..4255ee5ef 100644 --- a/src/block/FenceGate.php +++ b/src/block/FenceGate.php @@ -80,7 +80,7 @@ class FenceGate extends Transparent{ private function checkInWall() : bool{ return ( - $this->getSide(Facing::rotateY($this->facing, false)) instanceof Wall or + $this->getSide(Facing::rotateY($this->facing, false)) instanceof Wall || $this->getSide(Facing::rotateY($this->facing, true)) instanceof Wall ); } @@ -105,7 +105,7 @@ class FenceGate extends Transparent{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $this->open = !$this->open; - if($this->open and $player !== null){ + if($this->open && $player !== null){ $playerFacing = $player->getHorizontalFacing(); if($playerFacing === Facing::opposite($this->facing)){ $this->facing = $playerFacing; diff --git a/src/block/Fire.php b/src/block/Fire.php index adf6209a3..1b73882b0 100644 --- a/src/block/Fire.php +++ b/src/block/Fire.php @@ -99,7 +99,7 @@ class Fire extends Flowable{ } public function onNearbyBlockChange() : void{ - if(!$this->getSide(Facing::DOWN)->isSolid() and !$this->hasAdjacentFlammableBlocks()){ + if(!$this->getSide(Facing::DOWN)->isSolid() && !$this->hasAdjacentFlammableBlocks()){ $this->position->getWorld()->setBlock($this->position, VanillaBlocks::AIR()); }else{ $this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, mt_rand(30, 40)); @@ -114,7 +114,7 @@ class Fire extends Flowable{ $down = $this->getSide(Facing::DOWN); $result = null; - if($this->age < 15 and mt_rand(0, 2) === 0){ + if($this->age < 15 && mt_rand(0, 2) === 0){ $this->age++; $result = $this; } @@ -123,13 +123,13 @@ class Fire extends Flowable{ if(!$down->burnsForever()){ //TODO: check rain if($this->age === 15){ - if(!$down->isFlammable() and mt_rand(0, 3) === 3){ //1/4 chance to extinguish + if(!$down->isFlammable() && mt_rand(0, 3) === 3){ //1/4 chance to extinguish $canSpread = false; $result = VanillaBlocks::AIR(); } }elseif(!$this->hasAdjacentFlammableBlocks()){ $canSpread = false; - if(!$down->isSolid() or $this->age > 3){ + if(!$down->isSolid() || $this->age > 3){ $result = VanillaBlocks::AIR(); } } @@ -209,7 +209,7 @@ class Fire extends Flowable{ for($z = -1; $z <= 1; ++$z){ $targetZ = $z + (int) $this->position->z; for($x = -1; $x <= 1; ++$x){ - if($x === 0 and $y === 0 and $z === 0){ + if($x === 0 && $y === 0 && $z === 0){ continue; } $targetX = $x + (int) $this->position->x; @@ -241,7 +241,7 @@ class Fire extends Flowable{ $maxChance = intdiv($encouragement + 40 + $difficultyChanceIncrease, $ageDivisor); //TODO: max chance is lowered by half in humid biomes - if($maxChance > 0 and mt_rand(0, $randomBound - 1) <= $maxChance){ + if($maxChance > 0 && mt_rand(0, $randomBound - 1) <= $maxChance){ $new = clone $this; $new->age = min(15, $this->age + (mt_rand(0, 4) >> 2)); $this->spreadBlock($block, $new); diff --git a/src/block/Flower.php b/src/block/Flower.php index a7e10dfab..ff2d0344b 100644 --- a/src/block/Flower.php +++ b/src/block/Flower.php @@ -33,7 +33,7 @@ class Flower extends Flowable{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $down = $this->getSide(Facing::DOWN); - if($down->getId() === BlockLegacyIds::GRASS or $down->getId() === BlockLegacyIds::DIRT or $down->getId() === BlockLegacyIds::FARMLAND){ + if($down->getId() === BlockLegacyIds::GRASS || $down->getId() === BlockLegacyIds::DIRT || $down->getId() === BlockLegacyIds::FARMLAND){ return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); } diff --git a/src/block/FlowerPot.php b/src/block/FlowerPot.php index 79e8e80b1..6dc21eb44 100644 --- a/src/block/FlowerPot.php +++ b/src/block/FlowerPot.php @@ -69,7 +69,7 @@ class FlowerPot extends Flowable{ /** @return $this */ public function setPlant(?Block $plant) : self{ - if($plant === null or $plant instanceof Air){ + if($plant === null || $plant instanceof Air){ $this->plant = null; }else{ $this->plant = clone $plant; @@ -83,12 +83,12 @@ class FlowerPot extends Flowable{ } return - $block instanceof Cactus or - $block instanceof DeadBush or - $block instanceof Flower or - $block instanceof RedMushroom or - $block instanceof Sapling or - ($block instanceof TallGrass and $block->getIdInfo()->getVariant() === BlockLegacyMetadata::TALLGRASS_FERN); //TODO: clean up + $block instanceof Cactus || + $block instanceof DeadBush || + $block instanceof Flower || + $block instanceof RedMushroom || + $block instanceof Sapling || + ($block instanceof TallGrass && $block->getIdInfo()->getVariant() === BlockLegacyMetadata::TALLGRASS_FERN); //TODO: clean up //TODO: bamboo } diff --git a/src/block/FrostedIce.php b/src/block/FrostedIce.php index 3f7c0ef10..217263e92 100644 --- a/src/block/FrostedIce.php +++ b/src/block/FrostedIce.php @@ -63,7 +63,7 @@ class FrostedIce extends Ice{ } public function onRandomTick() : void{ - if((!$this->checkAdjacentBlocks(4) or mt_rand(0, 2) === 0) and + if((!$this->checkAdjacentBlocks(4) || mt_rand(0, 2) === 0) && $this->position->getWorld()->getHighestAdjacentFullLightAt($this->position->x, $this->position->y, $this->position->z) >= 12 - $this->age){ if($this->tryMelt()){ foreach($this->getAllSides() as $block){ @@ -85,11 +85,11 @@ class FrostedIce extends Ice{ $found = 0; for($x = -1; $x <= 1; ++$x){ for($z = -1; $z <= 1; ++$z){ - if($x === 0 and $z === 0){ + if($x === 0 && $z === 0){ continue; } if( - $this->position->getWorld()->getBlockAt($this->position->x + $x, $this->position->y, $this->position->z + $z) instanceof FrostedIce and + $this->position->getWorld()->getBlockAt($this->position->x + $x, $this->position->y, $this->position->z + $z) instanceof FrostedIce && ++$found >= $requirement ){ return true; diff --git a/src/block/Furnace.php b/src/block/Furnace.php index c49ffa35b..d4b74ea7c 100644 --- a/src/block/Furnace.php +++ b/src/block/Furnace.php @@ -73,7 +73,7 @@ class Furnace extends Opaque{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($player instanceof Player){ $furnace = $this->position->getWorld()->getTile($this->position); - if($furnace instanceof TileFurnace and $furnace->canOpenWith($item->getCustomName())){ + if($furnace instanceof TileFurnace && $furnace->canOpenWith($item->getCustomName())){ $player->setCurrentWindow($furnace->getInventory()); } } @@ -83,7 +83,7 @@ class Furnace extends Opaque{ public function onScheduledUpdate() : void{ $furnace = $this->position->getWorld()->getTile($this->position); - if($furnace instanceof TileFurnace and $furnace->onUpdate()){ + if($furnace instanceof TileFurnace && $furnace->onUpdate()){ $this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, 1); //TODO: check this } } diff --git a/src/block/Grass.php b/src/block/Grass.php index 08565455f..82d42c55f 100644 --- a/src/block/Grass.php +++ b/src/block/Grass.php @@ -54,7 +54,7 @@ class Grass extends Opaque{ public function onRandomTick() : void{ $lightAbove = $this->position->getWorld()->getFullLightAt($this->position->x, $this->position->y + 1, $this->position->z); - if($lightAbove < 4 and $this->position->getWorld()->getBlockAt($this->position->x, $this->position->y + 1, $this->position->z)->getLightFilter() >= 2){ + if($lightAbove < 4 && $this->position->getWorld()->getBlockAt($this->position->x, $this->position->y + 1, $this->position->z)->getLightFilter() >= 2){ //grass dies $ev = new BlockSpreadEvent($this, $this, VanillaBlocks::DIRT()); $ev->call(); @@ -70,9 +70,9 @@ class Grass extends Opaque{ $b = $this->position->getWorld()->getBlockAt($x, $y, $z); if( - !($b instanceof Dirt) or - $b->isCoarse() or - $this->position->getWorld()->getFullLightAt($x, $y + 1, $z) < 4 or + !($b instanceof Dirt) || + $b->isCoarse() || + $this->position->getWorld()->getFullLightAt($x, $y + 1, $z) < 4 || $this->position->getWorld()->getBlockAt($x, $y + 1, $z)->getLightFilter() >= 2 ){ continue; @@ -103,7 +103,7 @@ class Grass extends Opaque{ $this->position->getWorld()->setBlock($this->position, $newBlock); return true; - }elseif($item instanceof Shovel and $this->getSide(Facing::UP)->getId() === BlockLegacyIds::AIR){ + }elseif($item instanceof Shovel && $this->getSide(Facing::UP)->getId() === BlockLegacyIds::AIR){ $item->applyDamage(1); $newBlock = VanillaBlocks::GRASS_PATH(); $this->position->getWorld()->addSound($this->position->add(0.5, 0.5, 0.5), new ItemUseOnBlockSound($newBlock)); diff --git a/src/block/Ice.php b/src/block/Ice.php index f41426ead..eb7d6a1df 100644 --- a/src/block/Ice.php +++ b/src/block/Ice.php @@ -39,7 +39,7 @@ class Ice extends Transparent{ } public function onBreak(Item $item, ?Player $player = null) : bool{ - if(($player === null or $player->isSurvival()) and !$item->hasEnchantment(VanillaEnchantments::SILK_TOUCH())){ + if(($player === null || $player->isSurvival()) && !$item->hasEnchantment(VanillaEnchantments::SILK_TOUCH())){ $this->position->getWorld()->setBlock($this->position, VanillaBlocks::WATER()); return true; } diff --git a/src/block/ItemFrame.php b/src/block/ItemFrame.php index aff9f6566..270938d75 100644 --- a/src/block/ItemFrame.php +++ b/src/block/ItemFrame.php @@ -86,7 +86,7 @@ class ItemFrame extends Flowable{ /** @return $this */ public function setFramedItem(?Item $item) : self{ - if($item === null or $item->isNull()){ + if($item === null || $item->isNull()){ $this->framedItem = null; $this->itemRotation = 0; }else{ @@ -161,7 +161,7 @@ class ItemFrame extends Flowable{ } public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ - if($face === Facing::DOWN or $face === Facing::UP or !$blockClicked->isSolid()){ + if($face === Facing::DOWN || $face === Facing::UP || !$blockClicked->isSolid()){ return false; } @@ -172,7 +172,7 @@ class ItemFrame extends Flowable{ public function getDropsForCompatibleTool(Item $item) : array{ $drops = parent::getDropsForCompatibleTool($item); - if($this->framedItem !== null and lcg_value() <= $this->itemDropChance){ + if($this->framedItem !== null && lcg_value() <= $this->itemDropChance){ $drops[] = clone $this->framedItem; } diff --git a/src/block/Ladder.php b/src/block/Ladder.php index f76a28b6f..bd4de7e0f 100644 --- a/src/block/Ladder.php +++ b/src/block/Ladder.php @@ -65,7 +65,7 @@ class Ladder extends Transparent{ } public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ - if(!$blockClicked->isTransparent() and Facing::axis($face) !== Axis::Y){ + if(!$blockClicked->isTransparent() && Facing::axis($face) !== Axis::Y){ $this->facing = $face; return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); } diff --git a/src/block/Lantern.php b/src/block/Lantern.php index 4bd2f5918..516374a4d 100644 --- a/src/block/Lantern.php +++ b/src/block/Lantern.php @@ -77,11 +77,11 @@ class Lantern extends Transparent{ } public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ - if(!$this->canAttachTo($this->position->getWorld()->getBlock($blockReplace->getPosition()->up())) and !$this->canAttachTo($this->position->getWorld()->getBlock($blockReplace->getPosition()->down()))){ + if(!$this->canAttachTo($this->position->getWorld()->getBlock($blockReplace->getPosition()->up())) && !$this->canAttachTo($this->position->getWorld()->getBlock($blockReplace->getPosition()->down()))){ return false; } - $this->hanging = ($face === Facing::DOWN or !$this->canAttachTo($this->position->getWorld()->getBlock($blockReplace->getPosition()->down()))); + $this->hanging = ($face === Facing::DOWN || !$this->canAttachTo($this->position->getWorld()->getBlock($blockReplace->getPosition()->down()))); return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); } diff --git a/src/block/Leaves.php b/src/block/Leaves.php index 03c99936e..7ca55c6dc 100644 --- a/src/block/Leaves.php +++ b/src/block/Leaves.php @@ -96,7 +96,7 @@ class Leaves extends Transparent{ return true; } - if($block->getId() === $this->getId() and $distance <= 4){ + if($block->getId() === $this->getId() && $distance <= 4){ foreach(Facing::ALL as $side){ if($this->findLog($pos->getSide($side), $visited, $distance + 1)){ return true; @@ -108,7 +108,7 @@ class Leaves extends Transparent{ } public function onNearbyBlockChange() : void{ - if(!$this->noDecay and !$this->checkDecay){ + if(!$this->noDecay && !$this->checkDecay){ $this->checkDecay = true; $this->position->getWorld()->setBlock($this->position, $this, false); } @@ -119,10 +119,10 @@ class Leaves extends Transparent{ } public function onRandomTick() : void{ - if(!$this->noDecay and $this->checkDecay){ + if(!$this->noDecay && $this->checkDecay){ $ev = new LeavesDecayEvent($this); $ev->call(); - if($ev->isCancelled() or $this->findLog($this->position)){ + if($ev->isCancelled() || $this->findLog($this->position)){ $this->checkDecay = false; $this->position->getWorld()->setBlock($this->position, $this, false); }else{ @@ -145,7 +145,7 @@ class Leaves extends Transparent{ if(mt_rand(1, 20) === 1){ //Saplings $drops[] = ItemFactory::getInstance()->get(ItemIds::SAPLING, $this->treeType->getMagicNumber()); } - if(($this->treeType->equals(TreeType::OAK()) or $this->treeType->equals(TreeType::DARK_OAK())) and mt_rand(1, 200) === 1){ //Apples + if(($this->treeType->equals(TreeType::OAK()) || $this->treeType->equals(TreeType::DARK_OAK())) && mt_rand(1, 200) === 1){ //Apples $drops[] = VanillaItems::APPLE(); } diff --git a/src/block/Liquid.php b/src/block/Liquid.php index 6e3c8df35..46e9c487d 100644 --- a/src/block/Liquid.php +++ b/src/block/Liquid.php @@ -131,7 +131,7 @@ abstract class Liquid extends Transparent{ abstract public function getBucketEmptySound() : Sound; public function isSource() : bool{ - return !$this->falling and $this->decay === 0; + return !$this->falling && $this->decay === 0; } /** @@ -154,7 +154,7 @@ abstract class Liquid extends Transparent{ } protected function getEffectiveFlowDecay(Block $block) : int{ - if(!($block instanceof Liquid) or !$block->isSameType($this)){ + if(!($block instanceof Liquid) || !$block->isSameType($this)){ return -1; } @@ -279,7 +279,7 @@ abstract class Liquid extends Transparent{ $newDecay = $smallestFlowDecay + $multiplier; $falling = false; - if($newDecay >= 8 or $smallestFlowDecay < 0){ + if($newDecay >= 8 || $smallestFlowDecay < 0){ $newDecay = -1; } @@ -290,14 +290,14 @@ abstract class Liquid extends Transparent{ $minAdjacentSources = $this->getMinAdjacentSourcesToFormSource(); if($minAdjacentSources !== null && $this->adjacentSources >= $minAdjacentSources){ $bottomBlock = $world->getBlockAt($this->position->x, $this->position->y - 1, $this->position->z); - if($bottomBlock->isSolid() or ($bottomBlock instanceof Liquid and $bottomBlock->isSameType($this) and $bottomBlock->isSource())){ + if($bottomBlock->isSolid() || ($bottomBlock instanceof Liquid && $bottomBlock->isSameType($this) && $bottomBlock->isSource())){ $newDecay = 0; $falling = false; } } - if($falling !== $this->falling or (!$falling and $newDecay !== $this->decay)){ - if(!$falling and $newDecay < 0){ + if($falling !== $this->falling || (!$falling && $newDecay !== $this->decay)){ + if(!$falling && $newDecay < 0){ $world->setBlock($this->position, VanillaBlocks::AIR()); return; } @@ -312,7 +312,7 @@ abstract class Liquid extends Transparent{ $this->flowIntoBlock($bottomBlock, 0, true); - if($this->isSource() or !$bottomBlock->canBeFlowedInto()){ + if($this->isSource() || !$bottomBlock->canBeFlowedInto()){ if($this->falling){ $adjacentDecay = 1; //falling liquid behaves like source block }else{ @@ -331,7 +331,7 @@ abstract class Liquid extends Transparent{ } protected function flowIntoBlock(Block $block, int $newFlowDecay, bool $falling) : void{ - if($this->canFlowInto($block) and !($block instanceof Liquid)){ + if($this->canFlowInto($block) && !($block instanceof Liquid)){ $new = clone $this; $new->falling = $falling; $new->decay = $falling ? 0 : $newFlowDecay; @@ -350,7 +350,7 @@ abstract class Liquid extends Transparent{ /** @phpstan-impure */ private function getSmallestFlowDecay(Block $block, int $decay) : int{ - if(!($block instanceof Liquid) or !$block->isSameType($this)){ + if(!($block instanceof Liquid) || !$block->isSameType($this)){ return $decay; } @@ -381,8 +381,8 @@ abstract class Liquid extends Transparent{ protected function canFlowInto(Block $block) : bool{ return - $this->position->getWorld()->isInWorld($block->position->x, $block->position->y, $block->position->z) and - $block->canBeFlowedInto() and - !($block instanceof Liquid and $block->isSource()); //TODO: I think this should only be liquids of the same type + $this->position->getWorld()->isInWorld($block->position->x, $block->position->y, $block->position->z) && + $block->canBeFlowedInto() && + !($block instanceof Liquid && $block->isSource()); //TODO: I think this should only be liquids of the same type } } diff --git a/src/block/Magma.php b/src/block/Magma.php index e698a6431..fbff583aa 100644 --- a/src/block/Magma.php +++ b/src/block/Magma.php @@ -39,7 +39,7 @@ class Magma extends Opaque{ } public function onEntityInside(Entity $entity) : bool{ - if($entity instanceof Living and !$entity->isSneaking()){ + if($entity instanceof Living && !$entity->isSneaking()){ $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1); $entity->attack($ev); } diff --git a/src/block/NetherPortal.php b/src/block/NetherPortal.php index b8c73d0a7..5ba1f0d41 100644 --- a/src/block/NetherPortal.php +++ b/src/block/NetherPortal.php @@ -53,7 +53,7 @@ class NetherPortal extends Transparent{ * @return $this */ public function setAxis(int $axis) : self{ - if($axis !== Axis::X and $axis !== Axis::Z){ + if($axis !== Axis::X && $axis !== Axis::Z){ throw new \InvalidArgumentException("Invalid axis"); } $this->axis = $axis; diff --git a/src/block/NetherWartPlant.php b/src/block/NetherWartPlant.php index 5809c8a4e..c6b441915 100644 --- a/src/block/NetherWartPlant.php +++ b/src/block/NetherWartPlant.php @@ -79,7 +79,7 @@ class NetherWartPlant extends Flowable{ } public function onRandomTick() : void{ - if($this->age < 3 and mt_rand(0, 10) === 0){ //Still growing + if($this->age < 3 && mt_rand(0, 10) === 0){ //Still growing $block = clone $this; $block->age++; $ev = new BlockGrowEvent($this, $block); diff --git a/src/block/Note.php b/src/block/Note.php index d8ff22402..1dc24733a 100644 --- a/src/block/Note.php +++ b/src/block/Note.php @@ -59,7 +59,7 @@ class Note extends Opaque{ /** @return $this */ public function setPitch(int $pitch) : self{ - if($pitch < self::MIN_PITCH or $pitch > self::MAX_PITCH){ + if($pitch < self::MIN_PITCH || $pitch > self::MAX_PITCH){ throw new \InvalidArgumentException("Pitch must be in range " . self::MIN_PITCH . " - " . self::MAX_PITCH); } $this->pitch = $pitch; diff --git a/src/block/Pumpkin.php b/src/block/Pumpkin.php index 57d305806..835c68f31 100644 --- a/src/block/Pumpkin.php +++ b/src/block/Pumpkin.php @@ -34,7 +34,7 @@ use function in_array; class Pumpkin extends Opaque{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ - if($item instanceof Shears and in_array($face, Facing::HORIZONTAL, true)){ + if($item instanceof Shears && in_array($face, Facing::HORIZONTAL, true)){ $item->applyDamage(1); $this->position->getWorld()->setBlock($this->position, VanillaBlocks::CARVED_PUMPKIN()->setFacing($face)); $this->position->getWorld()->dropItem($this->position->add(0.5, 0.5, 0.5), VanillaItems::PUMPKIN_SEEDS()->setCount(1)); diff --git a/src/block/RedstoneComparator.php b/src/block/RedstoneComparator.php index 764676953..95471bd98 100644 --- a/src/block/RedstoneComparator.php +++ b/src/block/RedstoneComparator.php @@ -57,7 +57,7 @@ class RedstoneComparator extends Flowable{ public function readStateFromData(int $id, int $stateMeta) : void{ $this->facing = BlockDataSerializer::readLegacyHorizontalFacing($stateMeta & 0x03); $this->isSubtractMode = ($stateMeta & BlockLegacyMetadata::REDSTONE_COMPARATOR_FLAG_SUBTRACT) !== 0; - $this->powered = ($id === $this->idInfoFlattened->getSecondId() or ($stateMeta & BlockLegacyMetadata::REDSTONE_COMPARATOR_FLAG_POWERED) !== 0); + $this->powered = ($id === $this->idInfoFlattened->getSecondId() || ($stateMeta & BlockLegacyMetadata::REDSTONE_COMPARATOR_FLAG_POWERED) !== 0); } public function writeStateToMeta() : int{ diff --git a/src/block/Sapling.php b/src/block/Sapling.php index 85e092451..9709032c5 100644 --- a/src/block/Sapling.php +++ b/src/block/Sapling.php @@ -68,7 +68,7 @@ class Sapling extends Flowable{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $down = $this->getSide(Facing::DOWN); - if($down->getId() === BlockLegacyIds::GRASS or $down->getId() === BlockLegacyIds::DIRT or $down->getId() === BlockLegacyIds::FARMLAND){ + if($down->getId() === BlockLegacyIds::GRASS || $down->getId() === BlockLegacyIds::DIRT || $down->getId() === BlockLegacyIds::FARMLAND){ return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); } @@ -96,7 +96,7 @@ class Sapling extends Flowable{ } public function onRandomTick() : void{ - if($this->position->getWorld()->getFullLightAt($this->position->getFloorX(), $this->position->getFloorY(), $this->position->getFloorZ()) >= 8 and mt_rand(1, 7) === 1){ + if($this->position->getWorld()->getFullLightAt($this->position->getFloorX(), $this->position->getFloorY(), $this->position->getFloorZ()) >= 8 && mt_rand(1, 7) === 1){ if($this->ready){ $this->grow(null); }else{ diff --git a/src/block/SeaPickle.php b/src/block/SeaPickle.php index 9110dc22c..fb931f004 100644 --- a/src/block/SeaPickle.php +++ b/src/block/SeaPickle.php @@ -83,12 +83,12 @@ class SeaPickle extends Transparent{ public function canBePlacedAt(Block $blockReplace, Vector3 $clickVector, int $face, bool $isClickedBlock) : bool{ //TODO: proper placement logic (needs a supporting face below) - return ($blockReplace instanceof SeaPickle and $blockReplace->count < 4) or parent::canBePlacedAt($blockReplace, $clickVector, $face, $isClickedBlock); + return ($blockReplace instanceof SeaPickle && $blockReplace->count < 4) || parent::canBePlacedAt($blockReplace, $clickVector, $face, $isClickedBlock); } public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $this->underwater = false; //TODO: implement this once we have new water logic in place - if($blockReplace instanceof SeaPickle and $blockReplace->count < 4){ + if($blockReplace instanceof SeaPickle && $blockReplace->count < 4){ $this->count = $blockReplace->count + 1; } diff --git a/src/block/ShulkerBox.php b/src/block/ShulkerBox.php index a81e5009d..18cd38ff8 100644 --- a/src/block/ShulkerBox.php +++ b/src/block/ShulkerBox.php @@ -91,7 +91,7 @@ class ShulkerBox extends Opaque{ $shulker = $this->position->getWorld()->getTile($this->position); if($shulker instanceof TileShulkerBox){ if( - $this->getSide($this->facing)->getId() !== BlockLegacyIds::AIR or + $this->getSide($this->facing)->getId() !== BlockLegacyIds::AIR || !$shulker->canOpenWith($item->getCustomName()) ){ return true; diff --git a/src/block/Skull.php b/src/block/Skull.php index 47476abce..b403924cf 100644 --- a/src/block/Skull.php +++ b/src/block/Skull.php @@ -140,7 +140,7 @@ class Skull extends Flowable{ } $this->facing = $face; - if($player !== null and $face === Facing::UP){ + if($player !== null && $face === Facing::UP){ $this->rotation = ((int) floor(($player->getLocation()->getYaw() * 16 / 360) + 0.5)) & 0xf; } return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); diff --git a/src/block/Slab.php b/src/block/Slab.php index 610c6ee8c..1bddeba94 100644 --- a/src/block/Slab.php +++ b/src/block/Slab.php @@ -90,11 +90,11 @@ class Slab extends Transparent{ return true; } - if($blockReplace instanceof Slab and !$blockReplace->slabType->equals(SlabType::DOUBLE()) and $blockReplace->isSameType($this)){ + if($blockReplace instanceof Slab && !$blockReplace->slabType->equals(SlabType::DOUBLE()) && $blockReplace->isSameType($this)){ if($blockReplace->slabType->equals(SlabType::TOP())){ //Trying to combine with top slab - return $clickVector->y <= 0.5 or (!$isClickedBlock and $face === Facing::UP); + return $clickVector->y <= 0.5 || (!$isClickedBlock && $face === Facing::UP); }else{ - return $clickVector->y >= 0.5 or (!$isClickedBlock and $face === Facing::DOWN); + return $clickVector->y >= 0.5 || (!$isClickedBlock && $face === Facing::DOWN); } } @@ -102,9 +102,9 @@ class Slab extends Transparent{ } public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ - if($blockReplace instanceof Slab and !$blockReplace->slabType->equals(SlabType::DOUBLE()) and $blockReplace->isSameType($this) and ( - ($blockReplace->slabType->equals(SlabType::TOP()) and ($clickVector->y <= 0.5 or $face === Facing::UP)) or - ($blockReplace->slabType->equals(SlabType::BOTTOM()) and ($clickVector->y >= 0.5 or $face === Facing::DOWN)) + if($blockReplace instanceof Slab && !$blockReplace->slabType->equals(SlabType::DOUBLE()) && $blockReplace->isSameType($this) && ( + ($blockReplace->slabType->equals(SlabType::TOP()) && ($clickVector->y <= 0.5 || $face === Facing::UP)) || + ($blockReplace->slabType->equals(SlabType::BOTTOM()) && ($clickVector->y >= 0.5 || $face === Facing::DOWN)) )){ //Clicked in empty half of existing slab $this->slabType = SlabType::DOUBLE(); diff --git a/src/block/SnowLayer.php b/src/block/SnowLayer.php index 4bea77df5..015733a76 100644 --- a/src/block/SnowLayer.php +++ b/src/block/SnowLayer.php @@ -78,7 +78,7 @@ class SnowLayer extends Flowable implements Fallable{ } private function canBeSupportedBy(Block $b) : bool{ - return $b->isSolid() or ($b instanceof SnowLayer and $b->isSameType($this) and $b->layers === 8); + return $b->isSolid() || ($b instanceof SnowLayer && $b->isSameType($this) && $b->layers === 8); } public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ diff --git a/src/block/Stair.php b/src/block/Stair.php index b4dd2c65a..39bf4ab3a 100644 --- a/src/block/Stair.php +++ b/src/block/Stair.php @@ -96,9 +96,9 @@ class Stair extends Transparent{ ->trim(Facing::opposite($topStepFace), 0.5) ->trim(Facing::opposite($this->facing), 0.5); - if($this->shape->equals(StairShape::OUTER_LEFT()) or $this->shape->equals(StairShape::OUTER_RIGHT())){ + if($this->shape->equals(StairShape::OUTER_LEFT()) || $this->shape->equals(StairShape::OUTER_RIGHT())){ $topStep->trim(Facing::rotateY($this->facing, $this->shape->equals(StairShape::OUTER_LEFT())), 0.5); - }elseif($this->shape->equals(StairShape::INNER_LEFT()) or $this->shape->equals(StairShape::INNER_RIGHT())){ + }elseif($this->shape->equals(StairShape::INNER_LEFT()) || $this->shape->equals(StairShape::INNER_RIGHT())){ //add an extra cube $bbs[] = AxisAlignedBB::one() ->trim(Facing::opposite($topStepFace), 0.5) @@ -114,8 +114,8 @@ class Stair extends Transparent{ private function getPossibleCornerFacing(bool $oppositeFacing) : ?int{ $side = $this->getSide($oppositeFacing ? Facing::opposite($this->facing) : $this->facing); return ( - $side instanceof Stair and - $side->upsideDown === $this->upsideDown and + $side instanceof Stair && + $side->upsideDown === $this->upsideDown && Facing::axis($side->facing) !== Facing::axis($this->facing) //perpendicular ) ? $side->facing : null; } @@ -124,7 +124,7 @@ class Stair extends Transparent{ if($player !== null){ $this->facing = $player->getHorizontalFacing(); } - $this->upsideDown = (($clickVector->y > 0.5 and $face !== Facing::UP) or $face === Facing::DOWN); + $this->upsideDown = (($clickVector->y > 0.5 && $face !== Facing::UP) || $face === Facing::DOWN); return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); } diff --git a/src/block/Stem.php b/src/block/Stem.php index 5904736f7..e223b18be 100644 --- a/src/block/Stem.php +++ b/src/block/Stem.php @@ -53,7 +53,7 @@ abstract class Stem extends Crops{ $side = $this->getSide(Facing::HORIZONTAL[array_rand(Facing::HORIZONTAL)]); $d = $side->getSide(Facing::DOWN); - if($side->getId() === BlockLegacyIds::AIR and ($d->getId() === BlockLegacyIds::FARMLAND or $d->getId() === BlockLegacyIds::GRASS or $d->getId() === BlockLegacyIds::DIRT)){ + if($side->getId() === BlockLegacyIds::AIR && ($d->getId() === BlockLegacyIds::FARMLAND || $d->getId() === BlockLegacyIds::GRASS || $d->getId() === BlockLegacyIds::DIRT)){ $ev = new BlockGrowEvent($side, $grow); $ev->call(); if(!$ev->isCancelled()){ diff --git a/src/block/Sugarcane.php b/src/block/Sugarcane.php index 90eef3d4b..d2c13308a 100644 --- a/src/block/Sugarcane.php +++ b/src/block/Sugarcane.php @@ -97,7 +97,7 @@ class Sugarcane extends Flowable{ public function onNearbyBlockChange() : void{ $down = $this->getSide(Facing::DOWN); - if($down->isTransparent() and !$down->isSameType($this)){ + if($down->isTransparent() && !$down->isSameType($this)){ $this->position->getWorld()->useBreakOn($this->position); } } @@ -121,7 +121,7 @@ class Sugarcane extends Flowable{ $down = $this->getSide(Facing::DOWN); if($down->isSameType($this)){ return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); - }elseif($down->getId() === BlockLegacyIds::GRASS or $down->getId() === BlockLegacyIds::DIRT or $down->getId() === BlockLegacyIds::SAND or $down->getId() === BlockLegacyIds::PODZOL){ + }elseif($down->getId() === BlockLegacyIds::GRASS || $down->getId() === BlockLegacyIds::DIRT || $down->getId() === BlockLegacyIds::SAND || $down->getId() === BlockLegacyIds::PODZOL){ foreach(Facing::HORIZONTAL as $side){ if($down->getSide($side) instanceof Water){ return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); diff --git a/src/block/SweetBerryBush.php b/src/block/SweetBerryBush.php index 4412d0cff..4983bfea4 100644 --- a/src/block/SweetBerryBush.php +++ b/src/block/SweetBerryBush.php @@ -135,7 +135,7 @@ class SweetBerryBush extends Flowable{ } public function onRandomTick() : void{ - if($this->age < self::STAGE_MATURE and mt_rand(0, 2) === 1){ + if($this->age < self::STAGE_MATURE && mt_rand(0, 2) === 1){ $block = clone $this; ++$block->age; $ev = new BlockGrowEvent($this, $block); diff --git a/src/block/TNT.php b/src/block/TNT.php index 27383e996..5af0b5267 100644 --- a/src/block/TNT.php +++ b/src/block/TNT.php @@ -86,7 +86,7 @@ class TNT extends Opaque{ } public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ - if($item instanceof FlintSteel or $item->hasEnchantment(VanillaEnchantments::FIRE_ASPECT())){ + if($item instanceof FlintSteel || $item->hasEnchantment(VanillaEnchantments::FIRE_ASPECT())){ if($item instanceof Durable){ $item->applyDamage(1); } @@ -102,7 +102,7 @@ class TNT extends Opaque{ } public function onEntityInside(Entity $entity) : bool{ - if($entity instanceof Arrow and $entity->isOnFire()){ + if($entity instanceof Arrow && $entity->isOnFire()){ $this->ignite(); return false; } diff --git a/src/block/TallGrass.php b/src/block/TallGrass.php index 7f5daf731..b77a828fe 100644 --- a/src/block/TallGrass.php +++ b/src/block/TallGrass.php @@ -39,7 +39,7 @@ class TallGrass extends Flowable{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $down = $this->getSide(Facing::DOWN)->getId(); - if($down === BlockLegacyIds::GRASS or $down === BlockLegacyIds::DIRT){ + if($down === BlockLegacyIds::GRASS || $down === BlockLegacyIds::DIRT){ return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); } diff --git a/src/block/Thin.php b/src/block/Thin.php index 3f3dc86e7..567e4e86c 100644 --- a/src/block/Thin.php +++ b/src/block/Thin.php @@ -37,7 +37,7 @@ class Thin extends Transparent{ foreach(Facing::HORIZONTAL as $facing){ $side = $this->getSide($facing); - if($side instanceof Thin or $side->isFullCube()){ + if($side instanceof Thin || $side->isFullCube()){ $this->connections[$facing] = true; }else{ unset($this->connections[$facing]); @@ -51,7 +51,7 @@ class Thin extends Transparent{ /** @var AxisAlignedBB[] $bbs */ $bbs = []; - if(isset($this->connections[Facing::WEST]) or isset($this->connections[Facing::EAST])){ + if(isset($this->connections[Facing::WEST]) || isset($this->connections[Facing::EAST])){ $bb = AxisAlignedBB::one()->squash(Axis::Z, $inset); if(!isset($this->connections[Facing::WEST])){ @@ -62,7 +62,7 @@ class Thin extends Transparent{ $bbs[] = $bb; } - if(isset($this->connections[Facing::NORTH]) or isset($this->connections[Facing::SOUTH])){ + if(isset($this->connections[Facing::NORTH]) || isset($this->connections[Facing::SOUTH])){ $bb = AxisAlignedBB::one()->squash(Axis::X, $inset); if(!isset($this->connections[Facing::NORTH])){ diff --git a/src/block/Torch.php b/src/block/Torch.php index 292bfbb18..cb5bf8fb8 100644 --- a/src/block/Torch.php +++ b/src/block/Torch.php @@ -66,16 +66,16 @@ class Torch extends Flowable{ $below = $this->getSide(Facing::DOWN); $face = Facing::opposite($this->facing); - if($this->getSide($face)->isTransparent() and !($face === Facing::DOWN and ($below->getId() === BlockLegacyIds::FENCE or $below->getId() === BlockLegacyIds::COBBLESTONE_WALL))){ + if($this->getSide($face)->isTransparent() && !($face === Facing::DOWN && ($below->getId() === BlockLegacyIds::FENCE || $below->getId() === BlockLegacyIds::COBBLESTONE_WALL))){ $this->position->getWorld()->useBreakOn($this->position); } } public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ - if($blockClicked->canBeReplaced() and !$blockClicked->getSide(Facing::DOWN)->isTransparent()){ + if($blockClicked->canBeReplaced() && !$blockClicked->getSide(Facing::DOWN)->isTransparent()){ $this->facing = Facing::UP; return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); - }elseif($face !== Facing::DOWN and (!$blockClicked->isTransparent() or ($face === Facing::UP and ($blockClicked->getId() === BlockLegacyIds::FENCE or $blockClicked->getId() === BlockLegacyIds::COBBLESTONE_WALL)))){ + }elseif($face !== Facing::DOWN && (!$blockClicked->isTransparent() || ($face === Facing::UP && ($blockClicked->getId() === BlockLegacyIds::FENCE || $blockClicked->getId() === BlockLegacyIds::COBBLESTONE_WALL)))){ $this->facing = $face; return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); }else{ diff --git a/src/block/Trapdoor.php b/src/block/Trapdoor.php index 6f9d7b34c..08cb4b200 100644 --- a/src/block/Trapdoor.php +++ b/src/block/Trapdoor.php @@ -82,7 +82,7 @@ class Trapdoor extends Transparent{ if($player !== null){ $this->facing = Facing::opposite($player->getHorizontalFacing()); } - if(($clickVector->y > 0.5 and $face !== Facing::UP) or $face === Facing::DOWN){ + if(($clickVector->y > 0.5 && $face !== Facing::UP) || $face === Facing::DOWN){ $this->top = true; } diff --git a/src/block/Vine.php b/src/block/Vine.php index b9331bc40..16f684846 100644 --- a/src/block/Vine.php +++ b/src/block/Vine.php @@ -116,7 +116,7 @@ class Vine extends Flowable{ } public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ - if(!$blockClicked->isSolid() or Facing::axis($face) === Axis::Y){ + if(!$blockClicked->isSolid() || Facing::axis($face) === Axis::Y){ return false; } @@ -134,7 +134,7 @@ class Vine extends Flowable{ $supportedFaces = $up instanceof Vine ? array_intersect_key($this->faces, $up->faces) : []; foreach($this->faces as $face){ - if(!isset($supportedFaces[$face]) and !$this->getSide($face)->isSolid()){ + if(!isset($supportedFaces[$face]) && !$this->getSide($face)->isSolid()){ unset($this->faces[$face]); $changed = true; } diff --git a/src/block/Wall.php b/src/block/Wall.php index 5a1323d14..6c827d190 100644 --- a/src/block/Wall.php +++ b/src/block/Wall.php @@ -37,7 +37,7 @@ class Wall extends Transparent{ foreach(Facing::HORIZONTAL as $facing){ $block = $this->getSide($facing); - if($block instanceof static or $block instanceof FenceGate or ($block->isSolid() and !$block->isTransparent())){ + if($block instanceof static || $block instanceof FenceGate || ($block->isSolid() && !$block->isTransparent())){ $this->connections[$facing] = $facing; }else{ unset($this->connections[$facing]); @@ -57,10 +57,10 @@ class Wall extends Transparent{ $inset = 0.25; if( - !$this->up and //if there is a block on top, it stays as a post + !$this->up && //if there is a block on top, it stays as a post ( - ($north and $south and !$west and !$east) or - (!$north and !$south and $west and $east) + ($north && $south && !$west && !$east) || + (!$north && !$south && $west && $east) ) ){ //If connected to two sides on the same axis but not any others, AND there is not a block on top, there is no post and the wall is thinner diff --git a/src/block/inventory/AnimatedBlockInventoryTrait.php b/src/block/inventory/AnimatedBlockInventoryTrait.php index e0bb9fee0..c80fced3a 100644 --- a/src/block/inventory/AnimatedBlockInventoryTrait.php +++ b/src/block/inventory/AnimatedBlockInventoryTrait.php @@ -47,7 +47,7 @@ trait AnimatedBlockInventoryTrait{ public function onOpen(Player $who) : void{ parent::onOpen($who); - if($this->getHolder()->isValid() and $this->getViewerCount() === 1){ + if($this->getHolder()->isValid() && $this->getViewerCount() === 1){ //TODO: this crap really shouldn't be managed by the inventory $this->animateBlock(true); $this->getHolder()->getWorld()->addSound($this->getHolder()->add(0.5, 0.5, 0.5), $this->getOpenSound()); @@ -57,7 +57,7 @@ trait AnimatedBlockInventoryTrait{ abstract protected function animateBlock(bool $isOpen) : void; public function onClose(Player $who) : void{ - if($this->getHolder()->isValid() and $this->getViewerCount() === 1){ + if($this->getHolder()->isValid() && $this->getViewerCount() === 1){ //TODO: this crap really shouldn't be managed by the inventory $this->animateBlock(false); $this->getHolder()->getWorld()->addSound($this->getHolder()->add(0.5, 0.5, 0.5), $this->getCloseSound()); diff --git a/src/block/tile/Chest.php b/src/block/tile/Chest.php index 67534f123..614d7f0cd 100644 --- a/src/block/tile/Chest.php +++ b/src/block/tile/Chest.php @@ -60,12 +60,12 @@ class Chest extends Spawnable implements Container, Nameable{ } public function readSaveData(CompoundTag $nbt) : void{ - if(($pairXTag = $nbt->getTag(self::TAG_PAIRX)) instanceof IntTag and ($pairZTag = $nbt->getTag(self::TAG_PAIRZ)) instanceof IntTag){ + if(($pairXTag = $nbt->getTag(self::TAG_PAIRX)) instanceof IntTag && ($pairZTag = $nbt->getTag(self::TAG_PAIRZ)) instanceof IntTag){ $pairX = $pairXTag->getValue(); $pairZ = $pairZTag->getValue(); if( - ($this->position->x === $pairX and abs($this->position->z - $pairZ) === 1) or - ($this->position->z === $pairZ and abs($this->position->x - $pairX) === 1) + ($this->position->x === $pairX && abs($this->position->z - $pairZ) === 1) || + ($this->position->z === $pairZ && abs($this->position->x - $pairX) === 1) ){ $this->pairX = $pairX; $this->pairZ = $pairZ; @@ -100,7 +100,7 @@ class Chest extends Spawnable implements Container, Nameable{ $this->inventory->removeAllViewers(); if($this->doubleInventory !== null){ - if($this->isPaired() and $this->position->getWorld()->isChunkLoaded($this->pairX >> Chunk::COORD_BIT_SIZE, $this->pairZ >> Chunk::COORD_BIT_SIZE)){ + if($this->isPaired() && $this->position->getWorld()->isChunkLoaded($this->pairX >> Chunk::COORD_BIT_SIZE, $this->pairZ >> Chunk::COORD_BIT_SIZE)){ $this->doubleInventory->removeAllViewers(); if(($pair = $this->getPair()) !== null){ $pair->doubleInventory = null; @@ -122,7 +122,7 @@ class Chest extends Spawnable implements Container, Nameable{ * @return ChestInventory|DoubleChestInventory */ public function getInventory(){ - if($this->isPaired() and $this->doubleInventory === null){ + if($this->isPaired() && $this->doubleInventory === null){ $this->checkPairing(); } return $this->doubleInventory instanceof DoubleChestInventory ? $this->doubleInventory : $this->inventory; @@ -136,7 +136,7 @@ class Chest extends Spawnable implements Container, Nameable{ } protected function checkPairing() : void{ - if($this->isPaired() and !$this->position->getWorld()->isInLoadedTerrain(new Vector3($this->pairX, $this->position->y, $this->pairZ))){ + if($this->isPaired() && !$this->position->getWorld()->isInLoadedTerrain(new Vector3($this->pairX, $this->position->y, $this->pairZ))){ //paired to a tile in an unloaded chunk $this->doubleInventory = null; @@ -167,7 +167,7 @@ class Chest extends Spawnable implements Container, Nameable{ } public function isPaired() : bool{ - return $this->pairX !== null and $this->pairZ !== null; + return $this->pairX !== null && $this->pairZ !== null; } public function getPair() : ?Chest{ @@ -182,7 +182,7 @@ class Chest extends Spawnable implements Container, Nameable{ } public function pairWith(Chest $tile) : bool{ - if($this->isPaired() or $tile->isPaired()){ + if($this->isPaired() || $tile->isPaired()){ return false; } diff --git a/src/block/tile/ContainerTrait.php b/src/block/tile/ContainerTrait.php index f3dc42390..2abe134f2 100644 --- a/src/block/tile/ContainerTrait.php +++ b/src/block/tile/ContainerTrait.php @@ -81,7 +81,7 @@ trait ContainerTrait{ * @see Container::canOpenWith() */ public function canOpenWith(string $key) : bool{ - return $this->lock === null or $this->lock === $key; + return $this->lock === null || $this->lock === $key; } /** diff --git a/src/block/tile/FlowerPot.php b/src/block/tile/FlowerPot.php index f44e73e37..221453ae6 100644 --- a/src/block/tile/FlowerPot.php +++ b/src/block/tile/FlowerPot.php @@ -42,7 +42,7 @@ class FlowerPot extends Spawnable{ private $plant = null; public function readSaveData(CompoundTag $nbt) : void{ - if(($itemIdTag = $nbt->getTag(self::TAG_ITEM)) instanceof ShortTag and ($itemMetaTag = $nbt->getTag(self::TAG_ITEM_DATA)) instanceof IntTag){ + if(($itemIdTag = $nbt->getTag(self::TAG_ITEM)) instanceof ShortTag && ($itemMetaTag = $nbt->getTag(self::TAG_ITEM_DATA)) instanceof IntTag){ try{ $this->setPlant(BlockFactory::getInstance()->get($itemIdTag->getValue(), $itemMetaTag->getValue())); }catch(\InvalidArgumentException $e){ @@ -65,7 +65,7 @@ class FlowerPot extends Spawnable{ } public function setPlant(?Block $plant) : void{ - if($plant === null or $plant instanceof Air){ + if($plant === null || $plant instanceof Air){ $this->plant = null; }else{ $this->plant = clone $plant; diff --git a/src/block/tile/Furnace.php b/src/block/tile/Furnace.php index b527317d6..21b05f504 100644 --- a/src/block/tile/Furnace.php +++ b/src/block/tile/Furnace.php @@ -132,14 +132,14 @@ abstract class Furnace extends Spawnable implements Container, Nameable{ $this->maxFuelTime = $this->remainingFuelTime = $ev->getBurnTime(); $this->onStartSmelting(); - if($this->remainingFuelTime > 0 and $ev->isBurning()){ + if($this->remainingFuelTime > 0 && $ev->isBurning()){ $this->inventory->setFuel($fuel->getFuelResidue()); } } protected function onStartSmelting() : void{ $block = $this->getBlock(); - if($block instanceof BlockFurnace and !$block->isLit()){ + if($block instanceof BlockFurnace && !$block->isLit()){ $block->setLit(true); $this->position->getWorld()->setBlock($block->getPosition(), $block); } @@ -147,7 +147,7 @@ abstract class Furnace extends Spawnable implements Container, Nameable{ protected function onStopSmelting() : void{ $block = $this->getBlock(); - if($block instanceof BlockFurnace and $block->isLit()){ + if($block instanceof BlockFurnace && $block->isLit()){ $block->setLit(false); $this->position->getWorld()->setBlock($block->getPosition(), $block); } @@ -175,16 +175,16 @@ abstract class Furnace extends Spawnable implements Container, Nameable{ $furnaceType = $this->getFurnaceType(); $smelt = $this->position->getWorld()->getServer()->getCraftingManager()->getFurnaceRecipeManager($furnaceType)->match($raw); - $canSmelt = ($smelt instanceof FurnaceRecipe and $raw->getCount() > 0 and (($smelt->getResult()->equals($product) and $product->getCount() < $product->getMaxStackSize()) or $product->isNull())); + $canSmelt = ($smelt instanceof FurnaceRecipe && $raw->getCount() > 0 && (($smelt->getResult()->equals($product) && $product->getCount() < $product->getMaxStackSize()) || $product->isNull())); - if($this->remainingFuelTime <= 0 and $canSmelt and $fuel->getFuelTime() > 0 and $fuel->getCount() > 0){ + if($this->remainingFuelTime <= 0 && $canSmelt && $fuel->getFuelTime() > 0 && $fuel->getCount() > 0){ $this->checkFuel($fuel); } if($this->remainingFuelTime > 0){ --$this->remainingFuelTime; - if($smelt instanceof FurnaceRecipe and $canSmelt){ + if($smelt instanceof FurnaceRecipe && $canSmelt){ ++$this->cookTime; if($this->cookTime >= $furnaceType->getCookDurationTicks()){ diff --git a/src/block/tile/ItemFrame.php b/src/block/tile/ItemFrame.php index eb8ff3d32..f4f679e7e 100644 --- a/src/block/tile/ItemFrame.php +++ b/src/block/tile/ItemFrame.php @@ -73,7 +73,7 @@ class ItemFrame extends Spawnable{ } public function setItem(?Item $item) : void{ - if($item !== null and !$item->isNull()){ + if($item !== null && !$item->isNull()){ $this->item = clone $item; }else{ $this->item = VanillaItems::AIR(); diff --git a/src/block/tile/Note.php b/src/block/tile/Note.php index 5157f7436..30c252593 100644 --- a/src/block/tile/Note.php +++ b/src/block/tile/Note.php @@ -34,7 +34,7 @@ class Note extends Tile{ private $pitch = 0; public function readSaveData(CompoundTag $nbt) : void{ - if(($pitch = $nbt->getByte("note", $this->pitch)) > BlockNote::MIN_PITCH and $pitch <= BlockNote::MAX_PITCH){ + if(($pitch = $nbt->getByte("note", $this->pitch)) > BlockNote::MIN_PITCH && $pitch <= BlockNote::MAX_PITCH){ $this->pitch = $pitch; } } @@ -48,7 +48,7 @@ class Note extends Tile{ } public function setPitch(int $pitch) : void{ - if($pitch < BlockNote::MIN_PITCH or $pitch > BlockNote::MAX_PITCH){ + if($pitch < BlockNote::MIN_PITCH || $pitch > BlockNote::MAX_PITCH){ throw new \InvalidArgumentException("Pitch must be in range " . BlockNote::MIN_PITCH . " - " . BlockNote::MAX_PITCH); } $this->pitch = $pitch; diff --git a/src/block/tile/Skull.php b/src/block/tile/Skull.php index 4db9ebd93..8ff40898d 100644 --- a/src/block/tile/Skull.php +++ b/src/block/tile/Skull.php @@ -59,7 +59,7 @@ class Skull extends Spawnable{ } } $rotation = $nbt->getByte(self::TAG_ROT, 0); - if($rotation >= 0 and $rotation <= 15){ + if($rotation >= 0 && $rotation <= 15){ $this->skullRotation = $rotation; } } diff --git a/src/block/utils/BlockDataSerializer.php b/src/block/utils/BlockDataSerializer.php index 0c0c8005b..4bf5e9b75 100644 --- a/src/block/utils/BlockDataSerializer.php +++ b/src/block/utils/BlockDataSerializer.php @@ -150,7 +150,7 @@ final class BlockDataSerializer{ } public static function readBoundedInt(string $name, int $v, int $min, int $max) : int{ - if($v < $min or $v > $max){ + if($v < $min || $v > $max){ throw new InvalidBlockStateException("$name should be in range $min - $max, got $v"); } return $v; diff --git a/src/block/utils/FallableTrait.php b/src/block/utils/FallableTrait.php index 33f71a890..6afcc52bf 100644 --- a/src/block/utils/FallableTrait.php +++ b/src/block/utils/FallableTrait.php @@ -50,7 +50,7 @@ trait FallableTrait{ public function onNearbyBlockChange() : void{ $pos = $this->getPosition(); $down = $pos->getWorld()->getBlock($pos->getSide(Facing::DOWN)); - if($down->getId() === BlockLegacyIds::AIR or $down instanceof Liquid or $down instanceof Fire){ + if($down->getId() === BlockLegacyIds::AIR || $down instanceof Liquid || $down instanceof Fire){ $pos->getWorld()->setBlock($pos, VanillaBlocks::AIR()); $block = $this; diff --git a/src/block/utils/MinimumCostFlowCalculator.php b/src/block/utils/MinimumCostFlowCalculator.php index 95e845791..e299caaa3 100644 --- a/src/block/utils/MinimumCostFlowCalculator.php +++ b/src/block/utils/MinimumCostFlowCalculator.php @@ -55,7 +55,7 @@ final class MinimumCostFlowCalculator{ $cost = 1000; foreach(Facing::HORIZONTAL as $j){ - if($j === $originOpposite or $j === $lastOpposite){ + if($j === $originOpposite || $j === $lastOpposite){ continue; } diff --git a/src/block/utils/SignText.php b/src/block/utils/SignText.php index 753e25bb3..4c7eeeb02 100644 --- a/src/block/utils/SignText.php +++ b/src/block/utils/SignText.php @@ -89,7 +89,7 @@ class SignText{ if(!is_int($index)){ throw new \InvalidArgumentException("Index must be an integer"); } - if($index < 0 or $index >= self::LINE_COUNT){ + if($index < 0 || $index >= self::LINE_COUNT){ throw new \InvalidArgumentException("Line index is out of bounds"); } }