summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockLever.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-10-19 19:13:48 +0200
committerMattes D <github@xoft.cz>2014-10-19 19:13:48 +0200
commit8fbd65e77559f7324e217428baafd220331ca427 (patch)
tree4037415eb2f534a3c822f753b7773594728d3963 /src/Blocks/BlockLever.h
parentRemoved obsolete tr1::shared_ptr. (diff)
parentFixed error with non-const function (diff)
downloadcuberite-8fbd65e77559f7324e217428baafd220331ca427.tar
cuberite-8fbd65e77559f7324e217428baafd220331ca427.tar.gz
cuberite-8fbd65e77559f7324e217428baafd220331ca427.tar.bz2
cuberite-8fbd65e77559f7324e217428baafd220331ca427.tar.lz
cuberite-8fbd65e77559f7324e217428baafd220331ca427.tar.xz
cuberite-8fbd65e77559f7324e217428baafd220331ca427.tar.zst
cuberite-8fbd65e77559f7324e217428baafd220331ca427.zip
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockLever.h36
1 files changed, 29 insertions, 7 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;
}