2013-12-18 12:33:18 -05:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "BlockHandler.h"
|
2014-03-30 17:13:13 -04:00
|
|
|
#include "../FastRandom.h"
|
2013-12-18 12:33:18 -05:00
|
|
|
#include "../World.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cBlockNetherWartHandler :
|
|
|
|
public cBlockHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cBlockNetherWartHandler(BLOCKTYPE a_BlockType)
|
|
|
|
: cBlockHandler(a_BlockType)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_Meta) override
|
|
|
|
{
|
2014-03-30 17:13:13 -04:00
|
|
|
cFastRandom rand;
|
2013-12-18 12:33:18 -05:00
|
|
|
|
|
|
|
if (a_Meta == 0x7)
|
|
|
|
{
|
2014-03-30 17:13:13 -04:00
|
|
|
// Fully grown, drop the entire produce:
|
|
|
|
a_Pickups.push_back(cItem(E_ITEM_NETHER_WART, (char)(1 + (rand.NextInt(3) + rand.NextInt(3))) / 2, 0));
|
2013-12-18 12:33:18 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
a_Pickups.push_back(cItem(E_ITEM_NETHER_WART));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-30 17:13:13 -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);
|
2013-12-18 12:33:18 -05:00
|
|
|
if (Meta < 7)
|
|
|
|
{
|
|
|
|
a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_NETHER_WART, ++Meta);
|
|
|
|
}
|
|
|
|
}
|
2014-03-30 17:13:13 -04:00
|
|
|
|
2013-12-18 12:33:18 -05: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));
|
|
|
|
}
|
2014-01-31 18:17:41 -05:00
|
|
|
} ;
|