diff options
author | peterbell10 <peterbell10@live.co.uk> | 2017-06-13 21:35:30 +0200 |
---|---|---|
committer | Lukas Pioch <lukas@zgow.de> | 2017-06-13 21:35:30 +0200 |
commit | 360d8eade0332f2c1aa5c205ca772cd506c35b26 (patch) | |
tree | 066fde557310742a39020bad9bc4aa2a5ef8d51a /src/Blocks/BlockCrops.h | |
parent | Corrected check for level of subcommand and fixed multiple levels not working (#3758) (diff) | |
download | cuberite-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 '')
-rw-r--r-- | src/Blocks/BlockCrops.h | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/Blocks/BlockCrops.h b/src/Blocks/BlockCrops.h index 5ca264774..378505430 100644 --- a/src/Blocks/BlockCrops.h +++ b/src/Blocks/BlockCrops.h @@ -26,7 +26,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_Meta) override { - cFastRandom rand; + auto & rand = GetRandomProvider(); // If not fully grown, drop the "seed" of whatever is growing: if (a_Meta < RipeMeta) @@ -51,30 +51,30 @@ public: { case E_BLOCK_BEETROOTS: { - char SeedCount = static_cast<char>(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2); // [1 .. 3] with high preference of 2 - a_Pickups.push_back(cItem(E_ITEM_BEETROOT_SEEDS, SeedCount, 0)); - char BeetrootCount = static_cast<char>(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2); // [1 .. 3] with high preference of 2 - a_Pickups.push_back(cItem(E_ITEM_BEETROOT, BeetrootCount, 0)); + char SeedCount = 1 + ((rand.RandInt<char>(2) + rand.RandInt<char>(2)) / 2); // [1 .. 3] with high preference of 2 + a_Pickups.emplace_back(E_ITEM_BEETROOT_SEEDS, SeedCount, 0); + char BeetrootCount = 1 + ((rand.RandInt<char>(2) + rand.RandInt<char>(2)) / 2); // [1 .. 3] with high preference of 2 + a_Pickups.emplace_back(E_ITEM_BEETROOT, BeetrootCount, 0); break; } case E_BLOCK_CROPS: { - a_Pickups.push_back(cItem(E_ITEM_WHEAT, 1, 0)); - a_Pickups.push_back(cItem(E_ITEM_SEEDS, static_cast<char>(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2), 0)); // [1 .. 3] with high preference of 2 + a_Pickups.emplace_back(E_ITEM_WHEAT, 1, 0); + a_Pickups.emplace_back(E_ITEM_SEEDS, 1 + ((rand.RandInt<char>(2) + rand.RandInt<char>(2)) / 2), 0); // [1 .. 3] with high preference of 2 break; } case E_BLOCK_CARROTS: { - a_Pickups.push_back(cItem(E_ITEM_CARROT, static_cast<char>(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2), 0)); // [1 .. 3] with high preference of 2 + a_Pickups.emplace_back(E_ITEM_CARROT, 1 + ((rand.RandInt<char>(2) + rand.RandInt<char>(2)) / 2), 0); // [1 .. 3] with high preference of 2 break; } case E_BLOCK_POTATOES: { - a_Pickups.push_back(cItem(E_ITEM_POTATO, static_cast<char>(1 + (rand.NextInt(3) + rand.NextInt(3)) / 2), 0)); // [1 .. 3] with high preference of 2 - if (rand.NextInt(21) == 0) + a_Pickups.emplace_back(E_ITEM_POTATO, 1 + ((rand.RandInt<char>(2) + rand.RandInt<char>(2)) / 2), 0); // [1 .. 3] with high preference of 2 + if (rand.RandBool(0.05)) { // With a 5% chance, drop a poisonous potato as well - a_Pickups.push_back(cItem(E_ITEM_POISONOUS_POTATO, 1, 0)); + a_Pickups.emplace_back(E_ITEM_POISONOUS_POTATO, 1, 0); } break; } |