summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockRail.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/BlockRail.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/BlockRail.h')
-rw-r--r--src/Blocks/BlockRail.h30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/Blocks/BlockRail.h b/src/Blocks/BlockRail.h
index 6c4367334..4e2e6211f 100644
--- a/src/Blocks/BlockRail.h
+++ b/src/Blocks/BlockRail.h
@@ -1,6 +1,14 @@
-
#pragma once
+#include "BlockHandler.h"
+#include "BlockSlab.h"
+#include "BlockStairs.h"
+#include "BlockType.h"
+#include "Blocks/Mixins.h"
+#include "../BlockInfo.h"
+#include "../Chunk.h"
+#include "ChunkDef.h"
+
@@ -154,9 +162,26 @@ public:
private:
+ static bool CanBeSupportedBy(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
+ {
+ if (cBlockSlabHandler::IsAnySlabType(a_BlockType))
+ {
+ return (a_BlockMeta & E_META_WOODEN_SLAB_UPSIDE_DOWN);
+ }
+ else if (cBlockStairsHandler::IsAnyStairType(a_BlockType))
+ {
+ return (a_BlockMeta & E_BLOCK_STAIRS_UPSIDE_DOWN);
+ }
+ return cBlockInfo::FullyOccupiesVoxel(a_BlockType);
+ }
+
virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, NIBBLETYPE a_Meta) const override
{
- if ((a_Position.y <= 0) || !cBlockInfo::FullyOccupiesVoxel(a_Chunk.GetBlock(a_Position.addedY(-1))))
+ BLOCKTYPE BelowBlock;
+ NIBBLETYPE BelowBlockMeta;
+ a_Chunk.GetBlockTypeMeta(a_Position.addedY(-1), BelowBlock, BelowBlockMeta);
+
+ if ((a_Position.y <= 0) || !CanBeSupportedBy(BelowBlock, BelowBlockMeta))
{
return false;
}
@@ -187,6 +212,7 @@ private:
return cBlockInfo::FullyOccupiesVoxel(BlockType);
}
}
+
return true;
}