mobs will spawn only in loaded chunks, entities in unloaded chunks will automatically *rip*

This commit is contained in:
GameHerobrine 2023-07-04 03:57:40 +03:00
parent bc979c2853
commit 8d1e76f84d
7 changed files with 21 additions and 12 deletions

View file

@ -508,6 +508,12 @@ class Entity extends Position
$this->lastUpdate = $now;
return;
}
if(!$this->isPlayer() && !isset($this->level->usedChunks[((int)$this->x >> 4).".".((int)$this->z >> 4)])){
$this->close();
return false;
}
$tdiff = $now - $this->lastUpdate;
if($this->tickCounter === 0){
$this->tickCounter = 1;
@ -1003,6 +1009,10 @@ class Entity extends Position
{
if($this->closed === false){
$this->closed = true;
if($this?->linkedEntity?->linkedEntity?->eid === $this->eid){
$this->linkedEntity->linkedEntity = false;
}
$this->linkedEntity = false;
$this->server->api->entity->remove($this->eid);
}
}