diff options
Diffstat (limited to '')
-rw-r--r-- | source/Blocks/BlockFlowerPot.h | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/source/Blocks/BlockFlowerPot.h b/source/Blocks/BlockFlowerPot.h index 36f4389c3..ba93430f8 100644 --- a/source/Blocks/BlockFlowerPot.h +++ b/source/Blocks/BlockFlowerPot.h @@ -11,17 +11,21 @@ class cBlockFlowerPotHandler : public cBlockHandler
{
public:
- cBlockFlowerPotHandler(BLOCKTYPE a_BlockType)
- : cBlockHandler(a_BlockType)
+ cBlockFlowerPotHandler(BLOCKTYPE a_BlockType) :
+ cBlockHandler(a_BlockType)
{
}
+
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.push_back(cItem(E_ITEM_FLOWER_POT, 1, 0));
- if( a_BlockMeta == 0 ) return;
+ if (a_BlockMeta == 0)
+ {
+ return;
+ }
cItem Plant;
- switch( a_BlockMeta )
+ switch (a_BlockMeta)
{
case 1: Plant = cItem(E_ITEM_RED_ROSE, 1, 0); break;
case 2: Plant = cItem(E_ITEM_YELLOW_FLOWER, 1, 0); break;
@@ -34,21 +38,28 @@ public: case 9: Plant = cItem(E_ITEM_CACTUS, 1, 0); break;
case 10: Plant = cItem(E_BLOCK_DEAD_BUSH, 1, 0); break;
case 11: Plant = cItem(E_BLOCK_TALL_GRASS, 1, E_META_TALL_GRASS_FERN); break;
+ default: return;
}
a_Pickups.push_back(Plant);
}
+
void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
{
- char Meta = a_World->GetBlockMeta( a_BlockX, a_BlockY, a_BlockZ );
- if( Meta ) return;
- switch( a_Player->GetEquippedItem().m_ItemType )
+ NIBBLETYPE Meta = a_World->GetBlockMeta( a_BlockX, a_BlockY, a_BlockZ );
+ if (Meta != 0)
+ {
+ // Already filled
+ return;
+ }
+
+ switch (a_Player->GetEquippedItem().m_ItemType)
{
case E_ITEM_RED_ROSE: Meta = 1; break;
case E_ITEM_YELLOW_FLOWER: Meta = 2; break;
case E_ITEM_SAPLING:
{
- switch( a_Player->GetEquippedItem().m_ItemDamage )
+ switch (a_Player->GetEquippedItem().m_ItemDamage)
{
case E_META_SAPLING_APPLE: Meta = 3; break;
case E_META_SAPLING_CONIFER: Meta = 4; break;
@@ -62,17 +73,29 @@ public: case E_ITEM_CACTUS: Meta = 9; break;
case E_BLOCK_DEAD_BUSH: Meta = 10; break;
case E_BLOCK_TALL_GRASS:
- if( a_Player->GetEquippedItem().m_ItemDamage == E_META_TALL_GRASS_FERN ) Meta = 11; break;
+ {
+ if (a_Player->GetEquippedItem().m_ItemDamage == E_META_TALL_GRASS_FERN)
+ {
+ Meta = 11;
+ }
+ else
+ {
+ return;
+ }
+ break;
+ }
}
- if(a_Player->GetGameMode() != eGameMode_Creative)
+
+ if (a_Player->GetGameMode() != eGameMode_Creative)
{
cItem Item(a_Player->GetEquippedItem().m_ItemType, 1);
a_Player->GetInventory().RemoveItem(Item);
}
- a_World->SetBlockMeta( a_BlockX, a_BlockY, a_BlockZ, Meta );
+ a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
}
- virtual bool IsUseable() override
+
+ virtual bool IsUseable(void) override
{
return true;
}
|