diff --git a/changelogs/3.15.md b/changelogs/3.15.md index afba42b49..930c91e70 100644 --- a/changelogs/3.15.md +++ b/changelogs/3.15.md @@ -27,3 +27,8 @@ Plugin developers should **only** update their required API to this version if y - Players no longer get pullbacks when sprinting on slabs, stairs and various other blocks when `player.anti-cheat.allow-movement-cheats` is set to `false`. (This bug has been around for over 5 years, so many of you will be used to its existence.) - Fixed entity collision box calculation not taking clip distance into account. - Entities now step up the correct height of the target block, instead of jumping into the air 0.6 blocks and falling back down. + +# 3.15.2 +- Fixed issues with preloading `SubChunk`. +- `/gc` and automatic garbage collection will now release unused heap blocks back to the OS. Previously, the PHP process might hold onto these blocks indefinitely even when not used, causing elevated real memory usage. +- Added some documentation to `FurnaceBurnEvent`. diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 5ab264768..4dbd2d881 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,7 +2,6 @@ includes: - tests/phpstan/configs/actual-problems.neon - tests/phpstan/configs/check-explicit-mixed-baseline.neon - tests/phpstan/configs/com-dotnet-magic.neon - - tests/phpstan/configs/custom-leveldb.neon - tests/phpstan/configs/ds-bugs.neon - tests/phpstan/configs/gc-hacks.neon - tests/phpstan/configs/l7-baseline.neon diff --git a/resources/pocketmine.yml b/resources/pocketmine.yml index 4f0879b35..807946f7b 100644 --- a/resources/pocketmine.yml +++ b/resources/pocketmine.yml @@ -84,7 +84,7 @@ network: #Set to 0 to compress everything, -1 to disable. batch-threshold: 256 #Compression level used when sending batched packets. Higher = more CPU, less bandwidth usage - compression-level: 7 + compression-level: 6 #Use AsyncTasks for compression. Adds half/one tick delay, less CPU load on main thread async-compression: false #Experimental, only for Windows. Tries to use UPnP to automatically port forward diff --git a/src/Server.php b/src/Server.php index ef43c9d5a..1dc6d86ae 100644 --- a/src/Server.php +++ b/src/Server.php @@ -872,10 +872,10 @@ class Server{ $netCompressionThreshold = (int) $this->configGroup->getProperty("network.batch-threshold", 256); } - $netCompressionLevel = (int) $this->configGroup->getProperty("network.compression-level", 7); + $netCompressionLevel = (int) $this->configGroup->getProperty("network.compression-level", 6); if($netCompressionLevel < 1 or $netCompressionLevel > 9){ - $this->logger->warning("Invalid network compression level $netCompressionLevel set, setting to default 7"); - $netCompressionLevel = 7; + $this->logger->warning("Invalid network compression level $netCompressionLevel set, setting to default 6"); + $netCompressionLevel = 6; } ZlibCompressor::setInstance(new ZlibCompressor($netCompressionLevel, $netCompressionThreshold, ZlibCompressor::DEFAULT_MAX_DECOMPRESSION_SIZE)); diff --git a/src/command/defaults/StatusCommand.php b/src/command/defaults/StatusCommand.php index 8eabc97a2..cbf53c0ee 100644 --- a/src/command/defaults/StatusCommand.php +++ b/src/command/defaults/StatusCommand.php @@ -101,7 +101,6 @@ class StatusCommand extends VanillaCommand{ $sender->sendMessage(TextFormat::GOLD . "Total memory: " . TextFormat::RED . number_format(round(($mUsage[1] / 1024) / 1024, 2), 2) . " MB."); $sender->sendMessage(TextFormat::GOLD . "Total virtual memory: " . TextFormat::RED . number_format(round(($mUsage[2] / 1024) / 1024, 2), 2) . " MB."); $sender->sendMessage(TextFormat::GOLD . "Heap memory: " . TextFormat::RED . number_format(round(($rUsage[0] / 1024) / 1024, 2), 2) . " MB."); - $sender->sendMessage(TextFormat::GOLD . "Maximum memory (system): " . TextFormat::RED . number_format(round(($mUsage[2] / 1024) / 1024, 2), 2) . " MB."); $globalLimit = $server->getMemoryManager()->getGlobalMemoryLimit(); if($globalLimit > 0){ diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 72b9e02b9..22e94962a 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -1020,8 +1020,14 @@ abstract class Entity{ $this->fall($this->fallDistance); $this->resetFallDistance(); } - }elseif($distanceThisTick < 0){ + }elseif($distanceThisTick < $this->fallDistance){ + //we've fallen some distance (distanceThisTick is negative) + //or we ascended back towards where fall distance was measured from initially (distanceThisTick is positive but less than existing fallDistance) $this->fallDistance -= $distanceThisTick; + }else{ + //we ascended past the apex where fall distance was originally being measured from + //reset it so it will be measured starting from the new, higher position + $this->fallDistance = 0; } } diff --git a/src/event/inventory/FurnaceBurnEvent.php b/src/event/inventory/FurnaceBurnEvent.php index 32cc7efb8..d613c5d9e 100644 --- a/src/event/inventory/FurnaceBurnEvent.php +++ b/src/event/inventory/FurnaceBurnEvent.php @@ -29,6 +29,9 @@ use pocketmine\event\Cancellable; use pocketmine\event\CancellableTrait; use pocketmine\item\Item; +/** + * Called when a furnace is about to consume a new fuel item. + */ class FurnaceBurnEvent extends BlockEvent implements Cancellable{ use CancellableTrait; @@ -56,18 +59,31 @@ class FurnaceBurnEvent extends BlockEvent implements Cancellable{ return $this->fuel; } + /** + * Returns the number of ticks that the furnace will be powered for. + */ public function getBurnTime() : int{ return $this->burnTime; } + /** + * Sets the number of ticks that the given fuel will power the furnace for. + */ public function setBurnTime(int $burnTime) : void{ $this->burnTime = $burnTime; } + /** + * Returns whether the fuel item will be consumed. + */ public function isBurning() : bool{ return $this->burning; } + /** + * Sets whether the fuel will be consumed. If false, the furnace will smelt as if it consumed fuel, but no fuel + * will be deducted. + */ public function setBurning(bool $burning) : void{ $this->burning = $burning; } diff --git a/src/plugin/PluginDescription.php b/src/plugin/PluginDescription.php index cc57fbbb1..6bac0381e 100644 --- a/src/plugin/PluginDescription.php +++ b/src/plugin/PluginDescription.php @@ -56,7 +56,7 @@ class PluginDescription{ private $compatibleOperatingSystems = []; /** * @var string[][] - * @phpstan-var array> + * @phpstan-var array> */ private $extensions = []; /** @var string[] */ @@ -130,7 +130,7 @@ class PluginDescription{ $k = $v; $v = "*"; } - $this->extensions[$k] = is_array($v) ? $v : [$v]; + $this->extensions[$k] = array_map('strval', is_array($v) ? $v : [$v]); } } diff --git a/src/wizard/SetupWizard.php b/src/wizard/SetupWizard.php index 1fb63b3de..a9d943982 100644 --- a/src/wizard/SetupWizard.php +++ b/src/wizard/SetupWizard.php @@ -92,6 +92,7 @@ class SetupWizard{ $config->save(); if(strtolower($this->getInput($this->lang->get("skip_installer"), "n", "y/N")) === "y"){ + $this->printIpDetails(); return true; } @@ -101,6 +102,7 @@ class SetupWizard{ $this->generateUserFiles(); $this->networkFunctions(); + $this->printIpDetails(); $this->endWizard(); @@ -200,7 +202,9 @@ LICENSE; } $config->save(); - + } + + private function printIpDetails() : void{ $this->message($this->lang->get("ip_get")); $externalIP = Internet::getIP(); diff --git a/tests/phpstan/bootstrap.php b/tests/phpstan/bootstrap.php index a962d4ac8..1906c5f47 100644 --- a/tests/phpstan/bootstrap.php +++ b/tests/phpstan/bootstrap.php @@ -23,6 +23,10 @@ declare(strict_types=1); define('pocketmine\_PHPSTAN_ANALYSIS', true); +if(!defined('LEVELDB_ZLIB_RAW_COMPRESSION')){ + //leveldb might not be loaded + define('LEVELDB_ZLIB_RAW_COMPRESSION', 4); +} if(!extension_loaded('libdeflate')){ function libdeflate_deflate_compress(string $data, int $level = 6) : string{} } diff --git a/tests/phpstan/configs/custom-leveldb.neon b/tests/phpstan/configs/custom-leveldb.neon deleted file mode 100644 index d5ef2dd17..000000000 --- a/tests/phpstan/configs/custom-leveldb.neon +++ /dev/null @@ -1,12 +0,0 @@ -parameters: - ignoreErrors: - #TODO: use custom stubs - - - message: "#^Used constant LEVELDB_ZLIB_RAW_COMPRESSION not found\\.$#" - count: 1 - path: ../../../src/world/format/io/leveldb/LevelDB.php - - - - message: "#^Constant LEVELDB_ZLIB_RAW_COMPRESSION not found\\.$#" - count: 1 - path: ../../../src/world/format/io/leveldb/LevelDB.php