summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Harkness <me@bearbin.net>2015-05-18 14:32:47 +0200
committerAlexander Harkness <bearbin@gmail.com>2015-05-18 14:43:00 +0200
commitaedf9d05cb798e2ed3f9666028d12753929504fc (patch)
tree43d76da3964bcafe97d6ddee5260fed88e8e5649
parentMerge branch 'master' of https://github.com/mc-server/MCServer (diff)
downloadcuberite-aedf9d05cb798e2ed3f9666028d12753929504fc.tar
cuberite-aedf9d05cb798e2ed3f9666028d12753929504fc.tar.gz
cuberite-aedf9d05cb798e2ed3f9666028d12753929504fc.tar.bz2
cuberite-aedf9d05cb798e2ed3f9666028d12753929504fc.tar.lz
cuberite-aedf9d05cb798e2ed3f9666028d12753929504fc.tar.xz
cuberite-aedf9d05cb798e2ed3f9666028d12753929504fc.tar.zst
cuberite-aedf9d05cb798e2ed3f9666028d12753929504fc.zip
-rw-r--r--src/Blocks/BlockLeaves.h28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h
index 8e44c94ac..4d4610fd8 100644
--- a/src/Blocks/BlockLeaves.h
+++ b/src/Blocks/BlockLeaves.h
@@ -40,29 +40,41 @@ public:
{
cFastRandom rand;
- // Old leaves - 3 bits contain display; new leaves - 1st bit, shifted left two for saplings to understand
- if (rand.NextInt(20) == 0)
+ // There is a chance to drop a sapling that varies depending on the type of leaf broken.
+ // TODO: Take into account fortune for sapling drops.
+ int chance;
+ if ((m_BlockType == E_BLOCK_LEAVES) && ((a_BlockMeta & 0x03) == E_META_LEAVES_JUNGLE))
+ {
+ // Jungle leaves have a 2.5% chance of dropping a sapling.
+ chance = rand.NextInt(40);
+ }
+ else
+ {
+ // Other leaves have a 5% chance of dropping a sapling.
+ chance = rand.NextInt(20);
+ }
+ if (chance == 0)
{
a_Pickups.push_back(
cItem(
E_BLOCK_SAPLING,
1,
- (m_BlockType == E_BLOCK_LEAVES) ? (a_BlockMeta & 0x03) : (2 << (a_BlockMeta & 0x01))
+ (m_BlockType == E_BLOCK_LEAVES) ? (a_BlockMeta & 0x03) : (4 + (a_BlockMeta & 0x01))
)
);
}
-
- // 1 % chance of dropping an apple, if the leaves' type is Apple Leaves
+
+ // 0.5 % chance of dropping an apple, if the leaves' type is Apple Leaves
if ((m_BlockType == E_BLOCK_LEAVES) && ((a_BlockMeta & 0x03) == E_META_LEAVES_APPLE))
{
- if (rand.NextInt(101) == 0)
+ if (rand.NextInt(200) == 0)
{
a_Pickups.push_back(cItem(E_ITEM_RED_APPLE, 1, 0));
}
}
}
-
-
+
+
virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);