Heap of bugfixes, cleanup and PHP 7 upgrades

This commit is contained in:
Dylan K. Taylor
2017-07-13 19:18:56 +01:00
parent c2a7c2c6cd
commit 2a7b736f18
49 changed files with 114 additions and 148 deletions

View File

@ -819,7 +819,7 @@ class Level implements ChunkManager, Metadatable{
$pk->z = $z + 0.5;
$pk->data = ($data << 8) | $id;
$this->server->broadcastPacket($targets === null ? $this->getChunkPlayers($x >> 4, $z >> 4) : $targets, $pk);
$this->server->broadcastPacket($targets ?? $this->getChunkPlayers($x >> 4, $z >> 4), $pk);
}
/**
@ -1533,7 +1533,7 @@ class Level implements ChunkManager, Metadatable{
* @param int $delay
*/
public function dropItem(Vector3 $source, Item $item, Vector3 $motion = null, int $delay = 10){
$motion = $motion === null ? new Vector3(lcg_value() * 0.2 - 0.1, 0.2, lcg_value() * 0.2 - 0.1) : $motion;
$motion = $motion ?? new Vector3(lcg_value() * 0.2 - 0.1, 0.2, lcg_value() * 0.2 - 0.1);
$itemTag = $item->nbtSerialize();
$itemTag->setName("Item");
@ -1582,7 +1582,7 @@ class Level implements ChunkManager, Metadatable{
}
if($player !== null){
$ev = new BlockBreakEvent($player, $target, $item, ($player->isCreative() or $player->allowInstaBreak()));
$ev = new BlockBreakEvent($player, $target, $item, $player->isCreative() or $player->allowInstaBreak());
if(($player->isSurvival() and $item instanceof Item and !$target->isBreakable($item)) or $player->isSpectator()){
$ev->setCancelled();
@ -1633,7 +1633,7 @@ class Level implements ChunkManager, Metadatable{
$breakTime -= 1; //1 tick compensation
if(!$ev->getInstaBreak() and ((ceil($player->lastBreak * 20)) + $breakTime) > ceil(microtime(true) * 20)){
if(!$ev->getInstaBreak() and (ceil($player->lastBreak * 20) + $breakTime) > ceil(microtime(true) * 20)){
return false;
}
@ -2590,7 +2590,7 @@ class Level implements ChunkManager, Metadatable{
}
public function unloadChunk(int $x, int $z, bool $safe = true, bool $trySave = true) : bool{
if(($safe === true and $this->isChunkInUse($x, $z))){
if($safe === true and $this->isChunkInUse($x, $z)){
return false;
}