MobSpawner rewrite

This commit is contained in:
GameHerobrine 2022-12-19 13:51:40 +03:00
parent a75b4cc4de
commit 4835c15747
6 changed files with 98 additions and 131 deletions

View file

@ -31,6 +31,7 @@ class Level{
$this->usedChunks = [];
$this->changedBlocks = [];
$this->changedCount = [];
$this->mobSpawner = new MobSpawner($this);
}
public function close(){
@ -77,6 +78,7 @@ class Level{
$this->level->close();
unset($this->level);
}
unset($this->mobSpawner->level);
}
public function save($force = false, $extra = true){
@ -268,6 +270,10 @@ class Level{
$e->update();
}
}
if(Entity::$updateOnTick && $server->ticks % 40 === 0){ //40 ticks delay
$this->mobSpawner->handle();
}
}
public function setBlock(Vector3 $pos, Block $block, $update = true, $tiles = false, $direct = false){
@ -536,4 +542,4 @@ class Level{
}
return $this->server->api->block->scheduleBlockUpdate($pos, $delay, $type);
}
}
}