diff options
author | Howaner <franzi.moos@googlemail.com> | 2014-03-15 00:43:38 +0100 |
---|---|---|
committer | Howaner <franzi.moos@googlemail.com> | 2014-03-15 00:43:38 +0100 |
commit | cf137392885479d4e3f057c64cb078a6025f4b25 (patch) | |
tree | 916678451890d63d2f2a1671e8e339fd27da7a37 /src/WorldStorage | |
parent | Add ExpOrb saving. (diff) | |
download | cuberite-cf137392885479d4e3f057c64cb078a6025f4b25.tar cuberite-cf137392885479d4e3f057c64cb078a6025f4b25.tar.gz cuberite-cf137392885479d4e3f057c64cb078a6025f4b25.tar.bz2 cuberite-cf137392885479d4e3f057c64cb078a6025f4b25.tar.lz cuberite-cf137392885479d4e3f057c64cb078a6025f4b25.tar.xz cuberite-cf137392885479d4e3f057c64cb078a6025f4b25.tar.zst cuberite-cf137392885479d4e3f057c64cb078a6025f4b25.zip |
Diffstat (limited to '')
-rw-r--r-- | src/WorldStorage/NBTChunkSerializer.cpp | 10 | ||||
-rw-r--r-- | src/WorldStorage/WSSAnvil.cpp | 16 |
2 files changed, 20 insertions, 6 deletions
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index fa5547f46..37ebf0610 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -519,8 +519,8 @@ void cNBTChunkSerializer::AddPickupEntity(cPickup * a_Pickup) m_Writer.BeginCompound(""); AddBasicEntity(a_Pickup, "Item"); AddItem(a_Pickup->GetItem(), -1, "Item"); - m_Writer.AddShort("Health", a_Pickup->GetHealth()); - m_Writer.AddShort("Age", a_Pickup->GetAge()); + m_Writer.AddShort("Health", (Int16)(unsigned char)a_Pickup->GetHealth()); + m_Writer.AddShort("Age", (Int16)a_Pickup->GetAge()); m_Writer.EndCompound(); } @@ -601,9 +601,9 @@ void cNBTChunkSerializer::AddExpOrbEntity(cExpOrb* a_ExpOrb) { m_Writer.BeginCompound(""); AddBasicEntity(a_ExpOrb, "XPOrb"); - m_Writer.AddShort("Health", (short)(unsigned char)a_ExpOrb->GetHealth()); - m_Writer.AddShort("Age", (short)a_ExpOrb->GetAge()); - m_Writer.AddShort("Value", (short)a_ExpOrb->GetReward()); + m_Writer.AddShort("Health", (Int16)(unsigned char)a_ExpOrb->GetHealth()); + m_Writer.AddShort("Age", (Int16)a_ExpOrb->GetAge()); + m_Writer.AddShort("Value", (Int16)a_ExpOrb->GetReward()); m_Writer.EndCompound(); } diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index c180f715f..bb0a831b3 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -1383,6 +1383,7 @@ void cWSSAnvil::LoadMinecartHFromNBT(cEntityList & a_Entities, const cParsedNBT void cWSSAnvil::LoadPickupFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { + // Load item: int ItemTag = a_NBT.FindChildByName(a_TagIdx, "Item"); if ((ItemTag < 0) || (a_NBT.GetType(ItemTag) != TAG_Compound)) { @@ -1393,13 +1394,26 @@ void cWSSAnvil::LoadPickupFromNBT(cEntityList & a_Entities, const cParsedNBT & a { return; } + std::auto_ptr<cPickup> Pickup(new cPickup(0, 0, 0, Item, false)); // Pickup delay doesn't matter, just say false if (!LoadEntityBaseFromNBT(*Pickup.get(), a_NBT, a_TagIdx)) { return; } - // TODO: Add health and age + // Load health: + int Health = a_NBT.FindChildByName(a_TagIdx, "Health"); + if (Health > 0) + { + Pickup->SetHealth((int) (a_NBT.GetShort(Health) & 0xFF)); + } + + // Load age: + int Age = a_NBT.FindChildByName(a_TagIdx, "Age"); + if (Age > 0) + { + Pickup->SetAge(a_NBT.GetShort(Age)); + } a_Entities.push_back(Pickup.release()); } |