summaryrefslogtreecommitdiffstats
path: root/source/WorldStorage/WSSAnvil.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-10-21 09:46:28 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-10-21 09:46:28 +0200
commit3f9e876d70851ed0333a3fdc57d883f040e92d8b (patch)
tree789155746561aed3b04818ed4221f40fa42e77fd /source/WorldStorage/WSSAnvil.cpp
parentDouble chests are now working, and with sound. (FS #69) (diff)
downloadcuberite-3f9e876d70851ed0333a3fdc57d883f040e92d8b.tar
cuberite-3f9e876d70851ed0333a3fdc57d883f040e92d8b.tar.gz
cuberite-3f9e876d70851ed0333a3fdc57d883f040e92d8b.tar.bz2
cuberite-3f9e876d70851ed0333a3fdc57d883f040e92d8b.tar.lz
cuberite-3f9e876d70851ed0333a3fdc57d883f040e92d8b.tar.xz
cuberite-3f9e876d70851ed0333a3fdc57d883f040e92d8b.tar.zst
cuberite-3f9e876d70851ed0333a3fdc57d883f040e92d8b.zip
Diffstat (limited to 'source/WorldStorage/WSSAnvil.cpp')
-rw-r--r--source/WorldStorage/WSSAnvil.cpp42
1 files changed, 38 insertions, 4 deletions
diff --git a/source/WorldStorage/WSSAnvil.cpp b/source/WorldStorage/WSSAnvil.cpp
index 2036da92d..ded7e4327 100644
--- a/source/WorldStorage/WSSAnvil.cpp
+++ b/source/WorldStorage/WSSAnvil.cpp
@@ -12,6 +12,7 @@
#include "../FurnaceEntity.h"
#include "../SignEntity.h"
#include "../NoteEntity.h"
+#include "../JukeboxEntity.h"
#include "../Item.h"
#include "../StringCompression.h"
#include "../Entity.h"
@@ -156,6 +157,13 @@ protected:
m_Writer.EndCompound();
}
+ void AddJukeboxEntity(cJukeboxEntity * a_Jukebox)
+ {
+ m_Writer.BeginCompound("");
+ AddBasicTileEntity(a_Jukebox, "RecordPlayer");
+ m_Writer.AddInt("Record", a_Jukebox->GetRecord());
+ m_Writer.EndCompound();
+ }
virtual bool LightIsValid(bool a_IsLightValid) override
{
@@ -189,11 +197,12 @@ 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;
- case E_BLOCK_NOTE_BLOCK: AddNoteEntity ((cNoteEntity *) a_Entity); break;
+ case E_BLOCK_WALLSIGN: AddSignEntity ((cSignEntity *) a_Entity); break;
+ case E_BLOCK_NOTE_BLOCK: AddNoteEntity ((cNoteEntity *) a_Entity); break;
+ case E_BLOCK_JUKEBOX: AddJukeboxEntity((cJukeboxEntity *)a_Entity); break;
default:
{
ASSERT(!"Unhandled block entity saved into Anvil");
@@ -662,6 +671,10 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, con
{
LoadNoteFromNBT(a_BlockEntities, a_NBT, Child);
}
+ else if (strncmp(a_NBT.GetData(sID), "RecordPlayer", a_NBT.GetDataLength(sID)) == 0)
+ {
+ LoadJukeboxFromNBT(a_BlockEntities, a_NBT, Child);
+ }
// TODO: Other block entities
} // for Child - tag children
}
@@ -844,6 +857,27 @@ void cWSSAnvil::LoadNoteFromNBT(cBlockEntityList & a_BlockEntities, const cParse
+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))
+ {
+ return;
+ }
+ std::auto_ptr<cJukeboxEntity> Jukebox(new cJukeboxEntity(x, y, z, m_World));
+ int Record = a_NBT.FindChildByName(a_TagIdx, "Record");
+ if (Record >= 0)
+ {
+ Jukebox->SetRecord(a_NBT.GetInt(Record));
+ }
+ a_BlockEntities.push_back(Jukebox.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");