From 89143558958e68ac524a36548d58b6fc29029b5c Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 11 Apr 2020 00:20:51 +0100 Subject: Fix rotation metas on blocks --- src/Blocks/BlockAnvil.h | 24 +++++++++--------------- src/Blocks/BlockChest.h | 4 ++-- src/Blocks/BlockDoor.h | 4 ++-- src/Blocks/BlockDropSpenser.h | 4 ++-- src/Blocks/BlockFurnace.h | 4 ++-- src/Blocks/BlockPiston.h | 4 ++-- src/Blocks/BlockPumpkin.h | 4 ++-- src/Blocks/Mixins.h | 14 ++++++++++---- 8 files changed, 31 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/Blocks/BlockAnvil.h b/src/Blocks/BlockAnvil.h index 2252c7ded..da242fdb7 100644 --- a/src/Blocks/BlockAnvil.h +++ b/src/Blocks/BlockAnvil.h @@ -2,6 +2,7 @@ #pragma once #include "BlockHandler.h" +#include "Mixins.h" #include "../Entities/Player.h" #include "../UI/AnvilWindow.h" @@ -10,11 +11,13 @@ class cBlockAnvilHandler : - public cBlockHandler + public cYawRotator { public: + using super = cYawRotator; + cBlockAnvilHandler(BLOCKTYPE a_BlockType) - : cBlockHandler(a_BlockType) + : super(a_BlockType) { } @@ -45,21 +48,12 @@ public: BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override { - a_BlockType = m_BlockType; - NIBBLETYPE Meta = static_cast(a_Player.GetEquippedItem().m_ItemDamage); - int Direction = static_cast(floor(a_Player.GetYaw() * 4.0 / 360.0 + 1.5)) & 0x3; - - switch (Direction) + if (!super::GetPlacementBlockTypeMeta(a_ChunkInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta)) { - case 0: a_BlockMeta = static_cast(0x2 | Meta << 2); break; - case 1: a_BlockMeta = static_cast(0x3 | Meta << 2); break; - case 2: a_BlockMeta = static_cast(0x0 | Meta << 2); break; - case 3: a_BlockMeta = static_cast(0x1 | Meta << 2); break; - default: - { - return false; - } + return false; } + + a_BlockMeta = a_BlockMeta | static_cast(a_Player.GetEquippedItem().m_ItemDamage << 2); return true; } diff --git a/src/Blocks/BlockChest.h b/src/Blocks/BlockChest.h index 2176bba96..cd70c95b6 100644 --- a/src/Blocks/BlockChest.h +++ b/src/Blocks/BlockChest.h @@ -11,9 +11,9 @@ class cBlockChestHandler : - public cYawRotator> + public cYawRotator, 0x07, 0x03, 0x04, 0x02, 0x05> { - using super = cYawRotator>; + using super = cYawRotator, 0x07, 0x03, 0x04, 0x02, 0x05>; public: diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h index 61185f562..be589ed29 100644 --- a/src/Blocks/BlockDoor.h +++ b/src/Blocks/BlockDoor.h @@ -12,9 +12,9 @@ class cBlockDoorHandler : - public cYawRotator + public cYawRotator { - using super = cYawRotator; + using super = cYawRotator; public: diff --git a/src/Blocks/BlockDropSpenser.h b/src/Blocks/BlockDropSpenser.h index df29ca14a..2cade1210 100644 --- a/src/Blocks/BlockDropSpenser.h +++ b/src/Blocks/BlockDropSpenser.h @@ -14,9 +14,9 @@ class cBlockDropSpenserHandler : - public cPitchYawRotator + public cPitchYawRotator { - using super = cPitchYawRotator; + using super = cPitchYawRotator; public: diff --git a/src/Blocks/BlockFurnace.h b/src/Blocks/BlockFurnace.h index 10606242b..c4044a0b2 100644 --- a/src/Blocks/BlockFurnace.h +++ b/src/Blocks/BlockFurnace.h @@ -9,9 +9,9 @@ class cBlockFurnaceHandler : - public cYawRotator + public cYawRotator { - using super = cYawRotator; + using super = cYawRotator; public: diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h index 0ced74626..53a3537a2 100644 --- a/src/Blocks/BlockPiston.h +++ b/src/Blocks/BlockPiston.h @@ -17,9 +17,9 @@ class cWorld; class cBlockPistonHandler: - public cClearMetaOnDrop> + public cClearMetaOnDrop> { - using super = cClearMetaOnDrop>; + using super = cClearMetaOnDrop>; public: diff --git a/src/Blocks/BlockPumpkin.h b/src/Blocks/BlockPumpkin.h index ac1c77ecc..150d305e1 100644 --- a/src/Blocks/BlockPumpkin.h +++ b/src/Blocks/BlockPumpkin.h @@ -6,9 +6,9 @@ class cBlockPumpkinHandler : - public cClearMetaOnDrop> + public cClearMetaOnDrop> { - using super = cClearMetaOnDrop>; + using super = cClearMetaOnDrop>; public: cBlockPumpkinHandler(BLOCKTYPE a_BlockType) : diff --git a/src/Blocks/Mixins.h b/src/Blocks/Mixins.h index 62eaeae5c..1ee2876d3 100644 --- a/src/Blocks/Mixins.h +++ b/src/Blocks/Mixins.h @@ -203,7 +203,10 @@ public: ) override { NIBBLETYPE BaseMeta; - super::GetPlacementBlockTypeMeta(a_ChunkInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, BaseMeta); + if (!super::GetPlacementBlockTypeMeta(a_ChunkInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, BaseMeta)) + { + return false; + } a_BlockMeta = (BaseMeta & ~BitMask) | YawToMetaData(a_Player.GetYaw()); return true; @@ -249,8 +252,8 @@ template < NIBBLETYPE East = 0x05, NIBBLETYPE South = 0x03, NIBBLETYPE West = 0x04, - NIBBLETYPE Up = 0x01, - NIBBLETYPE Down = 0x00 + NIBBLETYPE Up = 0x00, + NIBBLETYPE Down = 0x01 > class cPitchYawRotator: public cYawRotator @@ -274,7 +277,10 @@ public: ) override { NIBBLETYPE BaseMeta; - super::GetPlacementBlockTypeMeta(a_ChunkInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, BaseMeta); + if (!super::GetPlacementBlockTypeMeta(a_ChunkInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, BaseMeta)) + { + return false; + } a_BlockMeta = (BaseMeta & ~BitMask) | PitchYawToMetaData(a_Player.GetYaw(), a_Player.GetPitch()); return true; -- cgit v1.2.3