2012-07-15 16:36:34 -04:00
|
|
|
#pragma once
|
|
|
|
#include "Block.h"
|
|
|
|
#include "../cWorld.h"
|
|
|
|
|
|
|
|
class cBlockSaplingHandler : public cBlockHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cBlockSaplingHandler(BLOCKTYPE a_BlockID)
|
|
|
|
: cBlockHandler(a_BlockID)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool NeedsRandomTicks() override
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-16 15:20:37 -04:00
|
|
|
virtual NIBBLETYPE GetDropMeta(NIBBLETYPE a_BlockMeta) override
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
return a_BlockMeta & 3; //Only the first 2 bits contain the display information the others are for growing
|
|
|
|
}
|
|
|
|
|
2012-07-16 15:20:37 -04:00
|
|
|
virtual bool CanBeAt(cWorld *a_World, int a_X, int a_Y, int a_Z) override
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
return IsBlockTypeOfDirt(a_World->GetBlock(a_X, a_Y - 1, a_Z));
|
|
|
|
}
|
|
|
|
|
2012-07-16 15:20:37 -04:00
|
|
|
virtual bool AllowBlockOnTop() override
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-07-16 15:20:37 -04:00
|
|
|
void OnUpdate(cWorld *a_World, int a_X, int a_Y, int a_Z) override
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
NIBBLETYPE Meta = a_World->GetBlockMeta(a_X, a_Y, a_Z);
|
|
|
|
|
|
|
|
if ((Meta & 0x08) != 0)
|
|
|
|
{
|
|
|
|
a_World->GrowTree(a_X, a_Y, a_Z);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
a_World->SetBlockMeta(a_X, a_Y, a_Z, Meta | 0x08);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-16 15:20:37 -04:00
|
|
|
virtual bool CanBePlacedOnSide() override
|
2012-07-15 16:36:34 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|