diff options
Diffstat (limited to '')
-rw-r--r-- | src/MobSpawner.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp index 60f7cfb43..98c428bab 100644 --- a/src/MobSpawner.cpp +++ b/src/MobSpawner.cpp @@ -111,12 +111,8 @@ eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome) if (allowedMobsSize > 0) { std::set<eMonsterType>::iterator itr = allowedMobs.begin(); - int iRandom = m_Random.NextInt(static_cast<int>(allowedMobsSize)); - for (int i = 0; i < iRandom; i++) - { - ++itr; - } + std::advance(itr, GetRandomProvider().RandInt<size_t>(allowedMobsSize - 1)); return *itr; } @@ -139,7 +135,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R return false; // Make sure mobs do not spawn on bedrock. } - cFastRandom Random; + auto & Random = GetRandomProvider(); BLOCKTYPE TargetBlock = a_Chunk->GetBlock(a_RelX, a_RelY, a_RelZ); cPlayer * a_Closest_Player = a_Chunk->GetWorld()->FindClosestPlayer(a_Chunk->PositionToWorldPosition(a_RelX, a_RelY, a_RelZ), 24); @@ -202,7 +198,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R (BlockBelow == E_BLOCK_GRASS) || (BlockBelow == E_BLOCK_LEAVES) || (BlockBelow == E_BLOCK_NEW_LEAVES) ) && (a_RelY >= 62) && - (Random.NextInt(3) != 0) + (Random.RandBool(2.0 / 3.0)) ); } @@ -260,7 +256,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R (!cBlockInfo::IsTransparent(BlockBelow)) && (SkyLight <= 7) && (BlockLight <= 7) && - (Random.NextInt(2) == 0) + (Random.RandBool()) ); } @@ -274,7 +270,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R (!cBlockInfo::IsTransparent(BlockBelow)) && (SkyLight <= 7) && (BlockLight <= 7) && - (Random.NextInt(2) == 0) + (Random.RandBool()) ); } @@ -298,7 +294,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && (!cBlockInfo::IsTransparent(BlockBelow)) && - (Random.NextInt(20) == 0) + (Random.RandBool(0.05)) ); } |