diff options
author | Mattes D <github@xoft.cz> | 2020-04-21 22:19:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-21 22:19:22 +0200 |
commit | 487f9a2aa9b5497495cef1ac3b9c7a603e69f862 (patch) | |
tree | 054a846942f414060e29c72f4a717c8a89e70893 /src/Blocks/BlockStairs.h | |
parent | Delet SpawnObject params (diff) | |
download | cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.gz cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.bz2 cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.lz cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.xz cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.tar.zst cuberite-487f9a2aa9b5497495cef1ac3b9c7a603e69f862.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Blocks/BlockStairs.h | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/src/Blocks/BlockStairs.h b/src/Blocks/BlockStairs.h index c9e36d535..d616f5d67 100644 --- a/src/Blocks/BlockStairs.h +++ b/src/Blocks/BlockStairs.h @@ -17,25 +17,27 @@ public: cBlockStairsHandler(BLOCKTYPE a_BlockType): Super(a_BlockType) { - } + + + + virtual bool GetPlacementBlockTypeMeta( - cChunkInterface & a_ChunkInterface, cPlayer & a_Player, - int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, - int a_CursorX, int a_CursorY, int a_CursorZ, + cChunkInterface & a_ChunkInterface, + cPlayer & a_Player, + const Vector3i a_PlacedBlockPos, + eBlockFace a_ClickedBlockFace, + const Vector3i a_CursorPos, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override { UNUSED(a_ChunkInterface); - UNUSED(a_BlockX); - UNUSED(a_BlockY); - UNUSED(a_BlockZ); - UNUSED(a_CursorX); - UNUSED(a_CursorZ); + UNUSED(a_PlacedBlockPos); + UNUSED(a_CursorPos); a_BlockType = m_BlockType; a_BlockMeta = RotationToMetaData(a_Player.GetYaw()); - switch (a_BlockFace) + switch (a_ClickedBlockFace) { case BLOCK_FACE_TOP: break; case BLOCK_FACE_BOTTOM: a_BlockMeta = a_BlockMeta | 0x4; break; // When placing onto a bottom face, always place an upside-down stairs block @@ -45,7 +47,7 @@ public: case BLOCK_FACE_WEST: { // When placing onto a sideways face, check cursor, if in top half, make it an upside-down stairs block - if (a_CursorY > 8) + if (a_CursorPos.y > 8) { a_BlockMeta |= 0x4; } @@ -56,6 +58,10 @@ public: return true; } + + + + static NIBBLETYPE RotationToMetaData(double a_Rotation) { a_Rotation += 90 + 45; // So its not aligned with axis @@ -81,12 +87,20 @@ public: } } + + + + virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override { // Toggle bit 3: return (a_Meta & 0x0b) | ((~a_Meta) & 0x04); } + + + + virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override { UNUSED(a_Meta); @@ -114,12 +128,16 @@ public: } } + + + + /** EXCEPTION a.k.a. why is this removed: This collision-detection is actually more accurate than the client, but since the client itself sends inaccurate / sparse data, it's easier to just err on the side of the client and keep the two in sync by assuming that if a player hit ANY of the stair's bounding cube, it counts as the ground. */ #if 0 - bool IsInsideBlock(const Vector3d & a_Position, const BLOCKTYPE a_BlockType, const NIBBLETYPE a_BlockMeta) + bool IsInsideBlock(Vector3d a_RelPosition, const BLOCKTYPE a_BlockType, const NIBBLETYPE a_BlockMeta) { if (a_BlockMeta & 0x4) // upside down { @@ -127,19 +145,19 @@ public: } else if ((a_BlockMeta & 0x3) == 0) // tall side is east (+X) { - return a_Position.y < ((a_Position.x > 0.5) ? 1.0 : 0.5); + return (a_RelPosition.y < ((a_RelPosition.x > 0.5) ? 1.0 : 0.5)); } else if ((a_BlockMeta & 0x3) == 1) // tall side is west (-X) { - return a_Position.y < ((a_Position.x < 0.5) ? 1.0 : 0.5); + return (a_RelPosition.y < ((a_RelPosition.x < 0.5) ? 1.0 : 0.5)); } else if ((a_BlockMeta & 0x3) == 2) // tall side is south (+Z) { - return a_Position.y < ((a_Position.z > 0.5) ? 1.0 : 0.5); + return (a_RelPosition.y < ((a_RelPosition.z > 0.5) ? 1.0 : 0.5)); } else if ((a_BlockMeta & 0x3) == 3) // tall side is north (-Z) { - return a_Position.y < ((a_Position.z < 0.5) ? 1.0 : 0.5); + return (a_RelPosition.y < ((a_RelPosition.z < 0.5) ? 1.0 : 0.5)); } return false; } |