mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 09:19:42 +00:00
Chunk: drop premature optimizations
This commit is contained in:
parent
722da5e88d
commit
92035ac2ec
@ -64,9 +64,6 @@ class Chunk{
|
||||
/** @var bool */
|
||||
protected $hasChanged = false;
|
||||
|
||||
/** @var bool */
|
||||
protected $isInit = false;
|
||||
|
||||
/** @var bool */
|
||||
protected $lightPopulated = false;
|
||||
/** @var bool */
|
||||
@ -464,7 +461,7 @@ class Chunk{
|
||||
throw new \InvalidArgumentException("Attempted to add a garbage closed Entity to a chunk");
|
||||
}
|
||||
$this->entities[$entity->getId()] = $entity;
|
||||
if(!($entity instanceof Player) and $this->isInit){
|
||||
if(!($entity instanceof Player)){
|
||||
$this->hasChanged = true;
|
||||
}
|
||||
}
|
||||
@ -474,7 +471,7 @@ class Chunk{
|
||||
*/
|
||||
public function removeEntity(Entity $entity) : void{
|
||||
unset($this->entities[$entity->getId()]);
|
||||
if(!($entity instanceof Player) and $this->isInit){
|
||||
if(!($entity instanceof Player)){
|
||||
$this->hasChanged = true;
|
||||
}
|
||||
}
|
||||
@ -491,20 +488,16 @@ class Chunk{
|
||||
$this->tiles[$index]->close();
|
||||
}
|
||||
$this->tiles[$index] = $tile;
|
||||
if($this->isInit){
|
||||
$this->hasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Tile $tile
|
||||
*/
|
||||
public function removeTile(Tile $tile) : void{
|
||||
unset($this->tiles[Chunk::blockHash($tile->x, $tile->y, $tile->z)]);
|
||||
if($this->isInit){
|
||||
$this->hasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of entities currently using this chunk.
|
||||
@ -578,7 +571,6 @@ class Chunk{
|
||||
* @param World $world
|
||||
*/
|
||||
public function initChunk(World $world) : void{
|
||||
if(!$this->isInit){
|
||||
if($this->NBTentities !== null){
|
||||
$this->hasChanged = true;
|
||||
$world->timings->syncChunkLoadEntitiesTimer->startTiming();
|
||||
@ -617,9 +609,6 @@ class Chunk{
|
||||
$this->NBTtiles = null;
|
||||
$world->timings->syncChunkLoadTileEntitiesTimer->stopTiming();
|
||||
}
|
||||
|
||||
$this->isInit = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user