Faster chunk loading

This commit is contained in:
Shoghi Cervantes 2014-06-10 11:27:30 +02:00
parent 3fbc411e17
commit b6caad289d

View File

@ -508,7 +508,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
} }
if(is_array($this->lastChunk)){ if(is_array($this->lastChunk)){
$identifier = $this->lastChunk[2]; /*$identifier = $this->lastChunk[2];
if(!$this->checkACK($identifier)){ if(!$this->checkACK($identifier)){
if((microtime(true) - $this->lastChunk[3]) < 1.5){ if((microtime(true) - $this->lastChunk[3]) < 1.5){
$this->server->getScheduler()->scheduleDelayedTask(new CallbackTask(array($this, "getNextChunk"), array(false, true)), MAX_CHUNK_RATE); $this->server->getScheduler()->scheduleDelayedTask(new CallbackTask(array($this, "getNextChunk"), array(false, true)), MAX_CHUNK_RATE);
@ -518,7 +518,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
LevelFormat::getXZ($index, $this->lastChunk[0], $this->lastChunk[1]); LevelFormat::getXZ($index, $this->lastChunk[0], $this->lastChunk[1]);
unset($this->chunksLoaded[$index]); unset($this->chunksLoaded[$index]);
} }
}else{ }else{*/
foreach($this->getLevel()->getChunkEntities($this->lastChunk[0], $this->lastChunk[1]) as $entity){ foreach($this->getLevel()->getChunkEntities($this->lastChunk[0], $this->lastChunk[1]) as $entity){
if($entity !== $this){ if($entity !== $this){
$entity->spawnTo($this); $entity->spawnTo($this);
@ -530,7 +530,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
} }
} }
} //}
$this->lastChunk = false; $this->lastChunk = false;
} }
@ -660,6 +660,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$entity->despawnFrom($this); $entity->despawnFrom($this);
} }
} }
}else{
$pk = new UnloadChunkPacket(); $pk = new UnloadChunkPacket();
$pk->chunkX = $X; $pk->chunkX = $X;
$pk->chunkZ = $Z; $pk->chunkZ = $Z;