summaryrefslogtreecommitdiffstats
path: root/src/MobSpawner.cpp
diff options
context:
space:
mode:
authorJK2K <39634161+JK2Kgit@users.noreply.github.com>2021-08-20 13:58:08 +0200
committerGitHub <noreply@github.com>2021-08-20 13:58:08 +0200
commit503b3c220f3a2b1f79205d60d5a4b2d28b07a3a0 (patch)
tree3f73d50ce142bbb92d5ea21a632756003d0457fe /src/MobSpawner.cpp
parentHaybale damage reduction implementation (#5277) (diff)
downloadcuberite-503b3c220f3a2b1f79205d60d5a4b2d28b07a3a0.tar
cuberite-503b3c220f3a2b1f79205d60d5a4b2d28b07a3a0.tar.gz
cuberite-503b3c220f3a2b1f79205d60d5a4b2d28b07a3a0.tar.bz2
cuberite-503b3c220f3a2b1f79205d60d5a4b2d28b07a3a0.tar.lz
cuberite-503b3c220f3a2b1f79205d60d5a4b2d28b07a3a0.tar.xz
cuberite-503b3c220f3a2b1f79205d60d5a4b2d28b07a3a0.tar.zst
cuberite-503b3c220f3a2b1f79205d60d5a4b2d28b07a3a0.zip
Diffstat (limited to '')
-rw-r--r--src/MobSpawner.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp
index c04467fd3..b66179898 100644
--- a/src/MobSpawner.cpp
+++ b/src/MobSpawner.cpp
@@ -208,12 +208,29 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, Vector3i a_RelPos, eMonsterType
case mtMagmaCube:
case mtSlime:
{
+ const int AMOUNT_MOON_PHASES = 8;
+ auto maxLight = Random.RandInt(0, 7);
+ auto moonPhaseNumber = static_cast<int>(std::floor(a_Chunk->GetWorld()->GetWorldAge().count() / 24000)) % AMOUNT_MOON_PHASES;
+ auto moonThreshold = static_cast<float>(std::abs(moonPhaseNumber - (AMOUNT_MOON_PHASES / 2)) / (AMOUNT_MOON_PHASES / 2));
return
(
(TargetBlock == E_BLOCK_AIR) &&
(BlockAbove == E_BLOCK_AIR) &&
- ((!cBlockInfo::IsTransparent(BlockBelow)) || (a_DisableSolidBelowCheck)) &&
- ((a_RelPos.y <= 40) || (a_Biome == biSwampland))
+ (
+ (!cBlockInfo::IsTransparent(BlockBelow)) ||
+ (a_DisableSolidBelowCheck)) &&
+ (
+ (a_RelPos.y <= 40) ||
+ (
+ (a_Biome == biSwampland) &&
+ (a_RelPos.y >= 50) &&
+ (a_RelPos.y <= 70) &&
+ (SkyLight <= maxLight) &&
+ (BlockLight <= maxLight) &&
+ (Random.RandBool(moonThreshold)) &&
+ (Random.RandBool(0.5))
+ )
+ )
);
}