Fixed cacti and sugarcane not being placeable on themselves (FS #234, patch submitted by STR_Warrior)

git-svn-id: http://mc-server.googlecode.com/svn/trunk@723 0a769ca7-a7f5-676a-18bf-c427514a06d6
master
madmaxoft@gmail.com 2012-08-10 20:26:50 +00:00
parent 6711fcd636
commit e6ac77a2c1
2 changed files with 50 additions and 21 deletions

View File

@ -1,8 +1,13 @@
#pragma once
#include "Block.h"
class cBlockCactusHandler : public cBlockHandler
class cBlockCactusHandler :
public cBlockHandler
{
public:
cBlockCactusHandler(BLOCKTYPE a_BlockID)
@ -10,11 +15,13 @@ public:
{
}
virtual NIBBLETYPE GetDropMeta(NIBBLETYPE a_BlockMeta) override
{
return 0;
}
virtual bool CanBeAt(cWorld * a_World, int a_X, int a_Y, int a_Z) override
{
BLOCKTYPE Surface = a_World->GetBlock(a_X, a_Y - 1, a_Z);
@ -38,14 +45,13 @@ public:
return true;
}
virtual bool AllowBlockOnTop() override
{
return false;
}
virtual bool CanBePlacedOnSide() override
{
return false;
}
};

View File

@ -1,9 +1,13 @@
#pragma once
#include "Block.h"
#include "../MersenneTwister.h"
#include "../cWorld.h"
class cBlockSugarcaneHandler : public cBlockHandler
class cBlockSugarcaneHandler :
public cBlockHandler
{
public:
cBlockSugarcaneHandler(BLOCKTYPE a_BlockID)
@ -11,33 +15,52 @@ public:
{
}
virtual bool NeedsRandomTicks() override
{
return true;
}
virtual int GetDropID() override
{
return E_ITEM_SUGARCANE;
}
virtual bool CanBeAt(cWorld * a_World, int a_X, int a_Y, int a_Z) override
{
BLOCKTYPE Block = a_World->GetBlock(a_X, a_Y-1, a_Z);
if(!IsBlockTypeOfDirt(Block) && Block != E_BLOCK_SAND && Block != E_BLOCK_SUGARCANE)
return false;
switch (a_World->GetBlock(a_X, a_Y - 1, a_Z))
{
case E_BLOCK_DIRT:
case E_BLOCK_GRASS:
case E_BLOCK_FARMLAND:
case E_BLOCK_SAND:
{
return a_World->IsBlockDirectlyWatered(a_X, a_Y - 1, a_Z);
}
case E_BLOCK_SUGARCANE:
{
return true;
}
}
return false;
}
void OnUpdate(cWorld * a_World, int a_X, int a_Y, int a_Z) override
{
//TODO: Handle Growing here
}
virtual bool CanBePlacedOnSide() override
{
return false;
}
};