From ddbb5363ef42c2fa1cbdc4f554b64d2e76764836 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 30 Jan 2019 19:10:24 +0000 Subject: [PATCH 1/8] Block->getBreakTime() now throws InvalidArgumentException on items with bad efficiency values --- src/pocketmine/block/Block.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index 344519f56..9fc9e0d85 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -39,6 +39,7 @@ use pocketmine\metadata\MetadataValue; use pocketmine\Player; use pocketmine\plugin\Plugin; use function array_merge; +use function get_class; use const PHP_INT_MAX; class Block extends Position implements BlockIds, Metadatable{ @@ -268,6 +269,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(); @@ -279,7 +281,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; From 5fe1d2e396211f49caecdb77b1bacb32693de40d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 31 Jan 2019 18:28:42 +0000 Subject: [PATCH 2/8] Level: fixed setChunk() bug introduced by eebd90ec4245abbcdddfc11fe3f4dc36a008f19e Anyone who is using getChunkPlayers() should probably check that their code is actually doing what they think it's doing. --- src/pocketmine/level/Level.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index b3066aa14..0f99e2f83 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -616,7 +616,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 @@ -2490,8 +2493,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; From d7f86f02409cf8e5f3b2af42d3de7fc81dc3d5bd Mon Sep 17 00:00:00 2001 From: Drew Date: Thu, 31 Jan 2019 13:45:25 -0500 Subject: [PATCH 3/8] Hack for client side regeneration (disable natural regeneration gamerule) (#2722) --- src/pocketmine/network/mcpe/protocol/StartGamePacket.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/network/mcpe/protocol/StartGamePacket.php b/src/pocketmine/network/mcpe/protocol/StartGamePacket.php index ae73547ca..cf891eaea 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{ /** @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 */ From d811217755b78390c739dfd791f2dbf0cf55b0f6 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 31 Jan 2019 18:47:32 +0000 Subject: [PATCH 4/8] Release 3.5.9 --- src/pocketmine/PocketMine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index 70d4de0a8..f752cec82 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -38,7 +38,7 @@ namespace pocketmine { const NAME = "PocketMine-MP"; const BASE_VERSION = "3.5.9"; - const IS_DEVELOPMENT_BUILD = true; + const IS_DEVELOPMENT_BUILD = false; const BUILD_NUMBER = 0; const MIN_PHP_VERSION = "7.2.0"; From af092b01e167b5855230c4f2c788aef524d7086d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 31 Jan 2019 18:47:57 +0000 Subject: [PATCH 5/8] 3.5.10 is next --- src/pocketmine/PocketMine.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index f752cec82..b44e31707 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -37,8 +37,8 @@ namespace pocketmine { use pocketmine\wizard\SetupWizard; const NAME = "PocketMine-MP"; - const BASE_VERSION = "3.5.9"; - const IS_DEVELOPMENT_BUILD = false; + const BASE_VERSION = "3.5.10"; + const IS_DEVELOPMENT_BUILD = true; const BUILD_NUMBER = 0; const MIN_PHP_VERSION = "7.2.0"; From 0b7ff6f2e72de4066441d27766ac75fc8dcba311 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 1 Feb 2019 14:33:06 +0000 Subject: [PATCH 6/8] Level: properly mark some functions as @internal this ensures these functions won't appear in the documentation. --- src/pocketmine/level/Level.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 0f99e2f83..07a9d19dc 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -568,7 +568,8 @@ class Level implements ChunkManager, Metadatable{ } /** - * @internal DO NOT use this from plugins, it's for internal use only. Use Server->unloadLevel() instead. + * @internal + * @see Server::unloadLevel() * * Unloads the current level from memory safely * @@ -746,8 +747,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 */ public function checkTime(){ if($this->stopTime){ @@ -758,8 +758,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. */ @@ -771,8 +770,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 * From 791b4d8ef38e166cf89b352c8c8da77519480aea Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 3 Feb 2019 11:32:47 +0000 Subject: [PATCH 7/8] SplashPotion: measure distance from eye height instead of base this fixes effect durations being off (mostly), closes #2650 there are still some minor differences, but this is closer matching than the previous version. --- src/pocketmine/entity/projectile/SplashPotion.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/entity/projectile/SplashPotion.php b/src/pocketmine/entity/projectile/SplashPotion.php index 3da50bf1c..5f9ecd9db 100644 --- a/src/pocketmine/entity/projectile/SplashPotion.php +++ b/src/pocketmine/entity/projectile/SplashPotion.php @@ -85,7 +85,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; } From 0f92ec6d2a37d078a3e418a6d8b0fa727a820e7c Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 3 Feb 2019 16:24:10 +0000 Subject: [PATCH 8/8] Level: Record a debug message when chunks are loaded without loaders --- src/pocketmine/level/Level.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 07a9d19dc..040c2bcd1 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -2839,6 +2839,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); }