From 360d8eade0332f2c1aa5c205ca772cd506c35b26 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Tue, 13 Jun 2017 20:35:30 +0100 Subject: FastRandom rewrite (#3754) --- src/Mobs/Sheep.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/Mobs/Sheep.cpp') diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index 810d37a70..4adcedae9 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -65,8 +65,8 @@ void cSheep::OnRightClicked(cPlayer & a_Player) a_Player.UseEquippedItem(); cItems Drops; - int NumDrops = m_World->GetTickRandomNumber(2) + 1; - Drops.push_back(cItem(E_BLOCK_WOOL, static_cast(NumDrops), static_cast(m_WoolColor))); + char NumDrops = GetRandomProvider().RandInt(1, 3); + Drops.emplace_back(E_BLOCK_WOOL, NumDrops, static_cast(m_WoolColor)); m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10); m_World->BroadcastSoundEffect("entity.sheep.shear", GetPosX(), GetPosY(), GetPosZ(), 1.0f, 1.0f); } @@ -121,7 +121,7 @@ void cSheep::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) } else { - if (m_World->GetTickRandomNumber(600) == 1) + if (GetRandomProvider().RandBool(1.0 / 600.0)) { if (m_World->GetBlock(PosX, PosY, PosZ) == E_BLOCK_GRASS) { @@ -167,8 +167,7 @@ void cSheep::InheritFromParents(cPassiveMonster * a_Parent1, cPassiveMonster * a return; } } - cFastRandom Random; - SetFurColor((Random.NextInt(100) < 50) ? Parent1->GetFurColor() : Parent2->GetFurColor()); + SetFurColor(GetRandomProvider().RandBool() ? Parent1->GetFurColor() : Parent2->GetFurColor()); m_World->BroadcastEntityMetadata(*this); } @@ -178,8 +177,7 @@ void cSheep::InheritFromParents(cPassiveMonster * a_Parent1, cPassiveMonster * a NIBBLETYPE cSheep::GenerateNaturalRandomColor(void) { - cFastRandom Random; - int Chance = Random.NextInt(101); + int Chance = GetRandomProvider().RandInt(100); if (Chance <= 81) { -- cgit v1.2.3