summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockLever.h
diff options
context:
space:
mode:
authorJulian Laubstein <julianlaubstein@yahoo.de>2014-10-19 15:01:01 +0200
committerJulian Laubstein <julianlaubstein@yahoo.de>2014-10-19 15:01:01 +0200
commit403f8581cf4a10e8402a129eca3f595eb5c029ab (patch)
tree05581d4ec964904b754735ca4746197834a881b6 /src/Blocks/BlockLever.h
parentMountain height gen: Added ditches. (diff)
downloadcuberite-403f8581cf4a10e8402a129eca3f595eb5c029ab.tar
cuberite-403f8581cf4a10e8402a129eca3f595eb5c029ab.tar.gz
cuberite-403f8581cf4a10e8402a129eca3f595eb5c029ab.tar.bz2
cuberite-403f8581cf4a10e8402a129eca3f595eb5c029ab.tar.lz
cuberite-403f8581cf4a10e8402a129eca3f595eb5c029ab.tar.xz
cuberite-403f8581cf4a10e8402a129eca3f595eb5c029ab.tar.zst
cuberite-403f8581cf4a10e8402a129eca3f595eb5c029ab.zip
Diffstat (limited to 'src/Blocks/BlockLever.h')
-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;
}