summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorwraith11 <wraith11@users.noreply.github.com>2015-04-07 17:51:38 +0200
committerwraith11 <Simon-Hahn-1@web.de>2015-04-21 20:47:02 +0200
commit794013315b5c4759181dbe5795eda937eff111c0 (patch)
tree0888c2521a9607e9ed907312c0493476fe69c980 /src
parentAdded extra divide operator to Vector3. (diff)
downloadcuberite-794013315b5c4759181dbe5795eda937eff111c0.tar
cuberite-794013315b5c4759181dbe5795eda937eff111c0.tar.gz
cuberite-794013315b5c4759181dbe5795eda937eff111c0.tar.bz2
cuberite-794013315b5c4759181dbe5795eda937eff111c0.tar.lz
cuberite-794013315b5c4759181dbe5795eda937eff111c0.tar.xz
cuberite-794013315b5c4759181dbe5795eda937eff111c0.tar.zst
cuberite-794013315b5c4759181dbe5795eda937eff111c0.zip
Diffstat (limited to 'src')
-rw-r--r--src/Blocks/BlockDoor.h25
-rw-r--r--src/Items/ItemDoor.h2
2 files changed, 21 insertions, 6 deletions
diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h
index 53f84b553..445383e7c 100644
--- a/src/Blocks/BlockDoor.h
+++ b/src/Blocks/BlockDoor.h
@@ -6,7 +6,7 @@
#include "Chunk.h"
#include "MetaRotator.h"
#include "ChunkInterface.h"
-
+#include "BlockSlab.h"
@@ -109,16 +109,31 @@ 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) && CanBeOn(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)));
+ return ((a_RelY > 0) && CanBeOn(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ), a_Chunk.GetMeta(a_RelX, a_RelY - 1, a_RelZ)));
}
/** Returns true if door can be placed on the specified block type. */
- static bool CanBeOn(BLOCKTYPE a_BlockType)
+ static bool CanBeOn(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- // Vanilla refuses to place doors on transparent blocks
+ // Vanilla refuses to place doors on transparent blocks, except top-half slabs and other doors
// We need to keep the door compatible with itself, otherwise the top half drops while the bottom half stays
- return !cBlockInfo::IsTransparent(a_BlockType) || IsDoorBlockType(a_BlockType);
+
+ // Doors can be placed on upside-down slabs
+ if (cBlockSlabHandler::IsAnySlabType(a_BlockType) && ((a_BlockMeta & 0x08) != 0))
+ {
+ return true;
+ }
+ // Doors can also be placed on other doors
+ else if (IsDoorBlockType(a_BlockType))
+ {
+ return true;
+ }
+ // Doors can not be placed on transparent blocks, but on any other block
+ else
+ {
+ return !cBlockInfo::IsTransparent(a_BlockType);
+ }
}
diff --git a/src/Items/ItemDoor.h b/src/Items/ItemDoor.h
index 524c49a5c..ddd3d4e20 100644
--- a/src/Items/ItemDoor.h
+++ b/src/Items/ItemDoor.h
@@ -40,7 +40,7 @@ public:
}
// The door needs a compatible block below it:
- if (!cBlockDoorHandler::CanBeOn(a_World.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ)))
+ if (!cBlockDoorHandler::CanBeOn(a_World.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ), a_World.GetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ)))
{
return false;
}