diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 5c8056c9bf..4b7b1f2bfc 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -1950,32 +1950,6 @@ class Server{ private function checkTickUpdates($currentTick){ - //TODO: move this to each Level - - //Update entities that need update - if(count(Entity::$needUpdate) > 0){ - Timings::$tickEntityTimer->startTiming(); - foreach(Entity::$needUpdate as $id => $entity){ - if($entity->onUpdate() === false){ - unset(Entity::$needUpdate[$id]); - } - } - Timings::$tickEntityTimer->stopTiming(); - } - - //Update tiles that need update - if(count(Tile::$needUpdate) > 0){ - Timings::$tickTileEntityTimer->startTiming(); - foreach(Tile::$needUpdate as $id => $tile){ - if($tile->onUpdate() === false){ - unset(Tile::$needUpdate[$id]); - } - } - Timings::$tickTileEntityTimer->stopTiming(); - } - - //TODO: Add level blocks - //Do level ticks foreach($this->getLevels() as $level){ $level->doTick($currentTick); diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index b0ef7a1329..7f36a86984 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -584,6 +584,7 @@ abstract class Entity extends Position implements Metadatable{ } public final function scheduleUpdate(){ + //TODO! Entity::$needUpdate[$this->id] = $this; } diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 15e8253c5b..58c9761f17 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -56,6 +56,7 @@ use pocketmine\event\level\LevelUnloadEvent; use pocketmine\event\level\SpawnChangeEvent; use pocketmine\event\LevelTimings; use pocketmine\event\player\PlayerInteractEvent; +use pocketmine\event\Timings; use pocketmine\inventory\InventoryHolder; use pocketmine\item\Item; use pocketmine\level\format\Chunk; @@ -502,6 +503,32 @@ class Level implements ChunkManager, Metadatable{ } $this->timings->doTickPending->stopTiming(); + $this->timings->entityTick->startTiming(); + //Update entities that need update + if(count(Entity::$needUpdate) > 0){ + //Timings::$tickEntityTimer->startTiming(); + foreach($this->entities as $id => $entity){ + if($entity->onUpdate() === false){ + //unset(Entity::$needUpdate[$id]); + } + } + //Timings::$tickEntityTimer->stopTiming(); + } + $this->timings->entityTick->stopTiming(); + + $this->timings->tileEntityTick->startTiming(); + //Update tiles that need update + if(count(Tile::$needUpdate) > 0){ + //Timings::$tickTileEntityTimer->startTiming(); + foreach($this->tiles as $id => $tile){ + if($tile->onUpdate() === false){ + //unset(Tile::$needUpdate[$id]); + } + } + //Timings::$tickTileEntityTimer->stopTiming(); + } + $this->timings->tileEntityTick->stopTiming(); + $this->timings->doTickTiles->startTiming(); $this->tickChunks(); $this->timings->doTickTiles->stopTiming(); diff --git a/src/pocketmine/tile/Tile.php b/src/pocketmine/tile/Tile.php index 0302176841..1a7402ac95 100644 --- a/src/pocketmine/tile/Tile.php +++ b/src/pocketmine/tile/Tile.php @@ -100,6 +100,7 @@ abstract class Tile extends Position{ } public final function scheduleUpdate(){ + //TODO! Tile::$needUpdate[$this->id] = $this; }