2012-09-23 18:09:57 -04:00
|
|
|
|
2012-07-15 16:36:34 -04:00
|
|
|
#pragma once
|
2012-09-23 18:09:57 -04:00
|
|
|
|
|
|
|
#include "ItemHandler.h"
|
|
|
|
#include "../World.h"
|
|
|
|
#include "../Player.h"
|
2012-07-15 16:36:34 -04:00
|
|
|
|
2012-10-03 04:52:11 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cItemDyeHandler :
|
|
|
|
public cItemHandler
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
public:
|
2012-10-18 15:41:29 -04:00
|
|
|
cItemDyeHandler(int a_ItemType)
|
|
|
|
: cItemHandler(a_ItemType)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-10-18 15:41:29 -04:00
|
|
|
virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, cItem * a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
// TODO: Handle coloring the sheep, too (OnItemUseOnEntity maybe)
|
|
|
|
// Handle growing the plants:
|
2013-01-11 23:46:01 -05:00
|
|
|
if (a_Item->m_ItemDamage == E_META_DYE_WHITE)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2012-10-18 15:41:29 -04:00
|
|
|
if (a_World->GrowRipePlant(a_BlockX, a_BlockY, a_BlockZ, true))
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2012-10-18 15:41:29 -04:00
|
|
|
if (a_Player->GetGameMode() != eGameMode_Creative)
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
2013-01-11 23:46:01 -05:00
|
|
|
cItem Item(a_Item->m_ItemType, 1, a_Item->m_ItemDamage);
|
2012-07-17 10:33:51 -04:00
|
|
|
a_Player->GetInventory().RemoveItem(Item);
|
2012-07-15 16:36:34 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2012-10-03 04:52:11 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|