Level: remove getTiles(), more removal of tiles from user interface

This commit is contained in:
Dylan K. Taylor 2019-02-15 16:27:00 +00:00
parent 65ce1a7581
commit f49d590794
3 changed files with 3 additions and 21 deletions

View File

@ -48,17 +48,15 @@ class GarbageCollectorCommand extends VanillaCommand{
$chunksCollected = 0; $chunksCollected = 0;
$entitiesCollected = 0; $entitiesCollected = 0;
$tilesCollected = 0;
$memory = memory_get_usage(); $memory = memory_get_usage();
foreach($sender->getServer()->getLevelManager()->getLevels() as $level){ foreach($sender->getServer()->getLevelManager()->getLevels() as $level){
$diff = [count($level->getChunks()), count($level->getEntities()), count($level->getTiles())]; $diff = [count($level->getChunks()), count($level->getEntities())];
$level->doChunkGarbageCollection(); $level->doChunkGarbageCollection();
$level->unloadChunks(true); $level->unloadChunks(true);
$chunksCollected += $diff[0] - count($level->getChunks()); $chunksCollected += $diff[0] - count($level->getChunks());
$entitiesCollected += $diff[1] - count($level->getEntities()); $entitiesCollected += $diff[1] - count($level->getEntities());
$tilesCollected += $diff[2] - count($level->getTiles());
$level->clearCache(true); $level->clearCache(true);
} }
@ -67,7 +65,6 @@ class GarbageCollectorCommand extends VanillaCommand{
$sender->sendMessage(TextFormat::GREEN . "---- " . TextFormat::WHITE . "Garbage collection result" . TextFormat::GREEN . " ----"); $sender->sendMessage(TextFormat::GREEN . "---- " . TextFormat::WHITE . "Garbage collection result" . TextFormat::GREEN . " ----");
$sender->sendMessage(TextFormat::GOLD . "Chunks: " . TextFormat::RED . number_format($chunksCollected)); $sender->sendMessage(TextFormat::GOLD . "Chunks: " . TextFormat::RED . number_format($chunksCollected));
$sender->sendMessage(TextFormat::GOLD . "Entities: " . TextFormat::RED . number_format($entitiesCollected)); $sender->sendMessage(TextFormat::GOLD . "Entities: " . TextFormat::RED . number_format($entitiesCollected));
$sender->sendMessage(TextFormat::GOLD . "Tiles: " . TextFormat::RED . number_format($tilesCollected));
$sender->sendMessage(TextFormat::GOLD . "Cycles: " . TextFormat::RED . number_format($cyclesCollected)); $sender->sendMessage(TextFormat::GOLD . "Cycles: " . TextFormat::RED . number_format($cyclesCollected));
$sender->sendMessage(TextFormat::GOLD . "Memory freed: " . TextFormat::RED . number_format(round((($memory - memory_get_usage()) / 1024) / 1024, 2), 2) . " MB"); $sender->sendMessage(TextFormat::GOLD . "Memory freed: " . TextFormat::RED . number_format(round((($memory - memory_get_usage()) / 1024) / 1024, 2), 2) . " MB");

View File

@ -112,8 +112,7 @@ class StatusCommand extends VanillaCommand{
$tickRate = $level->getTickRate() > 1 ? " (tick rate " . $level->getTickRate() . ")" : ""; $tickRate = $level->getTickRate() > 1 ? " (tick rate " . $level->getTickRate() . ")" : "";
$sender->sendMessage(TextFormat::GOLD . "World \"{$level->getFolderName()}\"$levelName: " . $sender->sendMessage(TextFormat::GOLD . "World \"{$level->getFolderName()}\"$levelName: " .
TextFormat::RED . number_format(count($level->getChunks())) . TextFormat::GREEN . " chunks, " . TextFormat::RED . number_format(count($level->getChunks())) . TextFormat::GREEN . " chunks, " .
TextFormat::RED . number_format(count($level->getEntities())) . TextFormat::GREEN . " entities, " . TextFormat::RED . number_format(count($level->getEntities())) . TextFormat::GREEN . " entities. " .
TextFormat::RED . number_format(count($level->getTiles())) . TextFormat::GREEN . " tiles. " .
"Time $timeColor" . round($level->getTickRateTime(), 2) . "ms" . $tickRate "Time $timeColor" . round($level->getTickRateTime(), 2) . "ms" . $tickRate
); );
} }

View File

@ -133,9 +133,6 @@ class Level implements ChunkManager, Metadatable{
public const DIFFICULTY_NORMAL = 2; public const DIFFICULTY_NORMAL = 2;
public const DIFFICULTY_HARD = 3; public const DIFFICULTY_HARD = 3;
/** @var Tile[] */
private $tiles = [];
/** @var Player[] */ /** @var Player[] */
private $players = []; private $players = [];
@ -2008,16 +2005,6 @@ class Level implements ChunkManager, Metadatable{
return $currentTarget; return $currentTarget;
} }
/**
* Returns a list of the Tile entities in this level
*
* @return Tile[]
*/
public function getTiles() : array{
return $this->tiles;
}
/** /**
* Returns a list of the players in this level * Returns a list of the players in this level
* *
@ -2576,7 +2563,6 @@ class Level implements ChunkManager, Metadatable{
throw new \InvalidStateException("Attempted to create tile " . get_class($tile) . " in unloaded chunk $chunkX $chunkZ"); throw new \InvalidStateException("Attempted to create tile " . get_class($tile) . " in unloaded chunk $chunkX $chunkZ");
} }
$this->tiles[Level::blockHash($tile->x, $tile->y, $tile->z)] = $tile;
$tile->scheduleUpdate(); $tile->scheduleUpdate();
} }
@ -2590,7 +2576,7 @@ class Level implements ChunkManager, Metadatable{
throw new \InvalidArgumentException("Invalid Tile level"); throw new \InvalidArgumentException("Invalid Tile level");
} }
unset($this->tiles[$blockHash = Level::blockHash($tile->x, $tile->y, $tile->z)], $this->updateTiles[$blockHash]); unset($this->updateTiles[Level::blockHash($tile->x, $tile->y, $tile->z)]);
$chunkX = $tile->getFloorX() >> 4; $chunkX = $tile->getFloorX() >> 4;
$chunkZ = $tile->getFloorZ() >> 4; $chunkZ = $tile->getFloorZ() >> 4;