summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/FastNBT.h8
-rw-r--r--source/WSSAnvil.cpp45
-rw-r--r--source/WSSAnvil.h1
3 files changed, 51 insertions, 3 deletions
diff --git a/source/FastNBT.h b/source/FastNBT.h
index ca801b36f..88d79f4c1 100644
--- a/source/FastNBT.h
+++ b/source/FastNBT.h
@@ -182,6 +182,14 @@ public:
return NetworkToHostDouble8(m_Data + m_Tags[a_Tag].m_DataStart);
}
+ inline AString GetString(int a_Tag) const
+ {
+ ASSERT(m_Tags[a_Tag].m_Type == TAG_String);
+ AString res;
+ res.assign(m_Data + m_Tags[a_Tag].m_DataStart, m_Tags[a_Tag].m_DataLength);
+ return res;
+ }
+
protected:
const char * m_Data;
int m_Length;
diff --git a/source/WSSAnvil.cpp b/source/WSSAnvil.cpp
index 435b8007d..14cea81f0 100644
--- a/source/WSSAnvil.cpp
+++ b/source/WSSAnvil.cpp
@@ -10,10 +10,10 @@
#include "BlockID.h"
#include "cChestEntity.h"
#include "cFurnaceEntity.h"
+#include "cSignEntity.h"
#include "cItem.h"
#include "StringCompression.h"
#include "cEntity.h"
-#include "cBlockEntity.h"
#include "cMakeDir.h"
#include "FastNBT.h"
@@ -136,6 +136,18 @@ protected:
}
+ void AddSignEntity(cSignEntity * a_Sign)
+ {
+ m_Writer.BeginCompound("");
+ AddBasicTileEntity(a_Sign, "Sign");
+ m_Writer.AddString("Text1", a_Sign->GetLine(0));
+ m_Writer.AddString("Text2", a_Sign->GetLine(1));
+ m_Writer.AddString("Text3", a_Sign->GetLine(2));
+ m_Writer.AddString("Text4", a_Sign->GetLine(3));
+ m_Writer.EndCompound();
+ }
+
+
virtual bool LightIsValid(bool a_IsLightValid) override
{
m_IsLightValid = a_IsLightValid;
@@ -168,8 +180,10 @@ protected:
// Add tile-entity into NBT:
switch (a_Entity->GetBlockType())
{
- case E_BLOCK_CHEST: AddChestEntity ((cChestEntity *) a_Entity); break;
- case E_BLOCK_FURNACE: AddFurnaceEntity((cFurnaceEntity *)a_Entity); break;
+ case E_BLOCK_CHEST: AddChestEntity ((cChestEntity *) a_Entity); break;
+ case E_BLOCK_FURNACE: AddFurnaceEntity((cFurnaceEntity *)a_Entity); break;
+ case E_BLOCK_SIGN_POST:
+ case E_BLOCK_WALLSIGN: AddSignEntity ((cSignEntity *) a_Entity); break;
default:
{
ASSERT(!"Unhandled block entity saved into Anvil");
@@ -619,6 +633,10 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, con
{
LoadFurnaceFromNBT(a_BlockEntities, a_NBT, Child);
}
+ else if (strncmp(a_NBT.GetData(sID), "Sign", a_NBT.GetDataLength(sID)) == 0)
+ {
+ LoadSignFromNBT(a_BlockEntities, a_NBT, Child);
+ }
// TODO: Other block entities
} // for Child - tag children
}
@@ -740,6 +758,27 @@ void cWSSAnvil::LoadFurnaceFromNBT(cBlockEntityList & a_BlockEntities, const cPa
+void cWSSAnvil::LoadSignFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx)
+{
+ ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound);
+ int x, y, z;
+ if (!GetBlockEntityNBTPos(a_NBT, a_TagIdx, x, y, z))
+ {
+ return;
+ }
+ std::auto_ptr<cSignEntity> Sign(new cSignEntity(E_BLOCK_SIGN_POST, x, y, z, m_World));
+ int Text1 = a_NBT.FindChildByName(a_TagIdx, "Text1");
+ if (Text1 >= 0)
+ {
+ Sign->SetLine(0, a_NBT.GetString(Text1));
+ }
+ a_BlockEntities.push_back(Sign.release());
+}
+
+
+
+
+
bool cWSSAnvil::GetBlockEntityNBTPos(const cParsedNBT & a_NBT, int a_TagIdx, int & a_X, int & a_Y, int & a_Z)
{
int x = a_NBT.FindChildByName(a_TagIdx, "x");
diff --git a/source/WSSAnvil.h b/source/WSSAnvil.h
index ab03adf5e..a88a67374 100644
--- a/source/WSSAnvil.h
+++ b/source/WSSAnvil.h
@@ -110,6 +110,7 @@ protected:
void LoadChestFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadFurnaceFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
+ void LoadSignFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
/// Helper function for extracting the X, Y, and Z int subtags of a NBT compound; returns true if successful
bool GetBlockEntityNBTPos(const cParsedNBT & a_NBT, int a_TagIdx, int & a_X, int & a_Y, int & a_Z);