From 1e9d83f0143ea16249d5047f4a1020be84e5c4b1 Mon Sep 17 00:00:00 2001 From: alvin0319 Date: Mon, 7 Nov 2022 22:09:05 +0900 Subject: [PATCH 01/17] BaseInventory: validate given array in setContents() (#5391) --- src/inventory/BaseInventory.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/inventory/BaseInventory.php b/src/inventory/BaseInventory.php index 3edc52043..06b3b9800 100644 --- a/src/inventory/BaseInventory.php +++ b/src/inventory/BaseInventory.php @@ -27,6 +27,7 @@ use pocketmine\item\Item; use pocketmine\item\VanillaItems; use pocketmine\player\Player; use pocketmine\utils\ObjectSet; +use pocketmine\utils\Utils; use function array_slice; use function count; use function max; @@ -85,6 +86,7 @@ abstract class BaseInventory implements Inventory{ * @phpstan-param array $items */ public function setContents(array $items) : void{ + Utils::validateArrayValueType($items, function(Item $item) : void{}); if(count($items) > $this->getSize()){ $items = array_slice($items, 0, $this->getSize(), true); } From 1a8c8af523374438df0ba534f50984557b4f72bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Nov 2022 13:40:53 +0000 Subject: [PATCH 02/17] Bump shivammathur/setup-php from 2.21.2 to 2.22.0 (#5375) Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.21.2 to 2.22.0. - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/2.21.2...2.22.0) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/discord-release-notify.yml | 2 +- .github/workflows/draft-release.yml | 2 +- .github/workflows/main.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/discord-release-notify.yml b/.github/workflows/discord-release-notify.yml index a7a251c77..a1ef20982 100644 --- a/.github/workflows/discord-release-notify.yml +++ b/.github/workflows/discord-release-notify.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP and tools - uses: shivammathur/setup-php@2.21.2 + uses: shivammathur/setup-php@2.22.0 with: php-version: 8.0 diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index 9c26c3ff1..022766d4f 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -18,7 +18,7 @@ jobs: submodules: true - name: Setup PHP - uses: shivammathur/setup-php@2.21.2 + uses: shivammathur/setup-php@2.22.0 with: php-version: 8.0 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 44a672b73..300f57eb3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -195,7 +195,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP and tools - uses: shivammathur/setup-php@2.21.2 + uses: shivammathur/setup-php@2.22.0 with: php-version: 8.0 tools: php-cs-fixer:3.11 From 3a2a23b236a3723dbd82e0b423ac0b3f61704386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Le=C3=B3n?= <58715544+JavierLeon9966@users.noreply.github.com> Date: Mon, 7 Nov 2022 10:54:14 -0300 Subject: [PATCH 03/17] Fixed totem activating when having 1HP instead of 0HP (#5380) --- src/entity/Human.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entity/Human.php b/src/entity/Human.php index 095d3ea86..ade87f981 100644 --- a/src/entity/Human.php +++ b/src/entity/Human.php @@ -356,7 +356,7 @@ class Human extends Living implements ProjectileSource, InventoryHolder{ && ($this->inventory->getItemInHand() instanceof Totem || $this->offHandInventory->getItem(0) instanceof Totem)){ $compensation = $this->getHealth() - $source->getFinalDamage() - 1; - if($compensation < 0){ + if($compensation <= -1){ $source->setModifier($compensation, EntityDamageEvent::MODIFIER_TOTEM); } } From 2d0602d19fde3d8517583c1ff09ab8feac91080b Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 7 Nov 2022 14:23:17 +0000 Subject: [PATCH 04/17] World: fixed spawning in the void when the spawn terrain is higher than y=70 on default worlds fixes #5390 --- src/world/World.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/world/World.php b/src/world/World.php index 126a947ee..f820a787f 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -2784,8 +2784,8 @@ class World implements ChunkManager{ if($this->getBlockAt($x, $y, $z)->isFullCube()){ if($wasAir){ $y++; - break; } + break; }else{ $wasAir = true; } From d5bf88acc021b3c0a1a8fbff1dd44a0e9465903f Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 7 Nov 2022 14:43:11 +0000 Subject: [PATCH 05/17] Added missing changelog items for 4.10.0 release these really ought to have been released in 4.9.2, but it's too late for that now. --- changelogs/4.10.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/changelogs/4.10.md b/changelogs/4.10.md index 8b27a6f09..d7407f22f 100644 --- a/changelogs/4.10.md +++ b/changelogs/4.10.md @@ -11,4 +11,13 @@ Released 26th October 2022. ## General - Added support for Minecraft: Bedrock Edition 1.19.40. -- Removed support for older versions. \ No newline at end of file +- Removed support for older versions. + +## Fixes +- Fixed incorrect command descriptions showing in `/help` when multiple commands use the same name. Previously, the most recently registered command would show, even though it wouldn't actually be invoked. +- Fixed splash potions affecting players in spectator mode. +- Fixed `World->addParticle()` sending particles to players who couldn't possibly see them when a list of targets was used. +- Fixed `World->addSound()` sending sounds to players who couldn't possibly hear them when a list of targets was used. + +## Documentation +- Improved type information available for various API methods in `World`. From a39938e6b674af02262d16e83152b9834c677fe0 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 7 Nov 2022 14:50:43 +0000 Subject: [PATCH 06/17] Release 4.10.1 --- changelogs/4.10.md | 15 +++++++++++++++ src/VersionInfo.php | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/changelogs/4.10.md b/changelogs/4.10.md index d7407f22f..66989b33d 100644 --- a/changelogs/4.10.md +++ b/changelogs/4.10.md @@ -21,3 +21,18 @@ Released 26th October 2022. ## Documentation - Improved type information available for various API methods in `World`. + +# 4.10.1 +Released 7th November 2022. + +## Fixes +- Fixed spawning in the void if spawn terrain in a world is solid at the default spawn position. +- Fixed totems of undying activating when the player has 1 HP remaining. +- Fixed durable items such as tools becoming unbreakable when in stacks larger than 1. Now, the durability correctly resets when the tool breaks. +- TPS below 12 now correctly shows as red in `/status`. Previously, it showed as orange due to a condition ordering bug. +- Improved handling of missing arguments in user-defined `pocketmine.yml` command aliases. Previously, missing arguments would be filled with an empty string, which caused a variety of unexpected behaviour. + +## Internals +- Added validation for the array given to `BaseInventory->setContents()` to ensure that it contains only `Item` instances. +- Silenced `PlayerAuthInputPacket` spam when the session is in the "spawn response" state. +- Updated to PHPStan 1.9. diff --git a/src/VersionInfo.php b/src/VersionInfo.php index ab7ac0b55..797c74f9a 100644 --- a/src/VersionInfo.php +++ b/src/VersionInfo.php @@ -32,7 +32,7 @@ use function str_repeat; final class VersionInfo{ public const NAME = "PocketMine-MP"; public const BASE_VERSION = "4.10.1"; - public const IS_DEVELOPMENT_BUILD = true; + public const IS_DEVELOPMENT_BUILD = false; public const BUILD_CHANNEL = "stable"; private function __construct(){ From b3ccf41307ce9024ce9364983a857d0f2b617426 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 7 Nov 2022 14:50:44 +0000 Subject: [PATCH 07/17] 4.10.2 is next --- src/VersionInfo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/VersionInfo.php b/src/VersionInfo.php index 797c74f9a..2f4ef94fd 100644 --- a/src/VersionInfo.php +++ b/src/VersionInfo.php @@ -31,8 +31,8 @@ use function str_repeat; final class VersionInfo{ public const NAME = "PocketMine-MP"; - public const BASE_VERSION = "4.10.1"; - public const IS_DEVELOPMENT_BUILD = false; + public const BASE_VERSION = "4.10.2"; + public const IS_DEVELOPMENT_BUILD = true; public const BUILD_CHANNEL = "stable"; private function __construct(){ From bf7014e0eca06bc5d00205967ef3d16792af4036 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 7 Nov 2022 15:18:05 +0000 Subject: [PATCH 08/17] Release 4.11.0-BETA1 --- changelogs/4.11-beta.md | 67 +++++++++++++++++++++++++++++++++++++++++ src/VersionInfo.php | 4 +-- 2 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 changelogs/4.11-beta.md diff --git a/changelogs/4.11-beta.md b/changelogs/4.11-beta.md new file mode 100644 index 000000000..9da45f30c --- /dev/null +++ b/changelogs/4.11-beta.md @@ -0,0 +1,67 @@ +**For Minecraft: Bedrock Edition 1.19.40** + +This is a minor feature release for PocketMine-MP, introducing some new features and improvements. + +### Note about API versions +Plugins which don't touch the protocol and compatible with any previous 4.x.y version will also run on these releases and do not need API bumps. +Plugin developers should **only** update their required API to this version if you need the changes in this build. + +**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do. + +# 4.11.0-BETA1 +Released 7th November 2022. + +## General +- Packet receive timings have now been split into two subcategories - Decode and Handle. +- Console command entry can now be disabled via the `console.enable-input` setting in `pocketmine.yml`. + - Best suited for headless servers (e.g. in a Docker container) where the console will never be used anyway. + - Disabling the console reader slightly reduces memory usage, because console reading currently requires an additional subprocess. +- Console command output now appears on the terminal only, and is not written to the log file. +- The output from console commands now appears with a `Command output |` prefix, instead of as a log message. +- Introduced validation for the `--data` and `--plugins` command line options. +- Encrypted resource packs are now supported, by means of adding a `.key` file alongside the pack in the `resource_packs` folder. + - e.g. `MyEncryptedPack.zip` -> `MyEncryptedPack.zip.key` + +## Gameplay +- Fixed supporting blocks of dead bush to be in line with vanilla. +- Sugarcane can now be grown using bonemeal on any part of the sugarcane. Previously, it only worked when used on the bottom block. +- Fixed modifier values for Instant Damage and Regeneration effects. + +## API +### General +- Plugins are now always disabled before their dependencies, to ensure that they are able to shutdown properly (e.g. a core plugin depending on a database plugin may want to save data to a DB during `onDisable()`). +- [`webmozart/path-util`](https://packagist.org/packages/webmozart/path-util) has been deprecated, and will be dropped in favour of [`symfony/filesystem`](https://packagist.org/packages/symfony/filesystem) in PM5. + - To prepare for this change, simply replace any usage of `Webmozart\PathUtil\Path` with `Symfony\Component\Filesystem\Path`, which is available as a dependency in this release. + +### `pocketmine` +- The following API methods are now deprecated: + - `Server->getPlayerByPrefix()` + +### `pocketmine\entity` +- `EntitySpawnEvent` and `ItemSpawnEvent` are now fired on the first tick after the entity is added to the world. Previously, these events were called directly from the entity constructor, making it impossible to get properties like velocity which are often set after the entity is created. +- The following API methods are now deprecated: + - `Living->hasLineOfSight()` + +### `pocketmine\item` +- The following new API methods have been added: + - `public Armor->clearCustomColor() : $this` + +### `pocketmine\inventory\transaction` +- Introduced a `TransactionBuilder` class. This makes it less of a hassle to build an `InventoryTransaction` server-side, since the regular `Inventory` API methods can be used, rather than having to manually create `SlotChangeAction`s. + +### `pocketmine\player` +- The following new API methods have been added: + - `public Player->sendToastNotification(string $title, string $body) : void` - makes a grey box appear at the top of the player's screen containing the specified message + +### `pocketmine\utils` +- The following new API methods have been added: + - `public static TextFormat::addBase(string $baseFormat, string $string) : string` - used for coloured log messages, changes the base formatting of a string by inserting the given formatting codes after every RESET code + +## Internals +- Improved performance of `ContainerTrait` dropping items on block destroy. (24e72ec109c1442b09558df89b6833cf2f2e0ec7) +- Avoid repeated calls to `Position->getWorld()` (use local variables). (2940547026db40ce76deb46e992870de3ead79ad) +- Revamped the way `InventoryManager` handles fake inventory slot mappings for stuff like crafting tables. (e90abecf38d9c57635fa0497514bba7e546a2469) +- Console polling is now done on the main thread (no longer a performance concern). +- Console reader subprocess should now automatically die if the server main process is killed, instead of persisting as a zombie. +- `ConsoleCommandSender` is no longer responsible for relaying broadcast messages to `MainLogger`. A new `BroadcastLoggerForwarder` has been added, which is subscribed to the appropriate server broadcast channels in order to relay messages. This ensures that chat messages and command audit messages are logged. +- `DelegateInventory` now uses `WeakReference` to track its inventory listener. This allows the delegate to be reused. diff --git a/src/VersionInfo.php b/src/VersionInfo.php index fc590de79..4f8e3cb16 100644 --- a/src/VersionInfo.php +++ b/src/VersionInfo.php @@ -31,8 +31,8 @@ use function str_repeat; final class VersionInfo{ public const NAME = "PocketMine-MP"; - public const BASE_VERSION = "4.10.2"; - public const IS_DEVELOPMENT_BUILD = true; + public const BASE_VERSION = "4.11.0-BETA1"; + public const IS_DEVELOPMENT_BUILD = false; public const BUILD_CHANNEL = "beta"; private function __construct(){ From 069062f122f5aa1d1a97aaebd8ea896c0ceca490 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 7 Nov 2022 15:18:09 +0000 Subject: [PATCH 09/17] 4.11.0-BETA2 is next --- src/VersionInfo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/VersionInfo.php b/src/VersionInfo.php index 4f8e3cb16..cfc5ddb12 100644 --- a/src/VersionInfo.php +++ b/src/VersionInfo.php @@ -31,8 +31,8 @@ use function str_repeat; final class VersionInfo{ public const NAME = "PocketMine-MP"; - public const BASE_VERSION = "4.11.0-BETA1"; - public const IS_DEVELOPMENT_BUILD = false; + public const BASE_VERSION = "4.11.0-BETA2"; + public const IS_DEVELOPMENT_BUILD = true; public const BUILD_CHANNEL = "beta"; private function __construct(){ From a7ac6070dcd00d87c1a0f773d508a7b1af0c27d0 Mon Sep 17 00:00:00 2001 From: IvanCraft623 <57236932+IvanCraft623@users.noreply.github.com> Date: Mon, 7 Nov 2022 15:05:53 -0500 Subject: [PATCH 10/17] Correct damage calculation for non-arrow projectiles (#5394) --- src/entity/projectile/Arrow.php | 3 ++- src/entity/projectile/Projectile.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/entity/projectile/Arrow.php b/src/entity/projectile/Arrow.php index 2ec412545..df3237d62 100644 --- a/src/entity/projectile/Arrow.php +++ b/src/entity/projectile/Arrow.php @@ -38,6 +38,7 @@ use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataFlags; use pocketmine\player\Player; use pocketmine\world\sound\ArrowHitSound; +use function ceil; use function mt_rand; use function sqrt; @@ -103,7 +104,7 @@ class Arrow extends Projectile{ } public function getResultDamage() : int{ - $base = parent::getResultDamage(); + $base = (int) ceil($this->motion->length() * parent::getResultDamage()); if($this->isCritical()){ return ($base + mt_rand(0, (int) ($base / 2) + 1)); }else{ diff --git a/src/entity/projectile/Projectile.php b/src/entity/projectile/Projectile.php index 0d6fe2a35..be2082948 100644 --- a/src/entity/projectile/Projectile.php +++ b/src/entity/projectile/Projectile.php @@ -128,7 +128,7 @@ abstract class Projectile extends Entity{ * Returns the amount of damage this projectile will deal to the entity it hits. */ public function getResultDamage() : int{ - return (int) ceil($this->motion->length() * $this->damage); + return (int) ceil($this->damage); } public function saveNBT() : CompoundTag{ From 50efcf74244b1d3d069796039f8bde28e3c7f830 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Nov 2022 13:40:09 +0000 Subject: [PATCH 11/17] Bump ramsey/uuid from 4.5.1 to 4.6.0 (#5400) Bumps [ramsey/uuid](https://github.com/ramsey/uuid) from 4.5.1 to 4.6.0. - [Release notes](https://github.com/ramsey/uuid/releases) - [Changelog](https://github.com/ramsey/uuid/blob/4.x/CHANGELOG.md) - [Commits](https://github.com/ramsey/uuid/compare/4.5.1...4.6.0) --- updated-dependencies: - dependency-name: ramsey/uuid dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.lock | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/composer.lock b/composer.lock index b3cd775be..358751514 100644 --- a/composer.lock +++ b/composer.lock @@ -930,21 +930,20 @@ }, { "name": "ramsey/uuid", - "version": "4.5.1", + "version": "4.6.0", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "a161a26d917604dc6d3aa25100fddf2556e9f35d" + "reference": "ad63bc700e7d021039e30ce464eba384c4a1d40f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/a161a26d917604dc6d3aa25100fddf2556e9f35d", - "reference": "a161a26d917604dc6d3aa25100fddf2556e9f35d", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/ad63bc700e7d021039e30ce464eba384c4a1d40f", + "reference": "ad63bc700e7d021039e30ce464eba384c4a1d40f", "shasum": "" }, "require": { "brick/math": "^0.8.8 || ^0.9 || ^0.10", - "ext-ctype": "*", "ext-json": "*", "php": "^8.0", "ramsey/collection": "^1.0" @@ -976,7 +975,6 @@ }, "suggest": { "ext-bcmath": "Enables faster math with arbitrary-precision integers using BCMath.", - "ext-ctype": "Enables faster processing of character classification using ctype functions.", "ext-gmp": "Enables faster math with arbitrary-precision integers using GMP.", "ext-uuid": "Enables the use of PeclUuidTimeGenerator and PeclUuidRandomGenerator.", "paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter", @@ -1008,7 +1006,7 @@ ], "support": { "issues": "https://github.com/ramsey/uuid/issues", - "source": "https://github.com/ramsey/uuid/tree/4.5.1" + "source": "https://github.com/ramsey/uuid/tree/4.6.0" }, "funding": [ { @@ -1020,7 +1018,7 @@ "type": "tidelift" } ], - "time": "2022-09-16T03:22:46+00:00" + "time": "2022-11-05T23:03:38+00:00" }, { "name": "symfony/polyfill-php81", From 93e661aa4e600e8193e4a57f987c6abf04386d87 Mon Sep 17 00:00:00 2001 From: Artem Turov <58974140+Lunarelly@users.noreply.github.com> Date: Wed, 9 Nov 2022 16:40:35 +0300 Subject: [PATCH 12/17] Removed useless @inheritDoc (#5399) --- src/player/Player.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/player/Player.php b/src/player/Player.php index f93ac2dfc..904bf5793 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -2405,9 +2405,6 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ $this->ySize = 0; } - /** - * {@inheritdoc} - */ public function teleport(Vector3 $pos, ?float $yaw = null, ?float $pitch = null) : bool{ if(parent::teleport($pos, $yaw, $pitch)){ From d03bbb0426e6c531712a451928b5dd5cec43b8db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Le=C3=B3n?= <58715544+JavierLeon9966@users.noreply.github.com> Date: Thu, 10 Nov 2022 09:57:14 -0300 Subject: [PATCH 13/17] Implemented darkness effect (#5402) --- src/data/bedrock/EffectIdMap.php | 1 + src/data/bedrock/EffectIds.php | 1 + src/entity/effect/StringToEffectParser.php | 1 + src/entity/effect/VanillaEffects.php | 2 ++ 4 files changed, 5 insertions(+) diff --git a/src/data/bedrock/EffectIdMap.php b/src/data/bedrock/EffectIdMap.php index 23985fa12..6dce86d9b 100644 --- a/src/data/bedrock/EffectIdMap.php +++ b/src/data/bedrock/EffectIdMap.php @@ -74,6 +74,7 @@ final class EffectIdMap{ //TODO: SLOW_FALLING //TODO: BAD_OMEN //TODO: VILLAGE_HERO + $this->register(EffectIds::DARKNESS, VanillaEffects::DARKNESS()); } //TODO: not a big fan of the code duplication here :( diff --git a/src/data/bedrock/EffectIds.php b/src/data/bedrock/EffectIds.php index 3acf56569..a2ada01d9 100644 --- a/src/data/bedrock/EffectIds.php +++ b/src/data/bedrock/EffectIds.php @@ -58,4 +58,5 @@ final class EffectIds{ public const SLOW_FALLING = 27; public const BAD_OMEN = 28; public const VILLAGE_HERO = 29; + public const DARKNESS = 30; } diff --git a/src/entity/effect/StringToEffectParser.php b/src/entity/effect/StringToEffectParser.php index d336af33b..23bd29bd0 100644 --- a/src/entity/effect/StringToEffectParser.php +++ b/src/entity/effect/StringToEffectParser.php @@ -40,6 +40,7 @@ final class StringToEffectParser extends StringToTParser{ $result->register("absorption", fn() => VanillaEffects::ABSORPTION()); $result->register("blindness", fn() => VanillaEffects::BLINDNESS()); $result->register("conduit_power", fn() => VanillaEffects::CONDUIT_POWER()); + $result->register("darkness", fn() => VanillaEffects::DARKNESS()); $result->register("fatal_poison", fn() => VanillaEffects::FATAL_POISON()); $result->register("fire_resistance", fn() => VanillaEffects::FIRE_RESISTANCE()); $result->register("haste", fn() => VanillaEffects::HASTE()); diff --git a/src/entity/effect/VanillaEffects.php b/src/entity/effect/VanillaEffects.php index 04f7985da..50544054a 100644 --- a/src/entity/effect/VanillaEffects.php +++ b/src/entity/effect/VanillaEffects.php @@ -36,6 +36,7 @@ use pocketmine\utils\RegistryTrait; * @method static AbsorptionEffect ABSORPTION() * @method static Effect BLINDNESS() * @method static Effect CONDUIT_POWER() + * @method static Effect DARKNESS() * @method static PoisonEffect FATAL_POISON() * @method static Effect FIRE_RESISTANCE() * @method static Effect HASTE() @@ -68,6 +69,7 @@ final class VanillaEffects{ //TODO: bad_omen self::register("blindness", new Effect(KnownTranslationFactory::potion_blindness(), new Color(0x1f, 0x1f, 0x23), true)); self::register("conduit_power", new Effect(KnownTranslationFactory::potion_conduitPower(), new Color(0x1d, 0xc2, 0xd1))); + self::register("darkness", new Effect(KnownTranslationFactory::effect_darkness(), new Color(0x29, 0x27, 0x21), true, 600, false)); self::register("fatal_poison", new PoisonEffect(KnownTranslationFactory::potion_poison(), new Color(0x4e, 0x93, 0x31), true, 600, true, true)); self::register("fire_resistance", new Effect(KnownTranslationFactory::potion_fireResistance(), new Color(0xe4, 0x9a, 0x3a))); self::register("haste", new Effect(KnownTranslationFactory::potion_digSpeed(), new Color(0xd9, 0xc0, 0x43))); From ef100b248b72dbe0238abd202c4d1ac11ff375ee Mon Sep 17 00:00:00 2001 From: Artem Turov <58974140+Lunarelly@users.noreply.github.com> Date: Sat, 12 Nov 2022 16:52:49 +0300 Subject: [PATCH 14/17] Improved doc comment for Internet::getIP() (#5406) --- src/utils/Internet.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/Internet.php b/src/utils/Internet.php index 7f379d7dc..3c22e460f 100644 --- a/src/utils/Internet.php +++ b/src/utils/Internet.php @@ -70,7 +70,7 @@ class Internet{ public static $online = true; /** - * Gets the External IP using an external service, it is cached + * Lazily gets the External IP using an external service and caches the result * * @param bool $force default false, force IP check even when cached * From d5e3636908648de4ba4599c8a24db26c46ac7772 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 12 Nov 2022 14:40:19 +0000 Subject: [PATCH 15/17] Timezone: Apparently timezone_id returned by timezone_abbreviations_list() may be null... --- src/player/Player.php | 8 -------- src/utils/Timezone.php | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/player/Player.php b/src/player/Player.php index 904bf5793..500e8b800 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -300,14 +300,6 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ $this->chunkLoader = new PlayerChunkLoader($spawnLocation); - $world = $spawnLocation->getWorld(); - //load the spawn chunk so we can see the terrain - $xSpawnChunk = $spawnLocation->getFloorX() >> Chunk::COORD_BIT_SIZE; - $zSpawnChunk = $spawnLocation->getFloorZ() >> Chunk::COORD_BIT_SIZE; - $world->registerChunkLoader($this->chunkLoader, $xSpawnChunk, $zSpawnChunk, true); - $world->registerChunkListener($this, $xSpawnChunk, $zSpawnChunk); - $this->usedChunks[World::chunkHash($xSpawnChunk, $zSpawnChunk)] = UsedChunkStatus::NEEDED(); - parent::__construct($spawnLocation, $this->playerInfo->getSkin(), $namedtag); } diff --git a/src/utils/Timezone.php b/src/utils/Timezone.php index 02110c0eb..3cf3a19df 100644 --- a/src/utils/Timezone.php +++ b/src/utils/Timezone.php @@ -208,7 +208,7 @@ abstract class Timezone{ //That's been a bug in PHP since 2008! foreach(timezone_abbreviations_list() as $zones){ foreach($zones as $timezone){ - if($timezone['offset'] == $offset){ + if($timezone['timezone_id'] !== null && $timezone['offset'] == $offset){ return $timezone['timezone_id']; } } From 732dac6fc147087c2acf8f60d1a2db5bfc7243a6 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 12 Nov 2022 14:43:22 +0000 Subject: [PATCH 16/17] Player: revert accidental change from ef100b248b72dbe0238abd202c4d1ac11ff375ee --- src/player/Player.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/player/Player.php b/src/player/Player.php index 500e8b800..904bf5793 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -300,6 +300,14 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ $this->chunkLoader = new PlayerChunkLoader($spawnLocation); + $world = $spawnLocation->getWorld(); + //load the spawn chunk so we can see the terrain + $xSpawnChunk = $spawnLocation->getFloorX() >> Chunk::COORD_BIT_SIZE; + $zSpawnChunk = $spawnLocation->getFloorZ() >> Chunk::COORD_BIT_SIZE; + $world->registerChunkLoader($this->chunkLoader, $xSpawnChunk, $zSpawnChunk, true); + $world->registerChunkListener($this, $xSpawnChunk, $zSpawnChunk); + $this->usedChunks[World::chunkHash($xSpawnChunk, $zSpawnChunk)] = UsedChunkStatus::NEEDED(); + parent::__construct($spawnLocation, $this->playerInfo->getSkin(), $namedtag); } From 83ddcce987bdc1b52256150cd42896ec82bca39d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 12 Nov 2022 16:57:35 +0000 Subject: [PATCH 17/17] World: Considerably simplify ticked chunk selection WARNING: This WILL have a performance impact on larger servers, but that's the price to pay for having crops actually grow. The old overengineered method for doing this was causing glacially slow crop growth, vanilla parity issues and really just didn't make much sense. This method is probably incorrect too, but it will at least produce visible results. --- resources/pocketmine.yml | 2 -- src/world/World.php | 30 +++++++++++++++--------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/resources/pocketmine.yml b/resources/pocketmine.yml index 4ad8ea9c0..ac60afe53 100644 --- a/resources/pocketmine.yml +++ b/resources/pocketmine.yml @@ -119,8 +119,6 @@ chunk-sending: spawn-radius: 4 chunk-ticking: - #Max amount of chunks processed each tick - per-tick: 40 #Radius of chunks around a player to tick tick-radius: 3 #Number of blocks inside ticking areas' subchunks that get ticked every tick. Higher values will accelerate events diff --git a/src/world/World.php b/src/world/World.php index f820a787f..e9441e9bb 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -66,6 +66,7 @@ use pocketmine\network\mcpe\protocol\BlockActorDataPacket; use pocketmine\network\mcpe\protocol\ClientboundPacket; use pocketmine\network\mcpe\protocol\types\BlockPosition; use pocketmine\network\mcpe\protocol\UpdateBlockPacket; +use pocketmine\player\ChunkSelector; use pocketmine\player\Player; use pocketmine\promise\Promise; use pocketmine\promise\PromiseResolver; @@ -317,7 +318,6 @@ class World implements ChunkManager{ private int $sleepTicks = 0; private int $chunkTickRadius; - private int $chunksPerTick; private int $tickedBlocksPerSubchunkPerTick = self::DEFAULT_TICKED_BLOCKS_PER_SUBCHUNK_PER_TICK; /** * @var true[] @@ -493,7 +493,11 @@ class World implements ChunkManager{ $cfg = $this->server->getConfigGroup(); $this->chunkTickRadius = min($this->server->getViewDistance(), max(1, $cfg->getPropertyInt("chunk-ticking.tick-radius", 4))); - $this->chunksPerTick = $cfg->getPropertyInt("chunk-ticking.per-tick", 40); + if($cfg->getPropertyInt("chunk-ticking.per-tick", 40) <= 0){ + //TODO: this needs l10n + $this->logger->warning("\"chunk-ticking.per-tick\" setting is deprecated, but you've used it to disable chunk ticking. Set \"chunk-ticking.tick-radius\" to 0 in \"pocketmine.yml\" instead."); + $this->chunkTickRadius = 0; + } $this->tickedBlocksPerSubchunkPerTick = $cfg->getPropertyInt("chunk-ticking.blocks-per-subchunk-per-tick", self::DEFAULT_TICKED_BLOCKS_PER_SUBCHUNK_PER_TICK); $this->maxConcurrentChunkPopulationTasks = $cfg->getPropertyInt("chunk-generation.population-queue-size", 2); @@ -1101,7 +1105,7 @@ class World implements ChunkManager{ } private function tickChunks() : void{ - if($this->chunksPerTick <= 0 || count($this->tickingLoaders) === 0){ + if($this->chunkTickRadius <= 0 || count($this->tickingLoaders) === 0){ return; } @@ -1110,19 +1114,15 @@ class World implements ChunkManager{ /** @var bool[] $chunkTickList chunkhash => dummy */ $chunkTickList = []; - $chunksPerLoader = min(200, max(1, (int) ((($this->chunksPerTick - count($this->tickingLoaders)) / count($this->tickingLoaders)) + 0.5))); - $randRange = 3 + $chunksPerLoader / 30; - $randRange = (int) ($randRange > $this->chunkTickRadius ? $this->chunkTickRadius : $randRange); - + $selector = new ChunkSelector(); foreach($this->tickingLoaders as $loader){ - $chunkX = (int) floor($loader->getX()) >> Chunk::COORD_BIT_SIZE; - $chunkZ = (int) floor($loader->getZ()) >> Chunk::COORD_BIT_SIZE; - - for($chunk = 0; $chunk < $chunksPerLoader; ++$chunk){ - $dx = mt_rand(-$randRange, $randRange); - $dz = mt_rand(-$randRange, $randRange); - $hash = World::chunkHash($dx + $chunkX, $dz + $chunkZ); - if(!isset($chunkTickList[$hash]) && isset($this->chunks[$hash]) && $this->isChunkTickable($dx + $chunkX, $dz + $chunkZ)){ + foreach($selector->selectChunks( + $this->chunkTickRadius, + (int) floor($loader->getX()) >> Chunk::COORD_BIT_SIZE, + (int) floor($loader->getZ()) >> Chunk::COORD_BIT_SIZE + ) as $hash){ + World::getXZ($hash, $chunkX, $chunkZ); + if(!isset($chunkTickList[$hash]) && isset($this->chunks[$hash]) && $this->isChunkTickable($chunkX, $chunkZ)){ $chunkTickList[$hash] = true; } }