From 10067c104333db1c246eb5ac56482844054190a1 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 1 Dec 2020 23:31:38 +0000 Subject: [PATCH] Improve painting performance these really shouldn't hit the CPU at all considering they are simply static objects ... --- src/entity/Entity.php | 8 ++++++++ src/entity/object/Painting.php | 4 ++++ src/world/World.php | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/entity/Entity.php b/src/entity/Entity.php index a9fcba9f16..2af2883f73 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -998,6 +998,14 @@ abstract class Entity{ $this->scheduleUpdate(); } + /** + * Called when a random update is performed on the chunk the entity is in. This happens when the chunk is within the + * ticking chunk range of a player (or chunk loader). + */ + public function onRandomUpdate() : void{ + $this->scheduleUpdate(); + } + /** * Flags the entity as needing a movement update on the next tick. Setting this forces a movement update even if the * entity's motion is zero. Used to trigger movement updates when blocks change near entities. diff --git a/src/entity/object/Painting.php b/src/entity/object/Painting.php index 3ccb6b1002..91d9a014d0 100644 --- a/src/entity/object/Painting.php +++ b/src/entity/object/Painting.php @@ -132,6 +132,10 @@ class Painting extends Entity{ } } + public function onRandomUpdate() : void{ + //NOOP + } + public function hasMovementUpdate() : bool{ return false; } diff --git a/src/world/World.php b/src/world/World.php index ef7bdf17de..398ccc7f76 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -968,7 +968,7 @@ class World implements ChunkManager{ $chunk = $this->chunks[$index]; foreach($chunk->getEntities() as $entity){ - $entity->scheduleUpdate(); + $entity->onRandomUpdate(); } foreach($chunk->getSubChunks() as $Y => $subChunk){