1
0
cuberite-2a/src/Blocks/BlockTallGrass.h

81 lines
1.2 KiB
C
Raw Normal View History

#pragma once
#include "BlockHandler.h"
2014-10-21 16:06:44 +00:00
#include "ChunkInterface.h"
class cBlockTallGrassHandler:
public cBlockHandler
{
using super = cBlockHandler;
public:
cBlockTallGrassHandler(BLOCKTYPE a_BlockType):
super(a_BlockType)
{
}
virtual bool DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) override
{
return true;
}
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override
{
// If using shears, drop self:
if ((a_Tool != nullptr) && (a_Tool->m_ItemType == E_ITEM_SHEARS))
{
return cItem(m_BlockType, 1, a_BlockMeta);
}
// Drop seeds, sometimes:
if (GetRandomProvider().RandBool(0.125))
2014-10-21 16:06:44 +00:00
{
return cItem(E_ITEM_SEEDS);
2014-10-21 16:06:44 +00:00
}
return {};
2014-10-21 16:06:44 +00:00
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
if (a_RelY <= 0)
{
return false;
}
BLOCKTYPE BelowBlock = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ);
return IsBlockTypeOfDirt(BelowBlock);
}
2015-06-30 14:50:15 +00:00
2015-06-30 14:50:15 +00:00
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 7;
}
} ;