From a62b2b1be2103d7de2fd66c7304b7473e369be3c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 5 May 2021 14:25:10 +0100 Subject: Move item placement into item handlers (#5184) * Move item placement into item handlers + Add appropriate CanBeAt checks in cPlayer::PlaceBlocks, into which all placement handlers call. * Partly addresses #5157 * Fixes #4878 * Fixes #2919 * Fixes #4629 * Fixes #4239 * Fixes #4849 Co-authored-by: changyong guo Co-authored-by: Xotheus Co-authored-by: Krist Pregracke * Review fixes * Update APIDesc.lua * Rename Co-authored-by: changyong guo Co-authored-by: Xotheus Co-authored-by: Krist Pregracke --- src/Blocks/BlockEndPortalFrame.h | 74 +++++----------------------------------- 1 file changed, 8 insertions(+), 66 deletions(-) (limited to 'src/Blocks/BlockEndPortalFrame.h') diff --git a/src/Blocks/BlockEndPortalFrame.h b/src/Blocks/BlockEndPortalFrame.h index 0b5e84da2..68e6e09fe 100644 --- a/src/Blocks/BlockEndPortalFrame.h +++ b/src/Blocks/BlockEndPortalFrame.h @@ -8,19 +8,19 @@ class cBlockEndPortalFrameHandler final : - public cMetaRotator { - using Super = cMetaRotator< + using Super = cYawRotator< cBlockHandler, 0x03, - E_META_END_PORTAL_FRAME_ZM, - E_META_END_PORTAL_FRAME_XP, E_META_END_PORTAL_FRAME_ZP, - E_META_END_PORTAL_FRAME_XM + E_META_END_PORTAL_FRAME_XM, + E_META_END_PORTAL_FRAME_ZM, + E_META_END_PORTAL_FRAME_XP >; public: @@ -29,54 +29,6 @@ public: private: - virtual bool GetPlacementBlockTypeMeta( - cChunkInterface & a_ChunkInterface, - cPlayer & a_Player, - const Vector3i a_PlacedBlockPos, - eBlockFace a_ClickedBlockFace, - const Vector3i a_CursorPos, - BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta - ) const override - { - a_BlockType = m_BlockType; - a_BlockMeta = YawToMetaData(a_Player.GetYaw()); - return true; - } - - - - - - inline static NIBBLETYPE YawToMetaData(double a_Rotation) - { - a_Rotation += 90 + 45; // So its not aligned with axis - if (a_Rotation > 360) - { - a_Rotation -= 360; - } - - if ((a_Rotation >= 0) && (a_Rotation < 90)) - { - return E_META_END_PORTAL_FRAME_XM; - } - else if ((a_Rotation >= 180) && (a_Rotation < 270)) - { - return E_META_END_PORTAL_FRAME_XP; - } - else if ((a_Rotation >= 90) && (a_Rotation < 180)) - { - return E_META_END_PORTAL_FRAME_ZM; - } - else - { - return E_META_END_PORTAL_FRAME_ZP; - } - } - - - - - virtual void OnPlaced(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) const override { // E_META_END_PORTAL_FRAME_EYE is the bit which signifies the eye of ender is in it. @@ -237,16 +189,6 @@ private: - virtual bool IsClickedThrough(void) const override - { - // TODO: Colision - return true; - } - - - - - virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override { UNUSED(a_Meta); -- cgit v1.2.3