summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockCrops.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockCrops.h45
1 files changed, 20 insertions, 25 deletions
diff --git a/src/Blocks/BlockCrops.h b/src/Blocks/BlockCrops.h
index aab2c18cd..fe90d6127 100644
--- a/src/Blocks/BlockCrops.h
+++ b/src/Blocks/BlockCrops.h
@@ -52,37 +52,42 @@ private:
}
// Fully grown, drop the crop's produce:
- cItems res;
+ cItems Res;
+
switch (m_BlockType)
{
case E_BLOCK_BEETROOTS:
{
const auto SeedCount = CalculateSeedCount(0, 3, ToolFortuneLevel(a_Tool));
- res.Add(E_ITEM_BEETROOT_SEEDS, SeedCount);
- res.Add(E_ITEM_BEETROOT);
+ Res.Add(E_ITEM_BEETROOT_SEEDS, SeedCount);
+ Res.Add(E_ITEM_BEETROOT);
break;
}
case E_BLOCK_CROPS:
{
- res.Add(E_ITEM_WHEAT);
+ // https://minecraft.fandom.com/wiki/Seeds_(Wheat)
+ Res.Add(E_ITEM_WHEAT);
const auto SeedCount = CalculateSeedCount(1, 3, ToolFortuneLevel(a_Tool));
- res.Add(E_ITEM_SEEDS, SeedCount);
+ Res.Add(E_ITEM_SEEDS, SeedCount);
break;
}
case E_BLOCK_CARROTS:
{
+ // https://minecraft.gamepedia.com/Carrot#Breaking
const auto CarrotCount = CalculateSeedCount(1, 4, ToolFortuneLevel(a_Tool));
- res.Add(E_ITEM_CARROT, CarrotCount);
+ Res.Add(E_ITEM_CARROT, CarrotCount);
break;
}
case E_BLOCK_POTATOES:
{
+ // https://minecraft.gamepedia.com/Potato#Breaking
const auto PotatoCount = CalculateSeedCount(2, 3, ToolFortuneLevel(a_Tool));
- res.Add(E_ITEM_POTATO, PotatoCount);
+ Res.Add(E_ITEM_POTATO, PotatoCount);
if (rand.RandBool(0.02))
{
- // With a 2% chance, drop a poisonous potato as well
- res.Add(E_ITEM_POISONOUS_POTATO);
+ // https://minecraft.gamepedia.com/Poisonous_Potato#Obtaining
+ // With a 2% chance, drop a poisonous potato as well:
+ Res.Add(E_ITEM_POISONOUS_POTATO);
}
break;
}
@@ -92,7 +97,7 @@ private:
break;
}
} // switch (m_BlockType)
- return res;
+ return Res;
}
@@ -101,16 +106,10 @@ private:
virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) const override
{
- auto oldMeta = a_Chunk.GetMeta(a_RelPos);
- if (oldMeta >= RipeMeta)
- {
- // Already ripe
- return 0;
- }
- auto newMeta = std::min<int>(oldMeta + a_NumStages, RipeMeta);
- ASSERT(newMeta > oldMeta);
- a_Chunk.GetWorld()->SetBlock(a_Chunk.RelativeToAbsolute(a_RelPos), m_BlockType, static_cast<NIBBLETYPE>(newMeta));
- return newMeta - oldMeta;
+ const auto OldMeta = a_Chunk.GetMeta(a_RelPos);
+ const auto NewMeta = std::clamp<NIBBLETYPE>(static_cast<NIBBLETYPE>(OldMeta + a_NumStages), 0, RipeMeta);
+ a_Chunk.SetMeta(a_RelPos, NewMeta);
+ return NewMeta - OldMeta;
}
@@ -131,8 +130,4 @@ private:
UNUSED(a_Meta);
return 7;
}
-} ;
-
-
-
-
+};