mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39: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){
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class Utils{
|
|||
|
||||
public static function wrapAngleTo360($angle)
|
||||
{
|
||||
$angle %= 360;
|
||||
$angle = (int)$angle % 360;
|
||||
return $angle < 0 ? $angle + 360 : $angle;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class Level{
|
|||
*/
|
||||
public $entityList;
|
||||
public $tiles, $blockUpdates, $nextSave, $players = [], $level, $mobSpawner;
|
||||
private $time, $startCheck, $startTime, $server, $name, $usedChunks, $changedBlocks, $changedCount, $stopTime;
|
||||
public $time, $startCheck, $startTime, $server, $name, $usedChunks, $changedBlocks, $changedCount, $stopTime;
|
||||
|
||||
private $generator;
|
||||
public function __construct(PMFLevel $level, Config $entities, Config $tiles, Config $blockUpdates, $name){
|
||||
|
|
@ -593,7 +593,7 @@ class Level{
|
|||
*/
|
||||
|
||||
public function getBlockWithoutVector($x, $y, $z, $positionfy = true){
|
||||
$b = $this->level->getBlock($x, $y, $z);
|
||||
$b = $this->level->getBlock((int)$x, (int)$y, (int)$z);
|
||||
return BlockAPI::get($b[0], $b[1], $positionfy ? new Position($x, $y, $z, $this) : false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,8 +38,9 @@ class MobSpawner{
|
|||
}else{
|
||||
return false;
|
||||
}
|
||||
$x = mt_rand(0,255);
|
||||
$z = mt_rand(0,255);
|
||||
$chunk = explode(".", array_rand($this->level->usedChunks, 1));
|
||||
$x = $chunk[0] * 16;
|
||||
$z = $chunk[1] * 16;
|
||||
$y = $this->getSafeY($x, $z, $grassOnly, $type >= 32 && $type <= 36 && $type != 35);
|
||||
if(!$y || $y < 0){
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@ class NormalGenerator implements NewLevelGenerator{
|
|||
$this->level = $level;
|
||||
$this->random = $random;
|
||||
$this->random->setSeed($this->level->getSeed());
|
||||
$this->noiseHills = new NoiseGeneratorSimplex($this->random, 3);
|
||||
$this->noisePatches = new NoiseGeneratorSimplex($this->random, 2);
|
||||
$this->noisePatchesSmall = new NoiseGeneratorSimplex($this->random, 2);
|
||||
$this->noiseBase = new NoiseGeneratorSimplex($this->random, 16);
|
||||
$this->noiseHills = new NoiseGeneratorPerlin($this->random, 3);
|
||||
$this->noisePatches = new NoiseGeneratorPerlin($this->random, 2);
|
||||
$this->noisePatchesSmall = new NoiseGeneratorPerlin($this->random, 2);
|
||||
$this->noiseBase = new NoiseGeneratorPerlin($this->random, 16);
|
||||
|
||||
$ores = new OrePopulator();
|
||||
$ores->setOreTypes(array(
|
||||
|
|
@ -72,7 +72,6 @@ class NormalGenerator implements NewLevelGenerator{
|
|||
$patches[$i] = $this->noisePatches->noise2D($x + ($chunkX << 4), $z + ($chunkZ << 4), 0.03, 16, true);
|
||||
$patchesSmall[$i] = $this->noisePatchesSmall->noise2D($x + ($chunkX << 4), $z + ($chunkZ << 4), 0.5, 4, true);
|
||||
$base[$i] = $this->noiseBase->noise2D($x + ($chunkX << 4), $z + ($chunkZ << 4), 0.7, 16, true);
|
||||
|
||||
if($base[$i] < 0){
|
||||
$base[$i] *= 0.5;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue