changed how mobs spawn a bit

This commit is contained in:
GameHerobrine 2024-07-02 21:13:11 +03:00
parent ae59d3da59
commit 72a1a93283
2 changed files with 30 additions and 19 deletions

View file

@ -598,7 +598,7 @@ class Level{
$this->checkSleep(); $this->checkSleep();
if($server->ticks % 10 === 0){ if($server->ticks % 100 === 0){
$this->mobSpawner->handle(); $this->mobSpawner->handle();
} }

View file

@ -80,18 +80,27 @@ class MobSpawner{
continue; continue;
} }
$y = $this->getSafeY($x, $z, $grassOnly, $type >= 32 && $type <= 36 && $type != 35); $cnt = mt_rand(1, 3);
for($i = 0; $i < $cnt; ++$i){
$xMob = $x + mt_rand(-3, 3);
$zMob = $z + mt_rand(-3, 3);
$y = $this->getSafeY($xMob, $zMob, $grassOnly, $type >= 32 && $type <= 36 && $type != 35);
if(!$y || $y < 0){ if(!$y || $y < 0){
continue; continue;
} }
$data = $this->genPosData($x, $y + 0.5, $z);
$data = $this->genPosData($xMob, $y + 0.5, $zMob);
if($baby != 2) $data["IsBaby"] = $baby; if($baby != 2) $data["IsBaby"] = $baby;
$e = $this->server->api->entity->add($this->level, 2, $type, $data); $e = $this->server->api->entity->add($this->level, 2, $type, $data);
if($e instanceof Entity){ if($e instanceof Entity){
$this->server->api->entity->spawnToAll($e); $this->server->api->entity->spawnToAll($e);
//ConsoleAPI::debug("$type spawned at $x, $y, $z"); ConsoleAPI::debug("$type spawned at $xMob, $y, $zMob");
} }
if(!isset($this->playerAffectedEIDS[$player->entity->eid])){ if(!isset($this->playerAffectedEIDS[$player->entity->eid])){
$this->playerAffectedEIDS[$player->entity->eid] = [$e->eid => true]; $this->playerAffectedEIDS[$player->entity->eid] = [$e->eid => true];
@ -100,6 +109,8 @@ class MobSpawner{
} }
$this->entityAffectedPlayers[$e->eid] = $player->entity->eid; $this->entityAffectedPlayers[$e->eid] = $player->entity->eid;
}
} }