2012-10-18 05:36:30 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ItemHandler.h"
|
|
|
|
#include "../World.h"
|
|
|
|
#include "../Player.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cItemSpawnEggHandler : public cItemHandler
|
|
|
|
{
|
|
|
|
public:
|
2012-10-18 15:41:29 -04:00
|
|
|
cItemSpawnEggHandler(int a_ItemType) :
|
|
|
|
cItemHandler(a_ItemType)
|
2012-10-18 05:36:30 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, cItem * a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) override
|
2012-10-18 05:36:30 -04:00
|
|
|
{
|
2013-01-11 23:46:01 -05:00
|
|
|
if (a_BlockFace < 0)
|
2012-10-18 05:36:30 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
|
2012-10-18 05:36:30 -04:00
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
if (a_BlockFace == BLOCK_FACE_BOTTOM)
|
2012-10-18 05:36:30 -04:00
|
|
|
{
|
2012-10-18 15:41:29 -04:00
|
|
|
a_BlockY--;
|
2012-10-18 05:36:30 -04:00
|
|
|
}
|
|
|
|
|
2012-10-28 10:57:35 -04:00
|
|
|
if (a_World->SpawnMob(a_BlockX + 0.5, a_BlockY, a_BlockZ + 0.5, a_Item->m_ItemDamage) >= 0)
|
2012-10-19 14:30:46 -04:00
|
|
|
{
|
2013-01-11 23:46:01 -05:00
|
|
|
if (a_Player->GetGameMode() != 1)
|
2012-11-24 04:50:38 -05:00
|
|
|
{
|
|
|
|
// The mob was spawned, "use" the item:
|
|
|
|
a_Player->GetInventory().RemoveItem(a_Player->GetInventory().GetEquippedItem());
|
|
|
|
}
|
2012-10-28 10:57:35 -04:00
|
|
|
return true;
|
2012-10-19 14:30:46 -04:00
|
|
|
}
|
2012-10-28 10:57:35 -04:00
|
|
|
|
|
|
|
return false;
|
2012-10-18 05:36:30 -04:00
|
|
|
}
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|