2014-09-12 16:41:23 +02:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "BlockHandler.h"
|
|
|
|
|
#include "../Items/ItemHandler.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cBlockMobSpawnerHandler :
|
|
|
|
|
public cBlockHandler
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
cBlockMobSpawnerHandler(BLOCKTYPE a_BlockType)
|
|
|
|
|
: cBlockHandler(a_BlockType)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-07-31 21:17:52 +01:00
|
|
|
virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
|
2014-09-19 23:00:54 +02:00
|
|
|
{
|
2017-07-31 21:17:52 +01:00
|
|
|
return a_ChunkInterface.UseBlockEntity(&a_Player, a_BlockX, a_BlockY, a_BlockZ);
|
2014-09-19 23:00:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual bool IsUseable() override
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-09-12 16:41:23 +02:00
|
|
|
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
|
|
|
|
{
|
|
|
|
|
// No pickups
|
|
|
|
|
}
|
2016-02-05 23:45:45 +02:00
|
|
|
|
|
|
|
|
|
2017-07-31 21:17:52 +01:00
|
|
|
virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
2014-09-12 16:41:23 +02:00
|
|
|
{
|
2017-07-31 21:17:52 +01:00
|
|
|
cItemHandler * Handler = a_Player.GetEquippedItem().GetHandler();
|
|
|
|
|
if (a_Player.IsGameModeCreative() || !Handler->CanHarvestBlock(E_BLOCK_MOB_SPAWNER))
|
2014-09-12 16:41:23 +02:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-13 20:35:30 +01:00
|
|
|
auto & Random = GetRandomProvider();
|
|
|
|
|
int Reward = 15 + Random.RandInt(14) + Random.RandInt(14);
|
2015-07-29 09:04:03 -06:00
|
|
|
a_WorldInterface.SpawnExperienceOrb(static_cast<double>(a_BlockX), static_cast<double>(a_BlockY + 1), static_cast<double>(a_BlockZ), Reward);
|
2014-09-12 16:41:23 +02:00
|
|
|
}
|
|
|
|
|
} ;
|