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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cBlockNetherWartHandler :
|
2019-10-16 04:06:34 -04:00
|
|
|
public cBlockPlant<false>
|
2013-12-18 12:33:18 -05:00
|
|
|
{
|
2019-10-16 04:06:34 -04:00
|
|
|
using super = cBlockPlant<false>;
|
|
|
|
|
2013-12-18 12:33:18 -05:00
|
|
|
public:
|
2019-10-16 04:06:34 -04:00
|
|
|
|
|
|
|
cBlockNetherWartHandler(BLOCKTYPE a_BlockType):
|
|
|
|
super(a_BlockType)
|
2013-12-18 12:33:18 -05:00
|
|
|
{
|
|
|
|
}
|
2015-12-13 08:49:44 -05:00
|
|
|
|
2013-12-18 12:33:18 -05:00
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override
|
|
|
|
{
|
|
|
|
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:
|
2019-10-16 04:06:34 -04:00
|
|
|
auto & rand = GetRandomProvider();
|
|
|
|
return cItem(E_ITEM_NETHER_WART, 1 + (rand.RandInt<char>(2) + rand.RandInt<char>(2)) / 2, 0);
|
2013-12-18 12:33:18 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-16 04:06:34 -04:00
|
|
|
return cItem(E_ITEM_NETHER_WART);
|
2013-12-18 12:33:18 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-02 09:49:37 -05:00
|
|
|
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
|
2013-12-18 12:33:18 -05:00
|
|
|
{
|
2014-03-30 17:13:13 -04:00
|
|
|
NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
|
2015-12-11 18:46:01 -05:00
|
|
|
if ((Meta < 3) && (CanGrow(a_Chunk, a_RelX, a_RelY, a_RelZ) == paGrowth))
|
2013-12-18 12:33:18 -05:00
|
|
|
{
|
|
|
|
a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_NETHER_WART, ++Meta);
|
|
|
|
}
|
2015-12-13 08:49:44 -05:00
|
|
|
else if (Meta > 3) // In older versions of cuberite, there was a bug which made wart grow too much. This check fixes previously saved buggy warts.
|
|
|
|
{
|
|
|
|
a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_NETHER_WART, 3);
|
|
|
|
}
|
2013-12-18 12:33:18 -05:00
|
|
|
}
|
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-01 08:06:32 -05:00
|
|
|
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) 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:
|
2013-12-18 12:33:18 -05:00
|
|
|
return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) == E_BLOCK_SOULSAND));
|
|
|
|
}
|
2015-06-30 10:50:15 -04:00
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-06-30 10:50:15 -04:00
|
|
|
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
|
|
|
|
{
|
|
|
|
UNUSED(a_Meta);
|
|
|
|
return 35;
|
|
|
|
}
|
2014-01-31 18:17:41 -05:00
|
|
|
} ;
|