2012-12-26 20:01:16 -05:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "BlockHandler.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cBlockFlowerPotHandler :
|
|
|
|
public cBlockHandler
|
|
|
|
{
|
|
|
|
public:
|
2013-01-11 23:46:01 -05:00
|
|
|
cBlockFlowerPotHandler(BLOCKTYPE a_BlockType) :
|
|
|
|
cBlockHandler(a_BlockType)
|
2012-12-26 20:01:16 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
|
2012-12-26 20:01:16 -05:00
|
|
|
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
|
|
|
{
|
|
|
|
a_Pickups.push_back(cItem(E_ITEM_FLOWER_POT, 1, 0));
|
2013-01-11 23:46:01 -05:00
|
|
|
if (a_BlockMeta == 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2012-12-27 05:23:10 -05:00
|
|
|
cItem Plant;
|
2013-01-11 23:46:01 -05:00
|
|
|
switch (a_BlockMeta)
|
2012-12-26 20:01:16 -05:00
|
|
|
{
|
2013-02-16 06:12:56 -05:00
|
|
|
case 1: Plant = cItem(E_BLOCK_RED_ROSE, 1, 0); break;
|
|
|
|
case 2: Plant = cItem(E_BLOCK_YELLOW_FLOWER, 1, 0); break;
|
|
|
|
case 3: Plant = cItem(E_BLOCK_SAPLING, 1, E_META_SAPLING_APPLE); break;
|
|
|
|
case 4: Plant = cItem(E_BLOCK_SAPLING, 1, E_META_SAPLING_CONIFER); break;
|
|
|
|
case 5: Plant = cItem(E_BLOCK_SAPLING, 1, E_META_SAPLING_BIRCH); break;
|
|
|
|
case 6: Plant = cItem(E_BLOCK_SAPLING, 1, E_META_SAPLING_JUNGLE); break;
|
|
|
|
case 7: Plant = cItem(E_BLOCK_RED_MUSHROOM, 1, 0); break;
|
|
|
|
case 8: Plant = cItem(E_BLOCK_BROWN_MUSHROOM, 1, 0); break;
|
|
|
|
case 9: Plant = cItem(E_BLOCK_CACTUS, 1, 0); break;
|
2012-12-26 20:01:16 -05:00
|
|
|
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;
|
2013-01-11 23:46:01 -05:00
|
|
|
default: return;
|
2012-12-26 20:01:16 -05:00
|
|
|
}
|
|
|
|
a_Pickups.push_back(Plant);
|
|
|
|
}
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
|
2012-12-26 20:01:16 -05:00
|
|
|
void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
|
|
|
|
{
|
2013-01-11 23:46:01 -05:00
|
|
|
NIBBLETYPE Meta = a_World->GetBlockMeta( a_BlockX, a_BlockY, a_BlockZ );
|
|
|
|
if (Meta != 0)
|
|
|
|
{
|
|
|
|
// Already filled
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (a_Player->GetEquippedItem().m_ItemType)
|
2012-12-26 20:01:16 -05:00
|
|
|
{
|
2013-02-16 06:12:56 -05:00
|
|
|
case E_BLOCK_RED_ROSE: Meta = 1; break;
|
|
|
|
case E_BLOCK_YELLOW_FLOWER: Meta = 2; break;
|
|
|
|
case E_BLOCK_SAPLING:
|
2012-12-26 20:01:16 -05:00
|
|
|
{
|
2013-01-11 23:46:01 -05:00
|
|
|
switch (a_Player->GetEquippedItem().m_ItemDamage)
|
2012-12-26 20:01:16 -05:00
|
|
|
{
|
|
|
|
case E_META_SAPLING_APPLE: Meta = 3; break;
|
|
|
|
case E_META_SAPLING_CONIFER: Meta = 4; break;
|
|
|
|
case E_META_SAPLING_BIRCH: Meta = 5; break;
|
|
|
|
case E_META_SAPLING_JUNGLE: Meta = 6; break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2013-02-16 06:12:56 -05:00
|
|
|
case E_BLOCK_RED_MUSHROOM: Meta = 7; break;
|
|
|
|
case E_BLOCK_BROWN_MUSHROOM: Meta = 8; break;
|
|
|
|
case E_BLOCK_CACTUS: Meta = 9; break;
|
2012-12-26 20:01:16 -05:00
|
|
|
case E_BLOCK_DEAD_BUSH: Meta = 10; break;
|
|
|
|
case E_BLOCK_TALL_GRASS:
|
2013-01-11 23:46:01 -05:00
|
|
|
{
|
|
|
|
if (a_Player->GetEquippedItem().m_ItemDamage == E_META_TALL_GRASS_FERN)
|
|
|
|
{
|
|
|
|
Meta = 11;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-12-26 20:01:16 -05:00
|
|
|
}
|
2013-01-11 23:46:01 -05:00
|
|
|
|
|
|
|
if (a_Player->GetGameMode() != eGameMode_Creative)
|
2012-12-27 05:23:10 -05:00
|
|
|
{
|
|
|
|
cItem Item(a_Player->GetEquippedItem().m_ItemType, 1);
|
|
|
|
a_Player->GetInventory().RemoveItem(Item);
|
|
|
|
}
|
2013-01-11 23:46:01 -05:00
|
|
|
a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
|
2012-12-26 20:01:16 -05:00
|
|
|
}
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
|
|
|
|
virtual bool IsUseable(void) override
|
2012-12-26 20:01:16 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|