summaryrefslogtreecommitdiffstats
path: root/source/WorldStorage/WSSAnvil.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-13 09:36:43 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-13 09:36:43 +0200
commit03c6bb9f85b929a99df2c800b8ba7d8ef4a8ec43 (patch)
tree8027076867da60f62e52362059717c94084bcfd9 /source/WorldStorage/WSSAnvil.cpp
parentProtectionAreas: Added proper ignored files (diff)
downloadcuberite-03c6bb9f85b929a99df2c800b8ba7d8ef4a8ec43.tar
cuberite-03c6bb9f85b929a99df2c800b8ba7d8ef4a8ec43.tar.gz
cuberite-03c6bb9f85b929a99df2c800b8ba7d8ef4a8ec43.tar.bz2
cuberite-03c6bb9f85b929a99df2c800b8ba7d8ef4a8ec43.tar.lz
cuberite-03c6bb9f85b929a99df2c800b8ba7d8ef4a8ec43.tar.xz
cuberite-03c6bb9f85b929a99df2c800b8ba7d8ef4a8ec43.tar.zst
cuberite-03c6bb9f85b929a99df2c800b8ba7d8ef4a8ec43.zip
Diffstat (limited to 'source/WorldStorage/WSSAnvil.cpp')
-rw-r--r--source/WorldStorage/WSSAnvil.cpp82
1 files changed, 55 insertions, 27 deletions
diff --git a/source/WorldStorage/WSSAnvil.cpp b/source/WorldStorage/WSSAnvil.cpp
index 1b70083c2..43e6dce05 100644
--- a/source/WorldStorage/WSSAnvil.cpp
+++ b/source/WorldStorage/WSSAnvil.cpp
@@ -13,6 +13,7 @@
#include "../BlockEntities/DispenserEntity.h"
#include "../BlockEntities/DropperEntity.h"
#include "../BlockEntities/FurnaceEntity.h"
+#include "../BlockEntities/HopperEntity.h"
#include "../BlockEntities/JukeboxEntity.h"
#include "../BlockEntities/NoteEntity.h"
#include "../BlockEntities/SignEntity.h"
@@ -568,6 +569,10 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, con
{
LoadFurnaceFromNBT(a_BlockEntities, a_NBT, Child);
}
+ else if (strncmp(a_NBT.GetData(sID), "Hopper", a_NBT.GetDataLength(sID)) == 0)
+ {
+ LoadHopperFromNBT(a_BlockEntities, a_NBT, Child);
+ }
else if (strncmp(a_NBT.GetData(sID), "Music", a_NBT.GetDataLength(sID)) == 0)
{
LoadNoteFromNBT(a_BlockEntities, a_NBT, Child);
@@ -721,7 +726,7 @@ void cWSSAnvil::LoadDropperFromNBT(cBlockEntityList & a_BlockEntities, const cPa
int Items = a_NBT.FindChildByName(a_TagIdx, "Items");
if ((Items < 0) || (a_NBT.GetType(Items) != TAG_List))
{
- return; // Make it an empty dispenser - the chunk loader will provide an empty cDispenserEntity for this
+ return; // Make it an empty dropper - the chunk loader will provide an empty cDropperEntity for this
}
std::auto_ptr<cDropperEntity> Dropper(new cDropperEntity(x, y, z, m_World));
LoadItemGridFromNBT(Dropper->GetContents(), a_NBT, Items);
@@ -781,7 +786,7 @@ void cWSSAnvil::LoadFurnaceFromNBT(cBlockEntityList & a_BlockEntities, const cPa
-void cWSSAnvil::LoadSignFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx)
+void cWSSAnvil::LoadHopperFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx)
{
ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound);
int x, y, z;
@@ -789,38 +794,41 @@ void cWSSAnvil::LoadSignFromNBT(cBlockEntityList & a_BlockEntities, const cParse
{
return;
}
- std::auto_ptr<cSignEntity> Sign(new cSignEntity(E_BLOCK_SIGN_POST, x, y, z, m_World));
-
- int currentLine = a_NBT.FindChildByName(a_TagIdx, "Text1");
- if (currentLine >= 0)
+ int Items = a_NBT.FindChildByName(a_TagIdx, "Items");
+ if ((Items < 0) || (a_NBT.GetType(Items) != TAG_List))
{
- Sign->SetLine(0, a_NBT.GetString(currentLine));
+ return; // Make it an empty hopper - the chunk loader will provide an empty cHopperEntity for this
}
+ std::auto_ptr<cHopperEntity> Hopper(new cHopperEntity(x, y, z, m_World));
+ LoadItemGridFromNBT(Hopper->GetContents(), a_NBT, Items);
+ a_BlockEntities.push_back(Hopper.release());
+}
- currentLine = a_NBT.FindChildByName(a_TagIdx, "Text2");
- if (currentLine >= 0)
- {
- Sign->SetLine(1, a_NBT.GetString(currentLine));
- }
- currentLine = a_NBT.FindChildByName(a_TagIdx, "Text3");
- if (currentLine >= 0)
+
+
+
+void cWSSAnvil::LoadJukeboxFromNBT(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))
{
- Sign->SetLine(2, a_NBT.GetString(currentLine));
+ return;
}
-
- currentLine = a_NBT.FindChildByName(a_TagIdx, "Text4");
- if (currentLine >= 0)
+ std::auto_ptr<cJukeboxEntity> Jukebox(new cJukeboxEntity(x, y, z, m_World));
+ int Record = a_NBT.FindChildByName(a_TagIdx, "Record");
+ if (Record >= 0)
{
- Sign->SetLine(3, a_NBT.GetString(currentLine));
+ Jukebox->SetRecord(a_NBT.GetInt(Record));
}
-
- a_BlockEntities.push_back(Sign.release());
+ a_BlockEntities.push_back(Jukebox.release());
}
+
void cWSSAnvil::LoadNoteFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx)
{
ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound);
@@ -842,7 +850,7 @@ void cWSSAnvil::LoadNoteFromNBT(cBlockEntityList & a_BlockEntities, const cParse
-void cWSSAnvil::LoadJukeboxFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx)
+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;
@@ -850,13 +858,33 @@ void cWSSAnvil::LoadJukeboxFromNBT(cBlockEntityList & a_BlockEntities, const cPa
{
return;
}
- std::auto_ptr<cJukeboxEntity> Jukebox(new cJukeboxEntity(x, y, z, m_World));
- int Record = a_NBT.FindChildByName(a_TagIdx, "Record");
- if (Record >= 0)
+ std::auto_ptr<cSignEntity> Sign(new cSignEntity(E_BLOCK_SIGN_POST, x, y, z, m_World));
+
+ int currentLine = a_NBT.FindChildByName(a_TagIdx, "Text1");
+ if (currentLine >= 0)
{
- Jukebox->SetRecord(a_NBT.GetInt(Record));
+ Sign->SetLine(0, a_NBT.GetString(currentLine));
}
- a_BlockEntities.push_back(Jukebox.release());
+
+ currentLine = a_NBT.FindChildByName(a_TagIdx, "Text2");
+ if (currentLine >= 0)
+ {
+ Sign->SetLine(1, a_NBT.GetString(currentLine));
+ }
+
+ currentLine = a_NBT.FindChildByName(a_TagIdx, "Text3");
+ if (currentLine >= 0)
+ {
+ Sign->SetLine(2, a_NBT.GetString(currentLine));
+ }
+
+ currentLine = a_NBT.FindChildByName(a_TagIdx, "Text4");
+ if (currentLine >= 0)
+ {
+ Sign->SetLine(3, a_NBT.GetString(currentLine));
+ }
+
+ a_BlockEntities.push_back(Sign.release());
}