From 65b7040c5e1df5c3b9778d9703bd4d12b001c28d Mon Sep 17 00:00:00 2001 From: mjagdis Date: Fri, 1 Nov 2024 22:16:53 +0000 Subject: Make wall banners actually placeable (#5574) Signed-off-by: Mike Jagdis --- src/Blocks/BlockBanner.h | 51 -------------------------------- src/Blocks/BlockHandler.cpp | 7 +++-- src/Blocks/BlockStandingBanner.h | 51 ++++++++++++++++++++++++++++++++ src/Blocks/BlockWallBanner.h | 64 ++++++++++++++++++++++++++++++++++++++++ src/Blocks/CMakeLists.txt | 3 +- 5 files changed, 121 insertions(+), 55 deletions(-) delete mode 100644 src/Blocks/BlockBanner.h create mode 100644 src/Blocks/BlockStandingBanner.h create mode 100644 src/Blocks/BlockWallBanner.h (limited to 'src') diff --git a/src/Blocks/BlockBanner.h b/src/Blocks/BlockBanner.h deleted file mode 100644 index e6a159bd4..000000000 --- a/src/Blocks/BlockBanner.h +++ /dev/null @@ -1,51 +0,0 @@ - -// BlockBanner.h - -#pragma once - -#include "../BlockInfo.h" -#include "BlockEntity.h" - - - - - -class cBlockBannerHandler final : - public cBlockEntityHandler -{ - using Super = cBlockEntityHandler; - -public: - - using Super::Super; - - virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override - { - // Drops handled by the block entity: - return {}; - } - - - - - - virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override - { - if (a_Position.y < 1) - { - return false; - } - - return cBlockInfo::IsSolid(a_Chunk.GetBlock(a_Position.addedY(-1))); - } - - - - - - virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override - { - UNUSED(a_Meta); - return 0; - } -} ; diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 4b0d7e5ec..6691f151f 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -7,7 +7,6 @@ #include "BlockPluginInterface.h" #include "BlockAir.h" #include "BlockAnvil.h" -#include "BlockBanner.h" #include "BlockBed.h" #include "BlockBigFlower.h" #include "BlockBookShelf.h" @@ -89,6 +88,7 @@ #include "BlockSnow.h" #include "BlockSponge.h" #include "BlockStairs.h" +#include "BlockStandingBanner.h" #include "BlockStems.h" #include "BlockStone.h" #include "BlockSugarCane.h" @@ -99,6 +99,7 @@ #include "BlockTripwire.h" #include "BlockTripwireHook.h" #include "BlockVines.h" +#include "BlockWallBanner.h" #include "BlockWallSign.h" #include "BlockWorkbench.h" @@ -413,7 +414,7 @@ namespace constexpr cDefaultBlockHandler BlockStainedClayHandler (E_BLOCK_STAINED_CLAY); constexpr cBlockGlassHandler BlockStainedGlassHandler (E_BLOCK_STAINED_GLASS); constexpr cBlockGlassHandler BlockStainedGlassPaneHandler (E_BLOCK_STAINED_GLASS_PANE); - constexpr cBlockBannerHandler BlockStandingBannerHandler (E_BLOCK_STANDING_BANNER); + constexpr cBlockStandingBannerHandler BlockStandingBannerHandler (E_BLOCK_STANDING_BANNER); constexpr cBlockLavaHandler BlockStationaryLavaHandler (E_BLOCK_STATIONARY_LAVA); constexpr cBlockWaterHandler BlockStationaryWaterHandler (E_BLOCK_STATIONARY_WATER); constexpr cBlockPistonHandler BlockStickyPistonHandler (E_BLOCK_STICKY_PISTON); @@ -434,7 +435,7 @@ namespace constexpr cBlockTripwireHandler BlockTripwireHandler (E_BLOCK_TRIPWIRE); constexpr cBlockTripwireHookHandler BlockTripwireHookHandler (E_BLOCK_TRIPWIRE_HOOK); constexpr cBlockVinesHandler BlockVinesHandler (E_BLOCK_VINES); - constexpr cBlockBannerHandler BlockWallBannerHandler (E_BLOCK_WALL_BANNER); + constexpr cBlockWallBannerHandler BlockWallBannerHandler (E_BLOCK_WALL_BANNER); constexpr cBlockWallSignHandler BlockWallsignHandler (E_BLOCK_WALLSIGN); constexpr cBlockWaterHandler BlockWaterHandler (E_BLOCK_WATER); constexpr cBlockGlazedTerracottaHandler BlockWhiteGlazedTerracottaHandler (E_BLOCK_WHITE_GLAZED_TERRACOTTA); diff --git a/src/Blocks/BlockStandingBanner.h b/src/Blocks/BlockStandingBanner.h new file mode 100644 index 000000000..391b7fde7 --- /dev/null +++ b/src/Blocks/BlockStandingBanner.h @@ -0,0 +1,51 @@ + +// BlockStandingBanner.h + +#pragma once + +#include "../BlockInfo.h" +#include "BlockEntity.h" + + + + + +class cBlockStandingBannerHandler final : + public cBlockEntityHandler +{ + using Super = cBlockEntityHandler; + +public: + + using Super::Super; + + virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override + { + // Drops handled by the block entity: + return {}; + } + + + + + + virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override + { + if (a_Position.y < 1) + { + return false; + } + + return cBlockInfo::IsSolid(a_Chunk.GetBlock(a_Position.addedY(-1))); + } + + + + + + virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override + { + UNUSED(a_Meta); + return 0; + } +} ; diff --git a/src/Blocks/BlockWallBanner.h b/src/Blocks/BlockWallBanner.h new file mode 100644 index 000000000..e0ebb8eee --- /dev/null +++ b/src/Blocks/BlockWallBanner.h @@ -0,0 +1,64 @@ + +// BlockWallBanner.h + +#pragma once + +#include "../BlockInfo.h" +#include "BlockEntity.h" + + + + + +class cBlockWallBannerHandler final : + public cBlockEntityHandler +{ + using Super = cBlockEntityHandler; + +public: + + using Super::Super; + + virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override + { + // Drops handled by the block entity: + return {}; + } + + + + + + virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override + { + Vector3i Offset; + + switch (a_Meta) + { + case BLOCK_FACE_ZM: Offset = Vector3i( 0, 0, 1); break; + case BLOCK_FACE_ZP: Offset = Vector3i( 0, 0, -1); break; + case BLOCK_FACE_XM: Offset = Vector3i( 1, 0, 0); break; + case BLOCK_FACE_XP: Offset = Vector3i(-1, 0, 0); break; + default: return false; + } + + auto NeighborPos = a_Position + Offset; + BLOCKTYPE NeighborType; + if (!a_Chunk.UnboundedRelGetBlockType(NeighborPos, NeighborType)) + { + // The neighbour is not accessible (unloaded chunk), we'll allow it for now. + return true; + } + return cBlockInfo::IsSolid(NeighborType); + } + + + + + + virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override + { + UNUSED(a_Meta); + return 0; + } +} ; diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt index a7dd7b675..38a60d5b7 100644 --- a/src/Blocks/CMakeLists.txt +++ b/src/Blocks/CMakeLists.txt @@ -9,7 +9,6 @@ target_sources( BlockAir.h BlockAnvil.h - BlockBanner.h BlockBed.h BlockBigFlower.h BlockBookShelf.h @@ -94,6 +93,7 @@ target_sources( BlockSnow.h BlockSponge.h BlockStairs.h + BlockStandingBanner.h BlockStems.h BlockStone.h BlockSugarCane.h @@ -104,6 +104,7 @@ target_sources( BlockTripwire.h BlockTripwireHook.h BlockVines.h + BlockWallBanner.h BlockWallSign.h BlockWorkbench.h BroadcastInterface.h -- cgit v1.2.3