summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockLever.h36
-rw-r--r--src/Blocks/BlockRedstone.h27
-rw-r--r--src/Blocks/BlockRedstoneRepeater.h25
-rw-r--r--src/Blocks/BlockSlab.h1
-rw-r--r--src/Chunk.cpp2
-rw-r--r--src/Chunk.h2
6 files changed, 81 insertions, 12 deletions
diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h
index 3b63b396c..f5bedea6c 100644
--- a/src/Blocks/BlockLever.h
+++ b/src/Blocks/BlockLever.h
@@ -1,9 +1,9 @@
#pragma once
#include "BlockHandler.h"
+#include "../Chunk.h"
#include "MetaRotator.h"
-
-
+#include "BlockSlab.h"
class cBlockLeverHandler :
@@ -93,13 +93,35 @@ public:
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
- NIBBLETYPE Meta;
- a_Chunk.UnboundedRelGetBlockMeta(a_RelX, a_RelY, a_RelZ, Meta);
+ NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
+
+ eBlockFace Face = BlockMetaDataToBlockFace(Meta);
+
+ AddFaceDirection(a_RelX, a_RelY, a_RelZ, Face, true);
+
+ if ((a_RelY < 0) || (a_RelY >= cChunkDef::Height -1))
+ {
+ return false;
+ }
+
+ BLOCKTYPE BlockIsOn;
+ a_Chunk.UnboundedRelGetBlock(a_RelX, a_RelY, a_RelZ, BlockIsOn, Meta);
- AddFaceDirection(a_RelX, a_RelY, a_RelZ, BlockMetaDataToBlockFace(Meta), true);
- BLOCKTYPE BlockIsOn; a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, BlockIsOn);
- return (a_RelY > 0) && cBlockInfo::FullyOccupiesVoxel(BlockIsOn);
+ if (cBlockInfo::FullyOccupiesVoxel(BlockIsOn))
+ {
+ return true;
+ }
+ else if (cBlockSlabHandler::IsAnySlabType(BlockIsOn))
+ {
+ // Check if the slab is turned up side down
+ if (((Meta & 0x08) == 0x08) && (Face == BLOCK_FACE_TOP))
+ {
+ return true;
+ }
+ }
+
+ return false;
}
diff --git a/src/Blocks/BlockRedstone.h b/src/Blocks/BlockRedstone.h
index 37d61ed73..2785eb479 100644
--- a/src/Blocks/BlockRedstone.h
+++ b/src/Blocks/BlockRedstone.h
@@ -3,6 +3,7 @@
#include "BlockHandler.h"
#include "../World.h"
+#include "BlockSlab.h"
@@ -16,11 +17,33 @@ public:
: cBlockHandler(a_BlockType)
{
}
-
+
+
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
- return ((a_RelY > 0) && cBlockInfo::FullyOccupiesVoxel(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)));
+ if (a_RelY <= 0)
+ {
+ return false;
+ }
+
+ BLOCKTYPE BelowBlock;
+ NIBBLETYPE BelowBlockMeta;
+ a_Chunk.GetBlockTypeMeta(a_RelX, a_RelY - 1, a_RelZ, BelowBlock, BelowBlockMeta);
+
+ if (cBlockInfo::FullyOccupiesVoxel(BelowBlock))
+ {
+ return true;
+ }
+ else if (cBlockSlabHandler::IsAnySlabType(BelowBlock))
+ {
+ // Check if the slab is turned up side down
+ if ((BelowBlockMeta & 0x08) == 0x08)
+ {
+ return true;
+ }
+ }
+ return false;
}
diff --git a/src/Blocks/BlockRedstoneRepeater.h b/src/Blocks/BlockRedstoneRepeater.h
index 1eb67f714..e8262dc40 100644
--- a/src/Blocks/BlockRedstoneRepeater.h
+++ b/src/Blocks/BlockRedstoneRepeater.h
@@ -5,6 +5,7 @@
#include "Chunk.h"
#include "MetaRotator.h"
#include "ChunkInterface.h"
+#include "BlockSlab.h"
@@ -44,6 +45,7 @@ public:
}
+
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Reset meta to zero
@@ -59,7 +61,28 @@ public:
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
- return ((a_RelY > 0) && cBlockInfo::IsSolid(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)));
+ if (a_RelY <= 0)
+ {
+ return false;
+ }
+
+ BLOCKTYPE BelowBlock;
+ NIBBLETYPE BelowBlockMeta;
+ a_Chunk.GetBlockTypeMeta(a_RelX, a_RelY - 1, a_RelZ, BelowBlock, BelowBlockMeta);
+
+ if (cBlockInfo::FullyOccupiesVoxel(BelowBlock))
+ {
+ return true;
+ }
+ else if (cBlockSlabHandler::IsAnySlabType(BelowBlock))
+ {
+ // Check if the slab is turned up side down
+ if ((BelowBlockMeta & 0x08) == 0x08)
+ {
+ return true;
+ }
+ }
+ return false;
}
diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h
index ffe2414f7..d762154df 100644
--- a/src/Blocks/BlockSlab.h
+++ b/src/Blocks/BlockSlab.h
@@ -13,6 +13,7 @@
#include "../Items/ItemHandler.h"
#include "Root.h"
#include "ChunkInterface.h"
+#include "../Entities/Player.h"
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index d03e0bf21..7d6d88b26 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -2614,7 +2614,7 @@ BLOCKTYPE cChunk::GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
-void cChunk::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
+void cChunk::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const
{
a_BlockType = GetBlock(a_RelX, a_RelY, a_RelZ);
a_BlockMeta = m_ChunkData.GetMeta(a_RelX, a_RelY, a_RelZ);
diff --git a/src/Chunk.h b/src/Chunk.h
index c50be263f..5f8fcaf7b 100644
--- a/src/Chunk.h
+++ b/src/Chunk.h
@@ -186,7 +186,7 @@ public:
void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients = true); // Doesn't force block updates on neighbors, use for simple changes such as grass growing etc.
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const;
BLOCKTYPE GetBlock(const Vector3i & a_RelCoords) const { return GetBlock(a_RelCoords.x, a_RelCoords.y, a_RelCoords.z); }
- void GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta);
+ void GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const;
void GetBlockInfo (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight);
/** Returns the chunk into which the specified block belongs, by walking the neighbors.