diff --git a/src/entity/Creature.php b/src/entity/Creature.php index 3cb70748..eb97bb34 100644 --- a/src/entity/Creature.php +++ b/src/entity/Creature.php @@ -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); diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 2ec83f18..295eb139 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -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); } } diff --git a/src/entity/ai/EntityAI.php b/src/entity/ai/EntityAI.php index 14a4648c..e290ac10 100644 --- a/src/entity/ai/EntityAI.php +++ b/src/entity/ai/EntityAI.php @@ -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){ diff --git a/src/utils/Utils.php b/src/utils/Utils.php index c926d410..5465d862 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -41,7 +41,7 @@ class Utils{ public static function wrapAngleTo360($angle) { - $angle %= 360; + $angle = (int)$angle % 360; return $angle < 0 ? $angle + 360 : $angle; } diff --git a/src/world/Level.php b/src/world/Level.php index bfcecdf2..1dd4c778 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -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); } diff --git a/src/world/MobSpawner.php b/src/world/MobSpawner.php index bdb878b4..36ffd2ab 100644 --- a/src/world/MobSpawner.php +++ b/src/world/MobSpawner.php @@ -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; diff --git a/src/world/generator/NormalGenerator.php b/src/world/generator/NormalGenerator.php index 2c996d15..47db5f54 100644 --- a/src/world/generator/NormalGenerator.php +++ b/src/world/generator/NormalGenerator.php @@ -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; }