summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockOre.h
diff options
context:
space:
mode:
authorKingCol13 <48412633+KingCol13@users.noreply.github.com>2020-09-20 20:06:28 +0200
committerGitHub <noreply@github.com>2020-09-20 20:06:28 +0200
commitb6b7fb1a6549ba0c92c5db141af6f6f9bc1d3038 (patch)
tree709d341446623a083202a955f6e9a7105784ab5e /src/Blocks/BlockOre.h
parentIBM Z (#4892) (diff)
downloadcuberite-b6b7fb1a6549ba0c92c5db141af6f6f9bc1d3038.tar
cuberite-b6b7fb1a6549ba0c92c5db141af6f6f9bc1d3038.tar.gz
cuberite-b6b7fb1a6549ba0c92c5db141af6f6f9bc1d3038.tar.bz2
cuberite-b6b7fb1a6549ba0c92c5db141af6f6f9bc1d3038.tar.lz
cuberite-b6b7fb1a6549ba0c92c5db141af6f6f9bc1d3038.tar.xz
cuberite-b6b7fb1a6549ba0c92c5db141af6f6f9bc1d3038.tar.zst
cuberite-b6b7fb1a6549ba0c92c5db141af6f6f9bc1d3038.zip
Diffstat (limited to 'src/Blocks/BlockOre.h')
-rw-r--r--src/Blocks/BlockOre.h23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/Blocks/BlockOre.h b/src/Blocks/BlockOre.h
index e329a5781..6c01a6a27 100644
--- a/src/Blocks/BlockOre.h
+++ b/src/Blocks/BlockOre.h
@@ -3,10 +3,6 @@
#include "BlockHandler.h"
-
-
-
-
class cBlockOreHandler:
public cBlockHandler
{
@@ -31,17 +27,20 @@ private:
}
}
- // TODO: Handle the Fortune enchantment here
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);
+
switch (m_BlockType)
{
- case E_BLOCK_LAPIS_ORE: return cItem(E_ITEM_DYE, random.RandInt<char>(4, 8), 4);
- case E_BLOCK_REDSTONE_ORE: return cItem(E_ITEM_REDSTONE_DUST, random.RandInt<char>(4, 5), 0);
- case E_BLOCK_REDSTONE_ORE_GLOWING: return cItem(E_ITEM_REDSTONE_DUST, random.RandInt<char>(4, 5), 0);
- case E_BLOCK_DIAMOND_ORE: return cItem(E_ITEM_DIAMOND);
- case E_BLOCK_EMERALD_ORE: return cItem(E_ITEM_EMERALD);
- case E_BLOCK_COAL_ORE: return cItem(E_ITEM_COAL);
- case E_BLOCK_NETHER_QUARTZ_ORE: return cItem(E_ITEM_NETHER_QUARTZ);
+ 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_CLAY: return cItem(E_ITEM_CLAY, 4);
default:
{