mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 03:59:43 +00:00
mobs will spawn only in loaded chunks, entities in unloaded chunks will automatically *rip*
This commit is contained in:
parent
bc979c2853
commit
8d1e76f84d
7 changed files with 21 additions and 12 deletions
|
|
@ -7,7 +7,7 @@ abstract class Creature extends Living{
|
|||
const CLASS_TYPE = ENTITY_MOB;
|
||||
|
||||
public $inPanic;
|
||||
|
||||
public $ignited;
|
||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||
$this->inPanic = false; //force for now
|
||||
parent::__construct($level, $eid, $class, $type, $data);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ class EntityAI
|
|||
* @param TaskBase $task
|
||||
*/
|
||||
public function addTask(TaskBase $task){
|
||||
console("[DEBUG] Adding new task...",true, true, 2);
|
||||
$this->tasks[$task->__toString()] = $task;
|
||||
}
|
||||
public function removeTask($name){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue