diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-15 21:18:11 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-15 21:18:11 +0100 |
commit | 8090c13cde2d61a0330f1e262de7526318a0965d (patch) | |
tree | 8a5f53d6113c25ee49caacea5c52548dc1585f91 /source/Blocks/BlockCactus.h | |
parent | Doxygen: Alpha-sorted class member docs (diff) | |
download | cuberite-8090c13cde2d61a0330f1e262de7526318a0965d.tar cuberite-8090c13cde2d61a0330f1e262de7526318a0965d.tar.gz cuberite-8090c13cde2d61a0330f1e262de7526318a0965d.tar.bz2 cuberite-8090c13cde2d61a0330f1e262de7526318a0965d.tar.lz cuberite-8090c13cde2d61a0330f1e262de7526318a0965d.tar.xz cuberite-8090c13cde2d61a0330f1e262de7526318a0965d.tar.zst cuberite-8090c13cde2d61a0330f1e262de7526318a0965d.zip |
Diffstat (limited to 'source/Blocks/BlockCactus.h')
-rw-r--r-- | source/Blocks/BlockCactus.h | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/source/Blocks/BlockCactus.h b/source/Blocks/BlockCactus.h index daa0e02c2..516f024d8 100644 --- a/source/Blocks/BlockCactus.h +++ b/source/Blocks/BlockCactus.h @@ -24,9 +24,13 @@ public: }
- virtual bool CanBeAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
- BLOCKTYPE Surface = a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ);
+ if (a_RelY <= 0)
+ {
+ return false;
+ }
+ BLOCKTYPE Surface = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ);
if ((Surface != E_BLOCK_SAND) && (Surface != E_BLOCK_CACTUS))
{
// Cactus can only be placed on sand and itself
@@ -34,15 +38,28 @@ public: }
// Check surroundings. Cacti may ONLY be surrounded by air
- if (
- (a_World->GetBlock(a_BlockX - 1, a_BlockY, a_BlockZ) != E_BLOCK_AIR) ||
- (a_World->GetBlock(a_BlockX + 1, a_BlockY, a_BlockZ) != E_BLOCK_AIR) ||
- (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ - 1) != E_BLOCK_AIR) ||
- (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ + 1) != E_BLOCK_AIR)
- )
+ static const struct
{
- return false;
- }
+ int x, z;
+ } Coords[] =
+ {
+ {-1, 0},
+ { 1, 0},
+ { 0, -1},
+ { 0, 1},
+ } ;
+ for (int i = 0; i < ARRAYCOUNT(Coords); i++)
+ {
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ if (
+ a_Chunk.UnboundedRelGetBlock(a_RelX + Coords[i].x, a_RelY, a_RelZ + Coords[i].z, BlockType, BlockMeta) &&
+ (BlockType != E_BLOCK_AIR)
+ )
+ {
+ return false;
+ }
+ } // for i - Coords[]
return true;
}
|