Fixed update ticks

This commit is contained in:
Shoghi Cervantes 2014-06-22 21:32:49 +02:00
parent 279a438ae6
commit 0e36107878

View File

@ -164,7 +164,7 @@ class Level implements ChunkManager, Metadatable{
$this->server->getGenerationManager()->openLevel($this, $generator, $this->provider->getGeneratorOptions()); $this->server->getGenerationManager()->openLevel($this, $generator, $this->provider->getGeneratorOptions());
$this->folderName = $name; $this->folderName = $name;
$this->updateQueue = new ReversePriorityQueue();
$this->startTime = $this->time = (int) $this->provider->getTime(); $this->startTime = $this->time = (int) $this->provider->getTime();
$this->nextSave = $this->startCheck = microtime(true); $this->nextSave = $this->startCheck = microtime(true);
$this->nextSave = microtime(true) + 90; $this->nextSave = microtime(true) + 90;
@ -376,25 +376,27 @@ class Level implements ChunkManager, Metadatable{
$this->changedBlocks = []; $this->changedBlocks = [];
} }
$X = null; }
$Z = null;
//Do chunk updates $X = null;
while($this->updateQueue->count() > 0 and $this->updateQueue->current()["priority"] <= $currentTick){ $Z = null;
$block = $this->getBlock($this->updateQueue->extract()["data"]);
$block->onUpdate(self::BLOCK_UPDATE_SCHEDULED);
}
foreach($this->usedChunks as $index => $p){ //Do chunk updates
Level::getXZ($index, $X, $Z); while($this->updateQueue->count() > 0 and $this->updateQueue->current()["priority"] <= $currentTick){
for($Y = 0; $Y < 8; ++$Y){ $block = $this->getBlock($this->updateQueue->extract()["data"]);
if(!$this->getChunkAt($X, $Z, true)->isSectionEmpty($Y)){ $block->onUpdate(self::BLOCK_UPDATE_SCHEDULED);
for($i = 0; $i < 3; ++$i){
$block = $this->getBlock(new Vector3(($X << 4) + mt_rand(0, 15), ($Y << 4) + mt_rand(0, 15), ($Z << 4) + mt_rand(0, 15))); }
if($block instanceof Block){
if($block->onUpdate(self::BLOCK_UPDATE_RANDOM) === self::BLOCK_UPDATE_NORMAL){ foreach($this->usedChunks as $index => $p){
$this->updateAround($block, self::BLOCK_UPDATE_NORMAL); Level::getXZ($index, $X, $Z);
} for($Y = 0; $Y < 8; ++$Y){
if(!$this->getChunkAt($X, $Z, true)->isSectionEmpty($Y)){
for($i = 0; $i < 3; ++$i){
$block = $this->getBlock(new Vector3(($X << 4) + mt_rand(0, 15), ($Y << 4) + mt_rand(0, 15), ($Z << 4) + mt_rand(0, 15)));
if($block instanceof Block){
if($block->onUpdate(self::BLOCK_UPDATE_RANDOM) === self::BLOCK_UPDATE_NORMAL){
$this->updateAround($block, self::BLOCK_UPDATE_NORMAL);
} }
} }
} }