summaryrefslogtreecommitdiffstats
path: root/source/WSSAnvil.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-15 22:58:52 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-15 22:58:52 +0200
commita06b72c18dde43d8b242ed02261daa7c19c8b910 (patch)
tree8d8d91e4856c13119732cf578dc5862fede5556b /source/WSSAnvil.cpp
parentBasic handling of vines. No growth yet. (diff)
downloadcuberite-a06b72c18dde43d8b242ed02261daa7c19c8b910.tar
cuberite-a06b72c18dde43d8b242ed02261daa7c19c8b910.tar.gz
cuberite-a06b72c18dde43d8b242ed02261daa7c19c8b910.tar.bz2
cuberite-a06b72c18dde43d8b242ed02261daa7c19c8b910.tar.lz
cuberite-a06b72c18dde43d8b242ed02261daa7c19c8b910.tar.xz
cuberite-a06b72c18dde43d8b242ed02261daa7c19c8b910.tar.zst
cuberite-a06b72c18dde43d8b242ed02261daa7c19c8b910.zip
Diffstat (limited to '')
-rw-r--r--source/WSSAnvil.cpp45
1 files changed, 42 insertions, 3 deletions
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");