summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage
diff options
context:
space:
mode:
Diffstat (limited to 'src/WorldStorage')
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp19
-rw-r--r--src/WorldStorage/NamespaceSerializer.cpp54
-rw-r--r--src/WorldStorage/NamespaceSerializer.h6
-rw-r--r--src/WorldStorage/WSSAnvil.cpp31
-rw-r--r--[-rwxr-xr-x]src/WorldStorage/WSSAnvil.h1
5 files changed, 105 insertions, 6 deletions
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index 30e2a7815..7ce85616c 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -12,6 +12,7 @@
#include "../UUID.h"
#include "FastNBT.h"
+#include "../BlockEntities/BannerEntity.h"
#include "../BlockEntities/BeaconEntity.h"
#include "../BlockEntities/BedEntity.h"
#include "../BlockEntities/BrewingstandEntity.h"
@@ -205,6 +206,11 @@ public:
// Add tile-entity into NBT:
switch (a_Entity->GetBlockType())
{
+ // Banners:
+ case E_BLOCK_STANDING_BANNER:
+ case E_BLOCK_WALL_BANNER: AddBannerEntity (static_cast<cBannerEntity *> (a_Entity)); break;
+
+ // Others:
case E_BLOCK_BEACON: AddBeaconEntity (static_cast<cBeaconEntity *> (a_Entity)); break;
case E_BLOCK_BED: AddBedEntity (static_cast<cBedEntity *> (a_Entity)); break;
case E_BLOCK_BREWING_STAND: AddBrewingstandEntity (static_cast<cBrewingstandEntity *> (a_Entity)); break;
@@ -226,7 +232,6 @@ public:
case E_BLOCK_SIGN_POST: AddSignEntity (static_cast<cSignEntity *> (a_Entity)); break;
case E_BLOCK_TRAPPED_CHEST: AddChestEntity (static_cast<cChestEntity *> (a_Entity), a_Entity->GetBlockType()); break;
case E_BLOCK_WALLSIGN: AddSignEntity (static_cast<cSignEntity *> (a_Entity)); break;
-
default:
{
ASSERT(!"Unhandled block entity saved into Anvil");
@@ -366,6 +371,18 @@ public:
+ void AddBannerEntity(cBannerEntity * a_Entity)
+ {
+ mWriter.BeginCompound("");
+ AddBasicTileEntity(a_Entity,"Banner");
+ mWriter.AddInt("Base", static_cast<int>(a_Entity->GetBaseColor()));
+ mWriter.EndCompound();
+ }
+
+
+
+
+
void AddBeaconEntity(cBeaconEntity * a_Entity)
{
mWriter.BeginCompound("");
diff --git a/src/WorldStorage/NamespaceSerializer.cpp b/src/WorldStorage/NamespaceSerializer.cpp
index 088714cd1..28033fe29 100644
--- a/src/WorldStorage/NamespaceSerializer.cpp
+++ b/src/WorldStorage/NamespaceSerializer.cpp
@@ -140,7 +140,7 @@ std::string_view NamespaceSerializer::From(const Statistic a_ID)
-std::string_view NamespaceSerializer::From(eMonsterType a_ID)
+std::string_view NamespaceSerializer::From(const eMonsterType a_ID)
{
switch (a_ID)
{
@@ -222,6 +222,58 @@ std::string_view NamespaceSerializer::From(eMonsterType a_ID)
+std::string_view NamespaceSerializer::From(const BannerPattern a_Pattern)
+{
+ switch (a_Pattern)
+ {
+ case BannerPattern::BottomStripe: return "bs";
+ case BannerPattern::TopStripe: return "ts";
+ case BannerPattern::LeftStripe: return "ls";
+ case BannerPattern::RightStripe: return "rs";
+ case BannerPattern::CenterStripeVertical: return "cs";
+ case BannerPattern::MiddleStripeHorizontal: return "ms";
+ case BannerPattern::DownRightStripe: return "drs";
+ case BannerPattern::DownLeftStripe: return "dls";
+ case BannerPattern::SmallVerticalStripes: return "ss";
+ case BannerPattern::DiagonalCross: return "cr";
+ case BannerPattern::SquareCross: return "sc";
+ case BannerPattern::LeftOfDiagonal: return "ld";
+ case BannerPattern::RightOfUpsideDownDiagonal: return "rud";
+ case BannerPattern::LeftOfUpsideDownDiagonal: return "lud";
+ case BannerPattern::RightOfDiagonal: return "rd";
+ case BannerPattern::VerticalHalfLeft: return "vh";
+ case BannerPattern::VerticalHalfRight: return "vhr";
+ case BannerPattern::HorizontalHalfTop: return "hh";
+ case BannerPattern::HorizontalHalfBottom: return "hhb";
+ case BannerPattern::BottomLeftCorner: return "bl";
+ case BannerPattern::BottomRightCorner: return "br";
+ case BannerPattern::TopLeftCorner: return "tl";
+ case BannerPattern::TopRightCorner: return "tr";
+ case BannerPattern::BottomTriangle: return "bt";
+ case BannerPattern::TopTriangle: return "tt";
+ case BannerPattern::BottomTriangleSawtooth: return "bts";
+ case BannerPattern::TopTriangleSawtooth: return "tts";
+ case BannerPattern::MiddleCircle: return "mc";
+ case BannerPattern::MiddleRhombus: return "mr";
+ case BannerPattern::Border: return "bo";
+ case BannerPattern::CurlyBorder: return "cbo";
+ case BannerPattern::Brick: return "bri";
+ case BannerPattern::Gradient: return "gra";
+ case BannerPattern::GradientUpsideDown: return "gru";
+ case BannerPattern::Creeper: return "cre";
+ case BannerPattern::Skull: return "sku";
+ case BannerPattern::Flower: return "flo";
+ case BannerPattern::Mojang: return "moj";
+ case BannerPattern::Globe: return "glb";
+ case BannerPattern::Piglin: return "pig";
+ }
+ UNREACHABLE("Unsupported banner pattern");
+}
+
+
+
+
+
Statistic NamespaceSerializer::ToCustomStatistic(const std::string_view ID)
{
static const std::unordered_map<std::string_view, Statistic> CustomStatistics
diff --git a/src/WorldStorage/NamespaceSerializer.h b/src/WorldStorage/NamespaceSerializer.h
index 5b0093bcc..876db740f 100644
--- a/src/WorldStorage/NamespaceSerializer.h
+++ b/src/WorldStorage/NamespaceSerializer.h
@@ -1,7 +1,8 @@
#pragma once
-#include "../Registries/Statistics.h"
-#include "../Mobs/MonsterTypes.h"
+#include "Defines.h"
+#include "Mobs/MonsterTypes.h"
+#include "Registries/Statistics.h"
namespace NamespaceSerializer
{
@@ -16,6 +17,7 @@ namespace NamespaceSerializer
std::string_view From(Statistic a_ID);
std::string_view From(eMonsterType a_ID);
+ std::string_view From(BannerPattern a_ID);
Statistic ToCustomStatistic(std::string_view a_ID);
eMonsterType ToMonsterType(std::string_view a_ID);
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index e2a9b1539..dae1ca825 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -19,6 +19,7 @@
#include "../BlockType.h"
#include "../JsonUtils.h"
+#include "../BlockEntities/BannerEntity.h"
#include "../BlockEntities/BeaconEntity.h"
#include "../BlockEntities/BedEntity.h"
#include "../BlockEntities/BrewingstandEntity.h"
@@ -635,7 +636,11 @@ OwnedBlockEntity cWSSAnvil::LoadBlockEntityFromNBT(const cParsedNBT & a_NBT, int
// Load the specific BlockEntity type:
switch (a_BlockType)
{
- // Specific entity loaders:
+ // Banners:
+ case E_BLOCK_STANDING_BANNER:
+ case E_BLOCK_WALL_BANNER: return LoadBannerFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
+
+ // Others:
case E_BLOCK_BEACON: return LoadBeaconFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
case E_BLOCK_BED: return LoadBedFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
case E_BLOCK_BREWING_STAND: return LoadBrewingstandFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
@@ -657,7 +662,6 @@ OwnedBlockEntity cWSSAnvil::LoadBlockEntityFromNBT(const cParsedNBT & a_NBT, int
case E_BLOCK_SIGN_POST: return LoadSignFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
case E_BLOCK_TRAPPED_CHEST: return LoadChestFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
case E_BLOCK_WALLSIGN: return LoadSignFromNBT (a_NBT, a_Tag, a_BlockType, a_BlockMeta, a_Pos);
-
default:
{
// All the other blocktypes should have no entities assigned to them. Report an error:
@@ -889,6 +893,29 @@ bool cWSSAnvil::CheckBlockEntityType(const cParsedNBT & a_NBT, int a_TagIdx, con
+OwnedBlockEntity cWSSAnvil::LoadBannerFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
+{
+ static const AStringVector expectedTypes({"Banner", "minecraft:standingbanner","minecraft:wallbanner"});
+ if (!CheckBlockEntityType(a_NBT, a_TagIdx, expectedTypes, a_Pos))
+ {
+ return nullptr;
+ }
+
+ // Reads base color from NBT
+ int CurrentLine = a_NBT.FindChildByName(a_TagIdx, "Base");
+ if (CurrentLine >= 0)
+ {
+ const auto Color = static_cast<unsigned char>(a_NBT.GetInt(CurrentLine));
+ return std::make_unique<cBannerEntity>(a_BlockType, a_BlockMeta, a_Pos, m_World, Color);
+ }
+
+ return nullptr;
+}
+
+
+
+
+
OwnedBlockEntity cWSSAnvil::LoadBeaconFromNBT(const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
{
// Check if the data has a proper type:
diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h
index d37bf2d25..971cbe3ef 100755..100644
--- a/src/WorldStorage/WSSAnvil.h
+++ b/src/WorldStorage/WSSAnvil.h
@@ -157,6 +157,7 @@ protected:
The coordinates are used only for the log message. */
bool CheckBlockEntityType(const cParsedNBT & a_NBT, int a_TagIdx, const AStringVector & a_ExpectedTypes, Vector3i a_Pos);
+ OwnedBlockEntity LoadBannerFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
OwnedBlockEntity LoadBeaconFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
OwnedBlockEntity LoadBedFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);
OwnedBlockEntity LoadBrewingstandFromNBT (const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos);