diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index faf41bda6..1f5a23514 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -44,6 +44,7 @@ use pocketmine\plugin\Plugin; use function array_merge; use function assert; use function dechex; +use function get_class; use const PHP_INT_MAX; class Block extends Position implements BlockIds, Metadatable{ @@ -324,6 +325,7 @@ class Block extends Position implements BlockIds, Metadatable{ * @param Item $item * * @return float + * @throws \InvalidArgumentException if the item efficiency is not a positive number */ public function getBreakTime(Item $item) : float{ $base = $this->getHardness(); @@ -335,7 +337,7 @@ class Block extends Position implements BlockIds, Metadatable{ $efficiency = $item->getMiningEfficiency($this); if($efficiency <= 0){ - throw new \RuntimeException("Item efficiency is invalid"); + throw new \InvalidArgumentException(get_class($item) . " has invalid mining efficiency: expected >= 0, got $efficiency"); } $base /= $efficiency; diff --git a/src/pocketmine/entity/projectile/SplashPotion.php b/src/pocketmine/entity/projectile/SplashPotion.php index c718bcecb..2e3427dd9 100644 --- a/src/pocketmine/entity/projectile/SplashPotion.php +++ b/src/pocketmine/entity/projectile/SplashPotion.php @@ -89,7 +89,7 @@ class SplashPotion extends Throwable{ if(!$this->willLinger()){ foreach($this->level->getNearbyEntities($this->boundingBox->expandedCopy(4.125, 2.125, 4.125), $this) as $entity){ if($entity instanceof Living and $entity->isAlive()){ - $distanceSquared = $entity->distanceSquared($this); + $distanceSquared = $entity->add(0, $entity->getEyeHeight(), 0)->distanceSquared($this); if($distanceSquared > 16){ //4 blocks continue; } diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index b8acb3777..e17922e4a 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -561,7 +561,10 @@ class Level implements ChunkManager, Metadatable{ } /** - * Gets the players being used in a specific chunk + * @deprecated WARNING: This function has a misleading name. Contrary to what the name might imply, this function + * DOES NOT return players who are IN a chunk, rather, it returns players who can SEE the chunk. + * + * Returns a list of players who have the target chunk within their view distance. * * @param int $chunkX * @param int $chunkZ @@ -678,8 +681,7 @@ class Level implements ChunkManager, Metadatable{ } /** - * WARNING: Do not use this, it's only for internal use. - * Changes to this function won't be recorded on the version. + * @internal * * @param Player ...$targets If empty, will send to all players in the level. */ @@ -699,8 +701,7 @@ class Level implements ChunkManager, Metadatable{ } /** - * WARNING: Do not use this, it's only for internal use. - * Changes to this function won't be recorded on the version. + * @internal * * @param int $currentTick * @@ -2262,8 +2263,10 @@ class Level implements ChunkManager, Metadatable{ $oldChunk = $this->getChunk($chunkX, $chunkZ, false); if($oldChunk !== null and $oldChunk !== $chunk){ if($deleteEntitiesAndTiles){ - $players = $this->getChunkPlayers($chunkX, $chunkZ); - foreach($players as $player){ + foreach($oldChunk->getEntities() as $player){ + if(!($player instanceof Player)){ + continue; + } $chunk->addEntity($player); $oldChunk->removeEntity($player); $player->chunk = $chunk; @@ -2618,6 +2621,7 @@ class Level implements ChunkManager, Metadatable{ $loader->onChunkLoaded($chunk); } }else{ + $this->server->getLogger()->debug("Newly loaded chunk $x $z has no loaders registered, will be unloaded at next available opportunity"); $this->unloadChunkRequest($x, $z); } diff --git a/src/pocketmine/network/mcpe/protocol/StartGamePacket.php b/src/pocketmine/network/mcpe/protocol/StartGamePacket.php index a3b57ccc3..aa09e94f1 100644 --- a/src/pocketmine/network/mcpe/protocol/StartGamePacket.php +++ b/src/pocketmine/network/mcpe/protocol/StartGamePacket.php @@ -94,7 +94,9 @@ class StartGamePacket extends DataPacket implements ClientboundPacket{ /** @var bool */ public $isTexturePacksRequired = true; /** @var array */ - public $gameRules = []; //TODO: implement this + public $gameRules = [ //TODO: implement this + "naturalregeneration" => [1, false] //Hack for client side regeneration + ]; /** @var bool */ public $hasBonusChestEnabled = false; /** @var bool */