summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2017-07-18 15:14:52 +0200
committerLukas Pioch <lukas@zgow.de>2017-07-18 15:14:52 +0200
commitf9b56dd859b97dd9af5f2a0c7050270d7a44b525 (patch)
treeafc54f07237b6cb1cfab0624bd61c80f2a029fc5 /src
parentMade cBlockHandler OnPlacedByPlayer call OnPlaced, made BlockRailHandler use NeighborChanged instead of OnNeighborChanged. (diff)
downloadcuberite-f9b56dd859b97dd9af5f2a0c7050270d7a44b525.tar
cuberite-f9b56dd859b97dd9af5f2a0c7050270d7a44b525.tar.gz
cuberite-f9b56dd859b97dd9af5f2a0c7050270d7a44b525.tar.bz2
cuberite-f9b56dd859b97dd9af5f2a0c7050270d7a44b525.tar.lz
cuberite-f9b56dd859b97dd9af5f2a0c7050270d7a44b525.tar.xz
cuberite-f9b56dd859b97dd9af5f2a0c7050270d7a44b525.tar.zst
cuberite-f9b56dd859b97dd9af5f2a0c7050270d7a44b525.zip
Diffstat (limited to 'src')
-rw-r--r--src/Blocks/BlockCactus.h8
-rw-r--r--src/Chunk.cpp35
2 files changed, 37 insertions, 6 deletions
diff --git a/src/Blocks/BlockCactus.h b/src/Blocks/BlockCactus.h
index 29e86d085..371402423 100644
--- a/src/Blocks/BlockCactus.h
+++ b/src/Blocks/BlockCactus.h
@@ -36,7 +36,7 @@ public:
return false;
}
- // Check surroundings. Cacti may ONLY be surrounded by air
+ // Check surroundings. Cacti may ONLY be surrounded by non-solid blocks
static const struct
{
int x, z;
@@ -53,7 +53,11 @@ public:
NIBBLETYPE BlockMeta;
if (
a_Chunk.UnboundedRelGetBlock(a_RelX + Coords[i].x, a_RelY, a_RelZ + Coords[i].z, BlockType, BlockMeta) &&
- cBlockInfo::IsSolid(BlockType)
+ (
+ cBlockInfo::IsSolid(BlockType) ||
+ (BlockType == E_BLOCK_LAVA) ||
+ (BlockType == E_BLOCK_STATIONARY_LAVA)
+ )
)
{
return false;
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index 282293c0f..3b9739907 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -1118,7 +1118,7 @@ int cChunk::GrowSugarcane(int a_RelX, int a_RelY, int a_RelZ, int a_NumBlocks)
int cChunk::GrowCactus(int a_RelX, int a_RelY, int a_RelZ, int a_NumBlocks)
{
- // Check the total height of the sugarcane blocks here:
+ // Check the total height of the cacti blocks here:
int Top = a_RelY + 1;
while (
(Top < cChunkDef::Height) &&
@@ -1141,11 +1141,38 @@ int cChunk::GrowCactus(int a_RelX, int a_RelY, int a_RelZ, int a_NumBlocks)
for (int i = 0; i < ToGrow; i++)
{
BLOCKTYPE BlockType;
- NIBBLETYPE BlockMeta;
- if (UnboundedRelGetBlock(a_RelX, Top + i, a_RelZ, BlockType, BlockMeta) && (BlockType == E_BLOCK_AIR))
+ if (UnboundedRelGetBlockType(a_RelX, Top + i, a_RelZ, BlockType) && (BlockType == E_BLOCK_AIR))
{
- // TODO: Check the surrounding blocks, if they aren't air, break the cactus block into pickups (and continue breaking blocks above in the next loop iterations)
UnboundedRelFastSetBlock(a_RelX, Top + i, a_RelZ, E_BLOCK_CACTUS, 0);
+
+ // Check surroundings. Cacti may ONLY be surrounded by non-solid blocks
+ static const struct
+ {
+ int x, z;
+ } Coords[] =
+ {
+ {-1, 0},
+ { 1, 0},
+ { 0, -1},
+ { 0, 1},
+ } ;
+ for (auto & Coord : Coords)
+ {
+ if (
+ UnboundedRelGetBlockType(a_RelX + Coord.x, Top + 1, a_RelZ + Coord.z, BlockType) &&
+ (
+ cBlockInfo::IsSolid(BlockType) ||
+ (BlockType == E_BLOCK_LAVA) ||
+ (BlockType == E_BLOCK_STATIONARY_LAVA)
+ )
+ )
+ {
+ return false;
+ }
+ } // for i - Coords[]
+ {
+ GetWorld()->DigBlock(a_RelX + GetPosX() * cChunkDef::Width, Top + i, a_RelZ + GetPosZ() * cChunkDef::Width);
+ }
}
else
{