2013-12-18 12:33:18 -05:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2015-08-19 12:45:53 -04:00
|
|
|
#include "BlockPlant.h"
|
2014-03-30 17:13:13 -04:00
|
|
|
#include "../FastRandom.h"
|
2013-12-18 12:33:18 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-05 06:27:14 -04:00
|
|
|
class cBlockNetherWartHandler final :
|
2019-10-16 04:06:34 -04:00
|
|
|
public cBlockPlant<false>
|
2013-12-18 12:33:18 -05:00
|
|
|
{
|
2020-04-13 12:38:06 -04:00
|
|
|
using Super = cBlockPlant<false>;
|
2019-10-16 04:06:34 -04:00
|
|
|
|
2013-12-18 12:33:18 -05:00
|
|
|
public:
|
2019-10-16 04:06:34 -04:00
|
|
|
|
2020-09-20 09:50:52 -04:00
|
|
|
using Super::Super;
|
2019-10-16 04:06:34 -04:00
|
|
|
|
2020-09-20 09:50:52 -04:00
|
|
|
private:
|
2019-10-16 04:06:34 -04:00
|
|
|
|
2020-09-23 11:06:27 -04:00
|
|
|
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
2019-10-16 04:06:34 -04:00
|
|
|
{
|
|
|
|
if (a_BlockMeta == 0x03)
|
2013-12-18 12:33:18 -05:00
|
|
|
{
|
2014-03-30 17:13:13 -04:00
|
|
|
// Fully grown, drop the entire produce:
|
2020-09-28 08:41:49 -04:00
|
|
|
const auto DropNum = FortuneDiscreteRandom(2, 4, ToolFortuneLevel(a_Tool));
|
|
|
|
return cItem(E_ITEM_NETHER_WART, DropNum);
|
2013-12-18 12:33:18 -05:00
|
|
|
}
|
2020-09-28 08:41:49 -04:00
|
|
|
|
|
|
|
return cItem(E_ITEM_NETHER_WART);
|
2013-12-18 12:33:18 -05:00
|
|
|
}
|
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-09-20 09:50:52 -04:00
|
|
|
virtual int Grow(cChunk & a_Chunk, Vector3i a_RelPos, int a_NumStages = 1) const override
|
2013-12-18 12:33:18 -05:00
|
|
|
{
|
2019-10-11 05:02:53 -04:00
|
|
|
auto oldMeta = a_Chunk.GetMeta(a_RelPos);
|
|
|
|
auto meta = std::min(oldMeta + a_NumStages, 3);
|
|
|
|
if ((oldMeta < 3) && (CanGrow(a_Chunk, a_RelPos) == paGrowth))
|
2013-12-18 12:33:18 -05:00
|
|
|
{
|
2019-10-11 05:02:53 -04:00
|
|
|
a_Chunk.SetBlock(a_RelPos, m_BlockType, static_cast<NIBBLETYPE>(meta));
|
|
|
|
return meta - oldMeta;
|
2013-12-18 12:33:18 -05:00
|
|
|
}
|
2019-10-11 05:02:53 -04:00
|
|
|
|
|
|
|
// In older versions of cuberite, there was a bug which made wart grow too much. This check fixes previously saved buggy warts.
|
|
|
|
if (oldMeta > 3)
|
2015-12-13 08:49:44 -05:00
|
|
|
{
|
2019-10-11 05:02:53 -04:00
|
|
|
a_Chunk.FastSetBlock(a_RelPos, m_BlockType, 3);
|
2015-12-13 08:49:44 -05:00
|
|
|
}
|
2019-10-11 05:02:53 -04:00
|
|
|
return 0;
|
2013-12-18 12:33:18 -05:00
|
|
|
}
|
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-09-20 09:50:52 -04:00
|
|
|
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
|
2013-12-18 12:33:18 -05:00
|
|
|
{
|
2014-03-30 17:13:13 -04:00
|
|
|
// Needs to be placed on top of a Soulsand block:
|
2020-04-21 16:19:22 -04:00
|
|
|
return ((a_RelPos.y > 0) && (a_Chunk.GetBlock(a_RelPos.addedY(-1)) == E_BLOCK_SOULSAND));
|
2013-12-18 12:33:18 -05:00
|
|
|
}
|
2015-06-30 10:50:15 -04:00
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-09-20 09:50:52 -04:00
|
|
|
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
|
2015-06-30 10:50:15 -04:00
|
|
|
{
|
|
|
|
UNUSED(a_Meta);
|
|
|
|
return 35;
|
|
|
|
}
|
2014-01-31 18:17:41 -05:00
|
|
|
} ;
|