1
0

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
This commit is contained in:
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 #pragma once
#include "Block.h" #include "Block.h"
class cBlockCactusHandler : public cBlockHandler
class cBlockCactusHandler :
public cBlockHandler
{ {
public: public:
cBlockCactusHandler(BLOCKTYPE a_BlockID) cBlockCactusHandler(BLOCKTYPE a_BlockID)
@ -10,12 +15,14 @@ public:
{ {
} }
virtual NIBBLETYPE GetDropMeta(NIBBLETYPE a_BlockMeta) override virtual NIBBLETYPE GetDropMeta(NIBBLETYPE a_BlockMeta) override
{ {
return 0; return 0;
} }
virtual bool CanBeAt(cWorld *a_World, int a_X, int a_Y, int a_Z) override
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); BLOCKTYPE Surface = a_World->GetBlock(a_X, a_Y - 1, a_Z);
if ((Surface != E_BLOCK_SAND) && (Surface != E_BLOCK_CACTUS)) if ((Surface != E_BLOCK_SAND) && (Surface != E_BLOCK_CACTUS))
@ -34,13 +41,8 @@ public:
{ {
return false; return false;
} }
return true;
}
virtual bool AllowBlockOnTop() override return true;
{
return false;
} }
@ -48,4 +50,8 @@ public:
{ {
return false; return false;
} }
}; };

View File

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