2012-10-18 02:36:30 -07:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ItemHandler.h"
|
|
|
|
#include "../World.h"
|
|
|
|
#include "../Player.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cItemSpawnEggHandler : public cItemHandler
|
|
|
|
{
|
|
|
|
public:
|
2012-10-18 12:41:29 -07:00
|
|
|
cItemSpawnEggHandler(int a_ItemType) :
|
|
|
|
cItemHandler(a_ItemType)
|
2012-10-18 02:36:30 -07:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-11 20:46:01 -08: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 02:36:30 -07:00
|
|
|
{
|
2013-01-11 20:46:01 -08:00
|
|
|
if (a_BlockFace < 0)
|
2012-10-18 02:36:30 -07:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-01-11 20:46:01 -08:00
|
|
|
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
|
2012-10-18 02:36:30 -07:00
|
|
|
|
2013-01-11 20:46:01 -08:00
|
|
|
if (a_BlockFace == BLOCK_FACE_BOTTOM)
|
2012-10-18 02:36:30 -07:00
|
|
|
{
|
2012-10-18 12:41:29 -07:00
|
|
|
a_BlockY--;
|
2012-10-18 02:36:30 -07:00
|
|
|
}
|
|
|
|
|
2012-10-28 07:57:35 -07:00
|
|
|
if (a_World->SpawnMob(a_BlockX + 0.5, a_BlockY, a_BlockZ + 0.5, a_Item->m_ItemDamage) >= 0)
|
2012-10-19 11:30:46 -07:00
|
|
|
{
|
2013-01-11 20:46:01 -08:00
|
|
|
if (a_Player->GetGameMode() != 1)
|
2012-11-24 01:50:38 -08:00
|
|
|
{
|
|
|
|
// The mob was spawned, "use" the item:
|
|
|
|
a_Player->GetInventory().RemoveItem(a_Player->GetInventory().GetEquippedItem());
|
|
|
|
}
|
2012-10-28 07:57:35 -07:00
|
|
|
return true;
|
2012-10-19 11:30:46 -07:00
|
|
|
}
|
2012-10-28 07:57:35 -07:00
|
|
|
|
|
|
|
return false;
|
2012-10-18 02:36:30 -07:00
|
|
|
}
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|