summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockOre.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-09-22 12:08:12 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2020-09-23 15:34:15 +0200
commit71b96ab921bed0371d7c75ac4a2db99b94591de2 (patch)
tree618e9e37799cbf07a55f4a3950071e067358753f /src/Blocks/BlockOre.h
parentAdded dtEnvitonment to player damage text (#4925) (diff)
downloadcuberite-71b96ab921bed0371d7c75ac4a2db99b94591de2.tar
cuberite-71b96ab921bed0371d7c75ac4a2db99b94591de2.tar.gz
cuberite-71b96ab921bed0371d7c75ac4a2db99b94591de2.tar.bz2
cuberite-71b96ab921bed0371d7c75ac4a2db99b94591de2.tar.lz
cuberite-71b96ab921bed0371d7c75ac4a2db99b94591de2.tar.xz
cuberite-71b96ab921bed0371d7c75ac4a2db99b94591de2.tar.zst
cuberite-71b96ab921bed0371d7c75ac4a2db99b94591de2.zip
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockOre.h27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/Blocks/BlockOre.h b/src/Blocks/BlockOre.h
index 6c01a6a27..5dbeac268 100644
--- a/src/Blocks/BlockOre.h
+++ b/src/Blocks/BlockOre.h
@@ -3,6 +3,10 @@
#include "BlockHandler.h"
+
+
+
+
class cBlockOreHandler:
public cBlockHandler
{
@@ -21,26 +25,25 @@ private:
{
switch (m_BlockType)
{
- // If it was a glowing redstone ore, drop a normal redstone ore
+ // If it was a glowing redstone ore, drop a normal redstone ore:
case E_BLOCK_REDSTONE_ORE_GLOWING: return cItem(E_BLOCK_REDSTONE_ORE);
default: return cItem(m_BlockType);
}
}
- auto & random = GetRandomProvider();
- const unsigned int FortuneLevel = ToolFortuneLevel(a_Tool);
- // Clamp to 10 to prevent server crash if thing are mined with extremely high level fortune pick
- const unsigned int DropMult = std::clamp<unsigned int>(FloorC(random.RandReal(FortuneLevel + 2.0)), 1, 10);
+ auto & Random = GetRandomProvider();
+ const auto FortuneLevel = ToolFortuneLevel(a_Tool);
+ const auto Drops = std::max(static_cast<char>(1), FloorC<char>(Random.RandReal(FortuneLevel + 2.0)));
switch (m_BlockType)
{
- case E_BLOCK_LAPIS_ORE: return cItem(E_ITEM_DYE, DropMult * random.RandInt<char>(4, 9), 4);
- case E_BLOCK_REDSTONE_ORE: // handled by next case (glowing redstone), no dropMult
- case E_BLOCK_REDSTONE_ORE_GLOWING: return cItem(E_ITEM_REDSTONE_DUST, random.RandInt<char>(4, 5 + FortuneLevel), 0);
- case E_BLOCK_DIAMOND_ORE: return cItem(E_ITEM_DIAMOND, DropMult);
- case E_BLOCK_EMERALD_ORE: return cItem(E_ITEM_EMERALD, DropMult);
- case E_BLOCK_COAL_ORE: return cItem(E_ITEM_COAL, DropMult);
- case E_BLOCK_NETHER_QUARTZ_ORE: return cItem(E_ITEM_NETHER_QUARTZ, DropMult);
+ case E_BLOCK_LAPIS_ORE: return cItem(E_ITEM_DYE, Drops * Random.RandInt<char>(4, 9), 4);
+ case E_BLOCK_REDSTONE_ORE: // Handled by next case (glowing redstone)
+ case E_BLOCK_REDSTONE_ORE_GLOWING: return cItem(E_ITEM_REDSTONE_DUST, Random.RandInt<char>(4, 5 + FortuneLevel));
+ case E_BLOCK_DIAMOND_ORE: return cItem(E_ITEM_DIAMOND, Drops);
+ case E_BLOCK_EMERALD_ORE: return cItem(E_ITEM_EMERALD, Drops);
+ case E_BLOCK_COAL_ORE: return cItem(E_ITEM_COAL, Drops);
+ case E_BLOCK_NETHER_QUARTZ_ORE: return cItem(E_ITEM_NETHER_QUARTZ, Drops);
case E_BLOCK_CLAY: return cItem(E_ITEM_CLAY, 4);
default:
{