From f40aba941eaf69b52ac0fbe3d8cea1ea349b97a6 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Wed, 8 Apr 2020 21:35:08 +0100 Subject: Add mixins for blocks that rotate based on player yaw at placement Also add observer block handler. --- src/Blocks/BlockDoor.h | 40 +++------------------------------------- 1 file changed, 3 insertions(+), 37 deletions(-) (limited to 'src/Blocks/BlockDoor.h') diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index ccb34c5a9..61185f562 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -12,9 +12,9 @@ class cBlockDoorHandler : - public cMetaRotator + public cYawRotator { - using super = cMetaRotator; + using super = cYawRotator; public: @@ -50,9 +50,7 @@ public: return false; } - a_BlockType = m_BlockType; - a_BlockMeta = PlayerYawToMetaData(a_Player.GetYaw()); - return true; + return super::GetPlacementBlockTypeMeta(a_ChunkInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta); } virtual cBoundingBox GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP) override; @@ -146,38 +144,6 @@ public: - /** Converts the player's yaw to placed door's blockmeta */ - inline static NIBBLETYPE PlayerYawToMetaData(double a_Yaw) - { - ASSERT((a_Yaw >= -180) && (a_Yaw < 180)); - - a_Yaw += 90 + 45; - if (a_Yaw > 360) - { - a_Yaw -= 360; - } - if ((a_Yaw >= 0) && (a_Yaw < 90)) - { - return 0x00; - } - else if ((a_Yaw >= 180) && (a_Yaw < 270)) - { - return 0x02; - } - else if ((a_Yaw >= 90) && (a_Yaw < 180)) - { - return 0x01; - } - else - { - return 0x03; - } - } - - - - - /** Returns a vector pointing one block in the direction the door is facing (where the outside is). */ inline static Vector3i GetRelativeDirectionToOutside(NIBBLETYPE a_BlockMeta) { -- cgit v1.2.3