From b7de59de89994f026336e690e9ed7449f89836b8 Mon Sep 17 00:00:00 2001 From: mjagdis Date: Sun, 30 Jun 2024 19:09:42 +0100 Subject: Preserve banner names across place and pick up (#5565) * Preserve banner names across place and pick up Signed-off-by: Mike Jagdis * Update src/BlockEntities/BannerEntity.h --------- Signed-off-by: Mike Jagdis Co-authored-by: Alexander Harkness --- src/WorldStorage/WSSAnvil.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/WorldStorage/WSSAnvil.cpp') diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index dec05f351..5a5a94d4e 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -890,15 +890,23 @@ OwnedBlockEntity cWSSAnvil::LoadBannerFromNBT(const cParsedNBT & a_NBT, int a_Ta return nullptr; } + unsigned char Color = 15; + AString CustomName; + // Reads base color from NBT int CurrentLine = a_NBT.FindChildByName(a_TagIdx, "Base"); if (CurrentLine >= 0) { - const auto Color = static_cast(a_NBT.GetInt(CurrentLine)); - return std::make_unique(a_BlockType, a_BlockMeta, a_Pos, m_World, Color); + Color = static_cast(a_NBT.GetInt(CurrentLine)); } - return nullptr; + CurrentLine = a_NBT.FindChildByName(a_TagIdx, "CustomName"); + if ((CurrentLine >= 0) && (a_NBT.GetType(CurrentLine) == TAG_String)) + { + CustomName = a_NBT.GetString(CurrentLine); + } + + return std::make_unique(a_BlockType, a_BlockMeta, a_Pos, m_World, Color, CustomName); } -- cgit v1.2.3