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

82 lines
1.4 KiB
C
Raw Normal View History

#pragma once
#include "BlockHandler.h"
class cBlockDeadBushHandler final :
public cBlockHandler
{
2020-04-13 12:38:06 -04:00
using Super = cBlockHandler;
public:
2020-04-13 12:38:06 -04:00
using Super::Super;
2020-04-13 12:38:06 -04:00
private:
2020-04-13 12:38:06 -04:00
virtual bool DoesIgnoreBuildCollision(const cWorld & a_World, const cItem & a_HeldItem, const Vector3i a_Position, const NIBBLETYPE a_Meta, const eBlockFace a_ClickedBlockFace, const bool a_ClickedDirectly) const override
{
return true;
}
2020-04-13 12:38:06 -04:00
virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override
{
if (a_Position.y <= 0)
{
return false;
}
BLOCKTYPE BelowBlock = a_Chunk.GetBlock(a_Position.addedY(-1));
switch (BelowBlock)
{
case E_BLOCK_CLAY:
case E_BLOCK_HARDENED_CLAY:
case E_BLOCK_STAINED_CLAY:
case E_BLOCK_SAND:
{
return true;
}
default: return false;
}
}
2015-06-30 10:50:15 -04:00
2017-02-26 05:09:06 -05:00
virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override
2017-02-26 05:09:06 -05:00
{
// If cutting down with shears, drop self:
if ((a_Tool != nullptr) && (a_Tool->m_ItemType == E_ITEM_SHEARS))
2017-02-26 05:09:06 -05:00
{
return cItem(m_BlockType, 1, a_BlockMeta);
}
2017-02-26 05:09:06 -05:00
// Drop 0-3 sticks:
auto chance = GetRandomProvider().RandInt<char>(3);
if (chance > 0)
{
return cItem(E_ITEM_STICK, chance, 0);
}
return {};
}
2017-02-26 05:09:06 -05:00
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
{
UNUSED(a_Meta);
return 0;
2017-02-26 05:09:06 -05:00
}
} ;