From b7e88e2c9f96f31e29a85c3d7ef312fb4bd8c549 Mon Sep 17 00:00:00 2001 From: Mat Date: Wed, 25 Mar 2020 12:49:36 +0200 Subject: Fix nether mob spawning (#4546) * Fix nether mob spawning * Remove zombie from nether mobs --- src/MobSpawner.cpp | 173 ++++++++++++++++++++++++++++------------------------- src/World.cpp | 2 +- 2 files changed, 94 insertions(+), 81 deletions(-) diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index 17725e4d9..5cb8f0d33 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -111,19 +111,37 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, Vector3i a_RelPos, eMonsterType switch (a_MobType) { - case mtGuardian: + case mtBat: { - return IsBlockWater(targetBlock) && IsBlockWater(blockBelow) && (a_RelPos.y >= 45) && (a_RelPos.y <= 62); + return ( + (a_RelPos.y <= 63) && + (blockLight <= 4) && + (skyLight <= 4) && + (targetBlock == E_BLOCK_AIR) && + (!cBlockInfo::IsTransparent(blockAbove)) + ); } - case mtSquid: + case mtBlaze: + case mtGhast: { - return IsBlockWater(targetBlock) && (a_RelPos.y >= 45) && (a_RelPos.y <= 62); + return ( + (targetBlock == E_BLOCK_AIR) && + (blockAbove == E_BLOCK_AIR) && + (!cBlockInfo::IsTransparent(blockBelow)) && + (random.RandBool()) + ); } - case mtBat: + case mtCaveSpider: { - return (a_RelPos.y <= 63) && (blockLight <= 4) && (skyLight <= 4) && (targetBlock == E_BLOCK_AIR) && !cBlockInfo::IsTransparent(blockAbove); + return ( + (targetBlock == E_BLOCK_AIR) && + (!cBlockInfo::IsTransparent(blockBelow)) && + (skyLight <= 7) && + (blockLight <= 7) && + (random.RandBool()) + ); } case mtChicken: @@ -136,22 +154,22 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, Vector3i a_RelPos, eMonsterType return ( (targetBlock == E_BLOCK_AIR) && (blockAbove == E_BLOCK_AIR) && - (!cBlockInfo::IsTransparent(blockBelow)) && (blockBelow == E_BLOCK_GRASS) && (skyLight >= 9) ); } - case mtOcelot: + case mtCreeper: + case mtSkeleton: + case mtZombie: { return ( (targetBlock == E_BLOCK_AIR) && (blockAbove == E_BLOCK_AIR) && - ( - (blockBelow == E_BLOCK_GRASS) || (blockBelow == E_BLOCK_LEAVES) || (blockBelow == E_BLOCK_NEW_LEAVES) - ) && - (a_RelPos.y >= 62) && - (random.RandBool(2.0 / 3.0)) + (!cBlockInfo::IsTransparent(blockBelow)) && + (skyLight <= 7) && + (blockLight <= 7) && + (random.RandBool()) ); } @@ -176,6 +194,55 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, Vector3i a_RelPos, eMonsterType break; } + case mtGuardian: + { + return ( + IsBlockWater(targetBlock) && + IsBlockWater(blockBelow) && + (a_RelPos.y >= 45) && + (a_RelPos.y <= 62) + ); + } + + case mtMagmaCube: + case mtSlime: + { + return ( + (targetBlock == E_BLOCK_AIR) && + (blockAbove == E_BLOCK_AIR) && + (!cBlockInfo::IsTransparent(blockBelow)) && + ( + (a_RelPos.y <= 40) || (a_Biome == biSwampland) + ) + ); + } + + case mtMooshroom: + { + return ( + (targetBlock == E_BLOCK_AIR) && + (blockAbove == E_BLOCK_AIR) && + (blockBelow == E_BLOCK_MYCELIUM) && + ( + (a_Biome == biMushroomShore) || + (a_Biome == biMushroomIsland) + ) + ); + } + + case mtOcelot: + { + return ( + (targetBlock == E_BLOCK_AIR) && + (blockAbove == E_BLOCK_AIR) && + ( + (blockBelow == E_BLOCK_GRASS) || (blockBelow == E_BLOCK_LEAVES) || (blockBelow == E_BLOCK_NEW_LEAVES) + ) && + (a_RelPos.y >= 62) && + (random.RandBool(2.0 / 3.0)) + ); + } + case mtSpider: { bool canSpawn = true; @@ -202,52 +269,12 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, Vector3i a_RelPos, eMonsterType return canSpawn && hasFloor && (skyLight <= 7) && (blockLight <= 7); } - case mtCaveSpider: - { - return ( - (targetBlock == E_BLOCK_AIR) && - (!cBlockInfo::IsTransparent(blockBelow)) && - (skyLight <= 7) && - (blockLight <= 7) && - (random.RandBool()) - ); - } - - case mtCreeper: - case mtSkeleton: - case mtZombie: - { - return ( - (targetBlock == E_BLOCK_AIR) && - (blockAbove == E_BLOCK_AIR) && - (!cBlockInfo::IsTransparent(blockBelow)) && - (skyLight <= 7) && - (blockLight <= 7) && - (random.RandBool()) - ); - } - - case mtMagmaCube: - case mtSlime: + case mtSquid: { return ( - (targetBlock == E_BLOCK_AIR) && - (blockAbove == E_BLOCK_AIR) && - (!cBlockInfo::IsTransparent(blockBelow)) && - ( - (a_RelPos.y <= 40) || (a_Biome == biSwampland) - ) - ); - } - - case mtGhast: - case mtZombiePigman: - { - return ( - (targetBlock == E_BLOCK_AIR) && - (blockAbove == E_BLOCK_AIR) && - (!cBlockInfo::IsTransparent(blockBelow)) && - (random.RandBool(0.05)) + IsBlockWater(targetBlock) && + (a_RelPos.y >= 45) && + (a_RelPos.y <= 62) ); } @@ -270,16 +297,12 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, Vector3i a_RelPos, eMonsterType ); } - case mtMooshroom: + case mtZombiePigman: { return ( (targetBlock == E_BLOCK_AIR) && (blockAbove == E_BLOCK_AIR) && - (blockBelow == E_BLOCK_MYCELIUM) && - ( - (a_Biome == biMushroomShore) || - (a_Biome == biMushroomIsland) - ) + (!cBlockInfo::IsTransparent(blockBelow)) ); } @@ -302,23 +325,6 @@ std::set cMobSpawner::GetAllowedMobTypes(EMCSBiome a_Biome) // Check biomes first to get a list of animals switch (a_Biome) { - // Nether mobs and endermen only - no other mobs in the nether - case biNether: - { - ListOfSpawnables.insert(mtGhast); - ListOfSpawnables.insert(mtMagmaCube); - ListOfSpawnables.insert(mtZombiePigman); - ListOfSpawnables.insert(mtEnderman); - return ListOfSpawnables; - } - - // Endermen only - no other mobs in the end - case biEnd: - { - ListOfSpawnables.insert(mtEnderman); - return ListOfSpawnables; - } - // Mooshroom only - no other mobs on mushroom islands case biMushroomIsland: case biMushroomShore: @@ -400,6 +406,7 @@ std::set cMobSpawner::GetAllowedMobTypes(EMCSBiome a_Biome) } } + // Overworld if ( (a_Biome != biDesertHills) && (a_Biome != biDesert) && @@ -423,6 +430,12 @@ std::set cMobSpawner::GetAllowedMobTypes(EMCSBiome a_Biome) ListOfSpawnables.insert(mtCreeper); ListOfSpawnables.insert(mtSquid); + // Nether + ListOfSpawnables.insert(mtBlaze); + ListOfSpawnables.insert(mtGhast); + ListOfSpawnables.insert(mtMagmaCube); + ListOfSpawnables.insert(mtZombiePigman); + return ListOfSpawnables; } diff --git a/src/World.cpp b/src/World.cpp index cfbbb4ff6..13b544a78 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -890,7 +890,7 @@ void cWorld::InitializeAndLoadMobSpawningValues(cIniFile & a_IniFile) switch (m_Dimension) { case dimOverworld: DefaultMonsters = "bat, cavespider, chicken, cow, creeper, guardian, horse, mooshroom, ocelot, pig, rabbit, sheep, silverfish, skeleton, slime, spider, squid, wolf, zombie"; break; // TODO Re-add Enderman when bugs are fixed - case dimNether: DefaultMonsters = "blaze, ghast, magmacube, skeleton, zombie, zombiepigman"; break; + case dimNether: DefaultMonsters = "blaze, ghast, magmacube, skeleton, zombiepigman"; break; case dimEnd: DefaultMonsters = ""; break; // TODO Re-add Enderman when bugs are fixed case dimNotSet: ASSERT(!"Dimension not set"); break; } -- cgit v1.2.3