mobs wont spawn if brightness is too high, aditional file with world data for storing additional information

This commit is contained in:
GameHerobrine 2025-06-23 07:02:31 +03:00
parent d1a724c143
commit cd07581d49
4 changed files with 175 additions and 13 deletions

View file

@ -88,7 +88,7 @@ class MobSpawner{
$zMob = $z + mt_rand(-3, 3);
$y = $this->getSafeY($xMob, $zMob, $grassOnly, $type >= 32 && $type <= 36 && $type != 35);
$y = $this->getSafeY($xMob, $zMob, $grassOnly, $type >= 32 && $type <= 36 && $type != 35, $type >= 32 && $type <= 36);
if(!$y || $y < 0){
continue;
}
@ -125,7 +125,7 @@ class MobSpawner{
];
}
protected function getSafeY($x, $z, $grassOnly = false, $highMob = false){ //first safe block //TODO check boundingbox
protected function getSafeY($x, $z, $grassOnly = false, $highMob = false, $isMonster = false){ //first safe block //TODO check boundingbox
$allowed = [];
for($y = 0; $y < 128; ++$y){
$b = $this->level->level->getBlockID($x, $y, $z);
@ -136,6 +136,9 @@ class MobSpawner{
(StaticBlock::getIsSolid($b1) && (!$grassOnly || $b1 === GRASS) &&
(!$highMob || !StaticBlock::getIsSolid($b2) && !StaticBlock::getIsLiquid($b2)))
){
if($isMonster && ($rb = $this->level->getRawBrightness($x, $y, $z)) > 8){ //dont spawn if too bright
continue;
}
$allowed[] = $y;
}
}