diff options
author | Alexander Harkness <me@bearbin.net> | 2020-04-11 01:20:51 +0200 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2020-04-11 21:00:05 +0200 |
commit | 89143558958e68ac524a36548d58b6fc29029b5c (patch) | |
tree | 1430a9c46ee44ec4ab789b4849a9a0049bae1cdc /src/Blocks/BlockAnvil.h | |
parent | added me as contributor (diff) | |
download | cuberite-89143558958e68ac524a36548d58b6fc29029b5c.tar cuberite-89143558958e68ac524a36548d58b6fc29029b5c.tar.gz cuberite-89143558958e68ac524a36548d58b6fc29029b5c.tar.bz2 cuberite-89143558958e68ac524a36548d58b6fc29029b5c.tar.lz cuberite-89143558958e68ac524a36548d58b6fc29029b5c.tar.xz cuberite-89143558958e68ac524a36548d58b6fc29029b5c.tar.zst cuberite-89143558958e68ac524a36548d58b6fc29029b5c.zip |
Diffstat (limited to 'src/Blocks/BlockAnvil.h')
-rw-r--r-- | src/Blocks/BlockAnvil.h | 24 |
1 files changed, 9 insertions, 15 deletions
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<cBlockHandler, 0x03, 0x03, 0x00, 0x01, 0x02> { public: + using super = cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x01, 0x02>; + 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<NIBBLETYPE>(a_Player.GetEquippedItem().m_ItemDamage); - int Direction = static_cast<int>(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<NIBBLETYPE>(0x2 | Meta << 2); break; - case 1: a_BlockMeta = static_cast<NIBBLETYPE>(0x3 | Meta << 2); break; - case 2: a_BlockMeta = static_cast<NIBBLETYPE>(0x0 | Meta << 2); break; - case 3: a_BlockMeta = static_cast<NIBBLETYPE>(0x1 | Meta << 2); break; - default: - { - return false; - } + return false; } + + a_BlockMeta = a_BlockMeta | static_cast<NIBBLETYPE>(a_Player.GetEquippedItem().m_ItemDamage << 2); return true; } |