summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockStems.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Blocks/BlockStems.h')
-rw-r--r--src/Blocks/BlockStems.h99
1 files changed, 37 insertions, 62 deletions
diff --git a/src/Blocks/BlockStems.h b/src/Blocks/BlockStems.h
index 11cd83967..bf5a9fbf0 100644
--- a/src/Blocks/BlockStems.h
+++ b/src/Blocks/BlockStems.h
@@ -11,17 +11,14 @@
ProduceBlockType is the blocktype for the produce to be grown.
StemPickupType is the item type for the pickup resulting from breaking the stem. */
template <BLOCKTYPE ProduceBlockType, ENUM_ITEM_TYPE StemPickupType>
-class cBlockStemsHandler final :
- public cBlockPlant<true>
+class cBlockStemsHandler final : public cBlockPlant<true>
{
using Super = cBlockPlant<true>;
-public:
-
+ public:
using Super::Super;
-private:
-
+ private:
virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override
{
/*
@@ -92,27 +89,20 @@ private:
auto & Random = GetRandomProvider();
// Check if there's another produce around the stem, if so, abort:
- static constexpr std::array<Vector3i, 4> NeighborOfs =
- {
- {
- { 1, 0, 0},
- {-1, 0, 0},
- { 0, 0, 1},
- { 0, 0, -1},
- }
- };
+ static constexpr std::array<Vector3i, 4> NeighborOfs = {{
+ {1, 0, 0},
+ {-1, 0, 0},
+ {0, 0, 1},
+ {0, 0, -1},
+ }};
std::array<BLOCKTYPE, 4> BlockType;
- if (
- !a_Chunk.UnboundedRelGetBlockType(a_StemRelPos + NeighborOfs[0], BlockType[0]) ||
+ if (!a_Chunk.UnboundedRelGetBlockType(a_StemRelPos + NeighborOfs[0], BlockType[0]) ||
!a_Chunk.UnboundedRelGetBlockType(a_StemRelPos + NeighborOfs[1], BlockType[1]) ||
!a_Chunk.UnboundedRelGetBlockType(a_StemRelPos + NeighborOfs[2], BlockType[2]) ||
!a_Chunk.UnboundedRelGetBlockType(a_StemRelPos + NeighborOfs[3], BlockType[3]) ||
- (BlockType[0] == ProduceBlockType) ||
- (BlockType[1] == ProduceBlockType) ||
- (BlockType[2] == ProduceBlockType) ||
- (BlockType[3] == ProduceBlockType)
- )
+ (BlockType[0] == ProduceBlockType) || (BlockType[1] == ProduceBlockType) ||
+ (BlockType[2] == ProduceBlockType) || (BlockType[3] == ProduceBlockType))
{
// Neighbors not valid or already taken by the same produce:
return;
@@ -120,12 +110,13 @@ private:
// Pick a direction in which to place the produce:
int x = 0, z = 0;
- const auto CheckType = Random.RandInt<size_t>(3); // The index to the neighbors array which should be checked for emptiness
+ const auto CheckType =
+ Random.RandInt<size_t>(3); // The index to the neighbors array which should be checked for emptiness
switch (CheckType)
{
- case 0: x = 1; break;
+ case 0: x = 1; break;
case 1: x = -1; break;
- case 2: z = 1; break;
+ case 2: z = 1; break;
case 3: z = -1; break;
}
@@ -153,11 +144,15 @@ private:
case E_BLOCK_GRASS:
case E_BLOCK_FARMLAND:
{
- const NIBBLETYPE Meta = (ProduceBlockType == E_BLOCK_MELON) ? 0 : static_cast<NIBBLETYPE>(Random.RandInt(4) % 4);
+ const NIBBLETYPE Meta =
+ (ProduceBlockType == E_BLOCK_MELON) ? 0 : static_cast<NIBBLETYPE>(Random.RandInt(4) % 4);
- FLOGD("Growing melon / pumpkin at {0} (<{1}, {2}> from stem), overwriting {3}, growing on top of {4}, meta {5}",
+ FLOGD(
+ "Growing melon / pumpkin at {0} (<{1}, {2}> from stem), overwriting {3}, growing on top of {4}, "
+ "meta {5}",
a_Chunk.RelativeToAbsolute(ProduceRelPos),
- x, z,
+ x,
+ z,
ItemTypeToString(BlockType[CheckType]),
ItemTypeToString(SoilType),
Meta
@@ -169,42 +164,22 @@ private:
}
}
-private:
-
+ private:
// https://minecraft.wiki/w/Pumpkin_Seeds#Breaking
// https://minecraft.wiki/w/Melon_Seeds#Breaking
- /** The array describes how many seed may be dropped at which age. The inner arrays describe the probability to drop 0, 1, 2, 3 seeds.
- The outer describes the age of the stem. */
- static constexpr std::array<std::array<double, 4>, 8> m_AgeSeedDropProbability
- {
- {
- {
- 81.3, 17.42, 1.24, 0.03
- },
- {
- 65.1, 30.04, 4.62, 0.24
- },
- {
- 51.2, 38.4, 9.6, 0.8
- },
- {
- 39.44, 43.02, 15.64, 1.9
- },
- {
- 29.13, 44.44, 22.22, 3.7
- },
- {
- 21.6, 43.2, 28.8, 6.4
- },
- {
- 15.17, 39.82, 34.84, 10.16
- },
- {
- 10.16, 34.84, 39.82, 15.17
- }
- }
+ /** The array describes how many seed may be dropped at which age. The inner arrays describe the probability to drop
+ 0, 1, 2, 3 seeds. The outer describes the age of the stem. */
+ static constexpr std::array<std::array<double, 4>, 8> m_AgeSeedDropProbability {
+ {{81.3, 17.42, 1.24, 0.03},
+ {65.1, 30.04, 4.62, 0.24},
+ {51.2, 38.4, 9.6, 0.8},
+ {39.44, 43.02, 15.64, 1.9},
+ {29.13, 44.44, 22.22, 3.7},
+ {21.6, 43.2, 28.8, 6.4},
+ {15.17, 39.82, 34.84, 10.16},
+ {10.16, 34.84, 39.82, 15.17}}
};
-} ;
+};
-using cBlockMelonStemHandler = cBlockStemsHandler<E_BLOCK_MELON, E_ITEM_MELON_SEEDS>;
+using cBlockMelonStemHandler = cBlockStemsHandler<E_BLOCK_MELON, E_ITEM_MELON_SEEDS>;
using cBlockPumpkinStemHandler = cBlockStemsHandler<E_BLOCK_PUMPKIN, E_ITEM_PUMPKIN_SEEDS>;