summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockButton.h
diff options
context:
space:
mode:
authorMichal Havlíček <80639037+havel06@users.noreply.github.com>2023-01-25 21:46:34 +0100
committerGitHub <noreply@github.com>2023-01-25 21:46:34 +0100
commit7fdfb8644169a25805afd32f00ced38c1c14cec8 (patch)
tree33f107ef8a6e8c1821187294cbadd965418b6e3b /src/Blocks/BlockButton.h
parentChanged Windows instructions to build out-of-source. (diff)
downloadcuberite-7fdfb8644169a25805afd32f00ced38c1c14cec8.tar
cuberite-7fdfb8644169a25805afd32f00ced38c1c14cec8.tar.gz
cuberite-7fdfb8644169a25805afd32f00ced38c1c14cec8.tar.bz2
cuberite-7fdfb8644169a25805afd32f00ced38c1c14cec8.tar.lz
cuberite-7fdfb8644169a25805afd32f00ced38c1c14cec8.tar.xz
cuberite-7fdfb8644169a25805afd32f00ced38c1c14cec8.tar.zst
cuberite-7fdfb8644169a25805afd32f00ced38c1c14cec8.zip
Diffstat (limited to 'src/Blocks/BlockButton.h')
-rw-r--r--src/Blocks/BlockButton.h37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h
index d703d73bd..1a141eff3 100644
--- a/src/Blocks/BlockButton.h
+++ b/src/Blocks/BlockButton.h
@@ -1,10 +1,15 @@
#pragma once
#include "BlockHandler.h"
+#include "BlockSlab.h"
+#include "BlockStairs.h"
#include "../BlockInfo.h"
#include "../Chunk.h"
+#include "Defines.h"
+#include "Entities/Player.h"
#include "Mixins.h"
#include "ChunkInterface.h"
+#include "World.h"
@@ -132,7 +137,37 @@ private:
return false;
}
BLOCKTYPE SupportBlockType;
- a_Chunk.UnboundedRelGetBlockType(SupportRelPos, SupportBlockType);
+ NIBBLETYPE SupportBlockMeta;
+ a_Chunk.UnboundedRelGetBlock(SupportRelPos, SupportBlockType, SupportBlockMeta);
+ eBlockFace Face = BlockMetaDataToBlockFace(a_Meta);
+
+ // upside down slabs
+ if (cBlockSlabHandler::IsAnySlabType(SupportBlockType))
+ {
+ return (Face == BLOCK_FACE_YP) && (SupportBlockMeta & E_META_WOODEN_SLAB_UPSIDE_DOWN);
+ }
+
+ // stairs (top and sides)
+ if (cBlockStairsHandler::IsAnyStairType(SupportBlockType))
+ {
+ switch (Face)
+ {
+ case eBlockFace::BLOCK_FACE_YP:
+ return (SupportBlockMeta & E_BLOCK_STAIRS_UPSIDE_DOWN);
+ case eBlockFace::BLOCK_FACE_XP:
+ return ((SupportBlockMeta & 0b11) == E_BLOCK_STAIRS_XP);
+ case eBlockFace::BLOCK_FACE_XM:
+ return ((SupportBlockMeta & 0b11) == E_BLOCK_STAIRS_XM);
+ case eBlockFace::BLOCK_FACE_ZP:
+ return ((SupportBlockMeta & 0b11) == E_BLOCK_STAIRS_ZP);
+ case eBlockFace::BLOCK_FACE_ZM:
+ return ((SupportBlockMeta & 0b11) == E_BLOCK_STAIRS_ZM);
+ default:
+ {
+ return false;
+ }
+ }
+ }
return cBlockInfo::FullyOccupiesVoxel(SupportBlockType);
}