summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockDoor.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2019-10-11 11:02:53 +0200
committerMattes D <github@xoft.cz>2019-10-28 10:45:43 +0100
commit61904af626b036b6e4e045ca219b2a361aa45a6e (patch)
tree60b99ab37c9ec87ca96d403b3254a4da023cf6ac /src/Blocks/BlockDoor.h
parentUpdate README.md (#4423) (diff)
downloadcuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.tar
cuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.tar.gz
cuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.tar.bz2
cuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.tar.lz
cuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.tar.xz
cuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.tar.zst
cuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.zip
Diffstat (limited to 'src/Blocks/BlockDoor.h')
-rw-r--r--src/Blocks/BlockDoor.h36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h
index b1a606f67..596e69793 100644
--- a/src/Blocks/BlockDoor.h
+++ b/src/Blocks/BlockDoor.h
@@ -141,6 +141,10 @@ public:
return false;
}
+
+
+
+
/** Converts the player's yaw to placed door's blockmeta */
inline static NIBBLETYPE PlayerYawToMetaData(double a_Yaw)
{
@@ -169,6 +173,10 @@ public:
}
}
+
+
+
+
/** Returns a vector pointing one block in the direction the door is facing (where the outside is). */
inline static Vector3i GetRelativeDirectionToOutside(NIBBLETYPE a_BlockMeta)
{
@@ -181,6 +189,10 @@ public:
}
}
+
+
+
+
/** Returns true if the specified blocktype is any kind of door */
inline static bool IsDoorBlockType(BLOCKTYPE a_Block)
{
@@ -203,6 +215,10 @@ public:
}
}
+
+
+
+
/** Returns true iff the door at the specified coords is open.
The coords may point to either the top part or the bottom part of the door. */
static NIBBLETYPE IsOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
@@ -211,6 +227,10 @@ public:
return ((Meta & 0x04) != 0);
}
+
+
+
+
/** Returns the complete meta composed from the both parts of the door as (TopMeta << 4) | BottomMeta
The coords may point to either part of the door.
The returned value has bit 3 (0x08) set iff the coords point to the top part of the door.
@@ -243,6 +263,10 @@ public:
}
}
+
+
+
+
/** Sets the door to the specified state. If the door is already in that state, does nothing. */
static void SetOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open)
{
@@ -264,24 +288,32 @@ public:
if ((Meta & 0x08) == 0)
{
// The block is the bottom part of the door
- a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, NewMeta);
+ a_ChunkInterface.SetBlockMeta({a_BlockX, a_BlockY, a_BlockZ}, NewMeta);
}
else
{
// The block is the top part of the door, set the meta to the corresponding top part
if (a_BlockY > 0)
{
- a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ, NewMeta);
+ a_ChunkInterface.SetBlockMeta({a_BlockX, a_BlockY - 1, a_BlockZ}, NewMeta);
}
}
}
+
+
+
+
/** Changes the door at the specified coords from open to close or vice versa */
static void ChangeDoor(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{
SetOpen(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, !IsOpen(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ));
}
+
+
+
+
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);