From 5a1662032227d706d00fa3994301f98667703655 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 20 Sep 2020 15:39:17 +0100 Subject: [PATCH] Cauldron: backport "use" behaviour to 1.12 (#4902) * Cauldron: backport "use" behaviour to 1.12 --- src/Blocks/BlockCauldron.h | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/Blocks/BlockCauldron.h b/src/Blocks/BlockCauldron.h index 9f2d0c82e..b8cd9081c 100644 --- a/src/Blocks/BlockCauldron.h +++ b/src/Blocks/BlockCauldron.h @@ -39,6 +39,7 @@ private: { NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockPos); auto EquippedItem = a_Player.GetEquippedItem(); + switch (EquippedItem.m_ItemType) { case E_ITEM_BUCKET: @@ -96,12 +97,12 @@ private: } break; } - // Resets any color to default: case E_ITEM_LEATHER_BOOTS: case E_ITEM_LEATHER_CAP: case E_ITEM_LEATHER_PANTS: case E_ITEM_LEATHER_TUNIC: { + // Resets any color to default: if ((Meta > 0) && ((EquippedItem.m_ItemColor.GetRed() != 255) || (EquippedItem.m_ItemColor.GetBlue() != 255) || (EquippedItem.m_ItemColor.GetGreen() != 255))) { a_ChunkInterface.SetBlockMeta(a_BlockPos, --Meta); @@ -111,7 +112,6 @@ private: } break; } - // Resets shulker box color: case E_BLOCK_BLACK_SHULKER_BOX: case E_BLOCK_BLUE_SHULKER_BOX: case E_BLOCK_BROWN_SHULKER_BOX: @@ -127,6 +127,8 @@ private: case E_BLOCK_RED_SHULKER_BOX: case E_BLOCK_YELLOW_SHULKER_BOX: { + // Resets shulker box color. + // TODO: When there is an actual default shulker box add the appropriate changes here! - 19.09.2020 - 12xx12 if (Meta == 0) { @@ -134,22 +136,30 @@ private: break; } - // This is a workaround for version < 1.13. They client thinks a player placed a shulker and display that to the player - // The shulker cleaning was added in 1.13. - const auto ResendPosition = AddFaceDirection(a_BlockPos, a_BlockFace); - a_Player.GetClientHandle()->SendBlockChange( - ResendPosition.x, ResendPosition.y, ResendPosition.z, - a_ChunkInterface.GetBlock(ResendPosition), a_ChunkInterface.GetBlockMeta(ResendPosition) - ); - // Proceed with normal cleaning: a_ChunkInterface.SetBlockMeta(a_BlockPos, --Meta); auto NewShulker = cItem(EquippedItem); NewShulker.m_ItemType = E_BLOCK_PURPLE_SHULKER_BOX; a_Player.ReplaceOneEquippedItemTossRest(NewShulker); + break; } } + + if (!ItemHandler(EquippedItem.m_ItemType)->IsPlaceable()) + { + // Item not placeable in the first place, our work is done: + return true; + } + + // This is a workaround for versions < 1.13, where rclking a cauldron with a block, places a block. + // Using cauldrons with blocks was added in 1.13 as part of shulker cleaning. + const auto ResendPosition = AddFaceDirection(a_BlockPos, a_BlockFace); + a_Player.GetClientHandle()->SendBlockChange( + ResendPosition.x, ResendPosition.y, ResendPosition.z, + a_ChunkInterface.GetBlock(ResendPosition), a_ChunkInterface.GetBlockMeta(ResendPosition) + ); + return true; }