From 0ea3861d434b017055dfaac5c11e4c90f3779fac Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 20 May 2022 11:12:55 +0100 Subject: [PATCH] Fixed paintings not working in newly generated worlds Paintings would not work unless at least one entity was loaded from disk (or saved). --- src/entity/EntityFactory.php | 2 -- src/entity/object/PaintingMotive.php | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/entity/EntityFactory.php b/src/entity/EntityFactory.php index 4bd743042..84838670a 100644 --- a/src/entity/EntityFactory.php +++ b/src/entity/EntityFactory.php @@ -173,8 +173,6 @@ final class EntityFactory{ $this->register(Human::class, function(World $world, CompoundTag $nbt) : Human{ return new Human(Helper::parseLocation($nbt, $world), Human::parseSkinNBT($nbt), $nbt); }, ['Human']); - - PaintingMotive::init(); } /** diff --git a/src/entity/object/PaintingMotive.php b/src/entity/object/PaintingMotive.php index a21bba2fc..28b52efe3 100644 --- a/src/entity/object/PaintingMotive.php +++ b/src/entity/object/PaintingMotive.php @@ -24,6 +24,8 @@ declare(strict_types=1); namespace pocketmine\entity\object; class PaintingMotive{ + private static bool $initialized = false; + /** @var PaintingMotive[] */ protected static $motives = []; @@ -76,6 +78,9 @@ class PaintingMotive{ * @return PaintingMotive[] */ public static function getAll() : array{ + if(!self::$initialized){ + self::init(); + } return self::$motives; }