summaryrefslogtreecommitdiffstats
path: root/src/Items/ItemDye.h
diff options
context:
space:
mode:
author0ddlyoko <nathangiaco@hotmail.com>2020-11-06 17:54:01 +0100
committerGitHub <noreply@github.com>2020-11-06 17:54:01 +0100
commit672bb0457012612ef59502b33717ee789c4d6bfe (patch)
tree962a76ff85b12a868009fa01659122386e695d0e /src/Items/ItemDye.h
parentEnder Crytal Fix and report proper cmake file for luabindingscheck fail (#5017) (diff)
downloadcuberite-672bb0457012612ef59502b33717ee789c4d6bfe.tar
cuberite-672bb0457012612ef59502b33717ee789c4d6bfe.tar.gz
cuberite-672bb0457012612ef59502b33717ee789c4d6bfe.tar.bz2
cuberite-672bb0457012612ef59502b33717ee789c4d6bfe.tar.lz
cuberite-672bb0457012612ef59502b33717ee789c4d6bfe.tar.xz
cuberite-672bb0457012612ef59502b33717ee789c4d6bfe.tar.zst
cuberite-672bb0457012612ef59502b33717ee789c4d6bfe.zip
Diffstat (limited to '')
-rw-r--r--src/Items/ItemDye.h51
1 files changed, 28 insertions, 23 deletions
diff --git a/src/Items/ItemDye.h b/src/Items/ItemDye.h
index da657007f..631e28e7d 100644
--- a/src/Items/ItemDye.h
+++ b/src/Items/ItemDye.h
@@ -102,13 +102,13 @@ public:
fertilization success is reported even in the case when the chance fails (bonemeal still needs to be consumed). */
static bool FertilizePlant(cWorld & a_World, Vector3i a_BlockPos)
{
- BLOCKTYPE blockType;
- NIBBLETYPE blockMeta;
- if (!a_World.GetBlockTypeMeta(a_BlockPos, blockType, blockMeta))
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ if (!a_World.GetBlockTypeMeta(a_BlockPos, BlockType, BlockMeta))
{
return false;
}
- switch (blockType)
+ switch (BlockType)
{
case E_BLOCK_WHEAT:
case E_BLOCK_CARROTS:
@@ -117,8 +117,8 @@ public:
case E_BLOCK_PUMPKIN_STEM:
{
// Grow by 2 - 5 stages:
- auto numStages = GetRandomProvider().RandInt(2, 5);
- if (a_World.GrowPlantAt(a_BlockPos, numStages) <= 0)
+ auto NumStages = GetRandomProvider().RandInt(2, 5);
+ if (a_World.GrowPlantAt(a_BlockPos, NumStages) <= 0)
{
return false;
}
@@ -128,14 +128,21 @@ public:
case E_BLOCK_BEETROOTS:
{
+ if (a_World.GrowPlantAt(a_BlockPos, 1) <= 0)
+ {
+ // Fix GH #4805 (bonemeal should only advance growth, not spawn produce):
+ return false;
+ }
+
+ a_World.BroadcastSoundParticleEffect(EffectID::PARTICLE_HAPPY_VILLAGER, a_BlockPos, 0);
+
// 75% chance of 1-stage growth:
- if (GetRandomProvider().RandBool(0.75))
+ if (!GetRandomProvider().RandBool(0.75))
{
- if (a_World.GrowPlantAt(a_BlockPos, 1) > 0)
- {
- a_World.BroadcastSoundParticleEffect(EffectID::PARTICLE_HAPPY_VILLAGER, a_BlockPos, 0);
- }
+ // Hit the 25%, rollback:
+ a_World.GrowPlantAt(a_BlockPos, -1);
}
+
return true;
} // case beetroots
@@ -144,27 +151,25 @@ public:
// 45% chance of growing to the next stage / full tree:
if (GetRandomProvider().RandBool(0.45))
{
- if (a_World.GrowPlantAt(a_BlockPos, 1) > 0)
- {
- a_World.BroadcastSoundParticleEffect(EffectID::PARTICLE_HAPPY_VILLAGER, a_BlockPos, 0);
- }
+ a_World.GrowPlantAt(a_BlockPos, 1);
}
+ a_World.BroadcastSoundParticleEffect(EffectID::PARTICLE_HAPPY_VILLAGER, a_BlockPos, 0);
return true;
- }
+ } // case sapling
case E_BLOCK_BIG_FLOWER:
{
// Drop the corresponding flower item without destroying the block:
- cItems pickups;
- switch (blockMeta)
+ cItems Pickups;
+ switch (BlockMeta)
{
- case E_META_BIG_FLOWER_SUNFLOWER: pickups.Add(E_BLOCK_BIG_FLOWER, 1, E_META_BIG_FLOWER_SUNFLOWER); break;
- case E_META_BIG_FLOWER_LILAC: pickups.Add(E_BLOCK_BIG_FLOWER, 1, E_META_BIG_FLOWER_LILAC); break;
- case E_META_BIG_FLOWER_ROSE_BUSH: pickups.Add(E_BLOCK_BIG_FLOWER, 1, E_META_BIG_FLOWER_ROSE_BUSH); break;
- case E_META_BIG_FLOWER_PEONY: pickups.Add(E_BLOCK_BIG_FLOWER, 1, E_META_BIG_FLOWER_PEONY); break;
+ case E_META_BIG_FLOWER_SUNFLOWER: Pickups.Add(E_BLOCK_BIG_FLOWER, 1, E_META_BIG_FLOWER_SUNFLOWER); break;
+ case E_META_BIG_FLOWER_LILAC: Pickups.Add(E_BLOCK_BIG_FLOWER, 1, E_META_BIG_FLOWER_LILAC); break;
+ case E_META_BIG_FLOWER_ROSE_BUSH: Pickups.Add(E_BLOCK_BIG_FLOWER, 1, E_META_BIG_FLOWER_ROSE_BUSH); break;
+ case E_META_BIG_FLOWER_PEONY: Pickups.Add(E_BLOCK_BIG_FLOWER, 1, E_META_BIG_FLOWER_PEONY); break;
}
// TODO: Should we call any hook for this?
- a_World.SpawnItemPickups(pickups, a_BlockPos);
+ a_World.SpawnItemPickups(Pickups, a_BlockPos);
return true;
} // big flower