summaryrefslogtreecommitdiffstats
path: root/source/WorldStorage/NBTChunkSerializer.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-10 21:52:03 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-04-10 21:52:03 +0200
commitcc26f1646308a71ea78f0656efa670915e5e7345 (patch)
tree99b380f0d6466d4f67d792a6bd66b6dc87b80f02 /source/WorldStorage/NBTChunkSerializer.cpp
parentFixed Windows Release build (diff)
downloadcuberite-cc26f1646308a71ea78f0656efa670915e5e7345.tar
cuberite-cc26f1646308a71ea78f0656efa670915e5e7345.tar.gz
cuberite-cc26f1646308a71ea78f0656efa670915e5e7345.tar.bz2
cuberite-cc26f1646308a71ea78f0656efa670915e5e7345.tar.lz
cuberite-cc26f1646308a71ea78f0656efa670915e5e7345.tar.xz
cuberite-cc26f1646308a71ea78f0656efa670915e5e7345.tar.zst
cuberite-cc26f1646308a71ea78f0656efa670915e5e7345.zip
Diffstat (limited to 'source/WorldStorage/NBTChunkSerializer.cpp')
-rw-r--r--source/WorldStorage/NBTChunkSerializer.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/source/WorldStorage/NBTChunkSerializer.cpp b/source/WorldStorage/NBTChunkSerializer.cpp
index 992fa7f69..e033bfb9b 100644
--- a/source/WorldStorage/NBTChunkSerializer.cpp
+++ b/source/WorldStorage/NBTChunkSerializer.cpp
@@ -11,7 +11,7 @@
#include "../SignEntity.h"
#include "../NoteEntity.h"
#include "../JukeboxEntity.h"
-#include "../Item.h"
+#include "../ItemGrid.h"
#include "../StringCompression.h"
#include "../Entity.h"
#include "../OSSupport/MakeDir.h"
@@ -74,6 +74,24 @@ void cNBTChunkSerializer::AddItem(const cItem & a_Item, int a_Slot, const AStrin
+void cNBTChunkSerializer::AddItemGrid(const cItemGrid & a_Grid, int a_BeginSlotNum)
+{
+ int NumSlots = a_Grid.GetNumSlots();
+ for (int i = 0; i < NumSlots; i++)
+ {
+ const cItem & Item = a_Grid.GetItem(i);
+ if (Item.IsEmpty())
+ {
+ continue;
+ }
+ AddItem(Item, i + a_BeginSlotNum);
+ } // for i - chest slots[]
+}
+
+
+
+
+
void cNBTChunkSerializer::AddBasicTileEntity(cBlockEntity * a_Entity, const char * a_EntityTypeID)
{
m_Writer.AddInt ("x", a_Entity->GetPosX());
@@ -91,15 +109,7 @@ void cNBTChunkSerializer::AddChestEntity(cChestEntity * a_Entity)
m_Writer.BeginCompound("");
AddBasicTileEntity(a_Entity, "Chest");
m_Writer.BeginList("Items", TAG_Compound);
- for (int i = 0; i < cChestEntity::c_ChestHeight * cChestEntity::c_ChestWidth; i++)
- {
- const cItem * Item = a_Entity->GetSlot(i);
- if ((Item == NULL) || Item->IsEmpty())
- {
- continue;
- }
- AddItem(*Item, i);
- } // for i - chest slots[]
+ AddItemGrid(a_Entity->GetContents());
m_Writer.EndList();
m_Writer.EndCompound();
}