summaryrefslogtreecommitdiffstats
path: root/src/MobSpawner.cpp
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2017-06-13 21:35:30 +0200
committerLukas Pioch <lukas@zgow.de>2017-06-13 21:35:30 +0200
commit360d8eade0332f2c1aa5c205ca772cd506c35b26 (patch)
tree066fde557310742a39020bad9bc4aa2a5ef8d51a /src/MobSpawner.cpp
parentCorrected check for level of subcommand and fixed multiple levels not working (#3758) (diff)
downloadcuberite-360d8eade0332f2c1aa5c205ca772cd506c35b26.tar
cuberite-360d8eade0332f2c1aa5c205ca772cd506c35b26.tar.gz
cuberite-360d8eade0332f2c1aa5c205ca772cd506c35b26.tar.bz2
cuberite-360d8eade0332f2c1aa5c205ca772cd506c35b26.tar.lz
cuberite-360d8eade0332f2c1aa5c205ca772cd506c35b26.tar.xz
cuberite-360d8eade0332f2c1aa5c205ca772cd506c35b26.tar.zst
cuberite-360d8eade0332f2c1aa5c205ca772cd506c35b26.zip
Diffstat (limited to 'src/MobSpawner.cpp')
-rw-r--r--src/MobSpawner.cpp16
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))
);
}