diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-09 21:08:39 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-09 21:08:39 +0100 |
commit | e694893edf835d426eba8e1da042f7a65ec06c1e (patch) | |
tree | 68d75f171b2a95b923421199781f8b2a1057d120 /source/WorldStorage/WSSAnvil.cpp | |
parent | Pickups are now being saved into Anvil. (diff) | |
download | cuberite-e694893edf835d426eba8e1da042f7a65ec06c1e.tar cuberite-e694893edf835d426eba8e1da042f7a65ec06c1e.tar.gz cuberite-e694893edf835d426eba8e1da042f7a65ec06c1e.tar.bz2 cuberite-e694893edf835d426eba8e1da042f7a65ec06c1e.tar.lz cuberite-e694893edf835d426eba8e1da042f7a65ec06c1e.tar.xz cuberite-e694893edf835d426eba8e1da042f7a65ec06c1e.tar.zst cuberite-e694893edf835d426eba8e1da042f7a65ec06c1e.zip |
Diffstat (limited to 'source/WorldStorage/WSSAnvil.cpp')
-rw-r--r-- | source/WorldStorage/WSSAnvil.cpp | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/source/WorldStorage/WSSAnvil.cpp b/source/WorldStorage/WSSAnvil.cpp index de9a3c3ae..a7db674ff 100644 --- a/source/WorldStorage/WSSAnvil.cpp +++ b/source/WorldStorage/WSSAnvil.cpp @@ -861,7 +861,12 @@ void cWSSAnvil::LoadFallingBlockFromNBT(cEntityList & a_Entities, const cParsedN void cWSSAnvil::LoadMinecartRFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { - // TODO + std::auto_ptr<cEmptyMinecart> Minecart(new cEmptyMinecart(0, 0, 0)); + if (!LoadEntityBaseFromNBT(*Minecart.get(), a_NBT, a_TagIdx)) + { + return; + } + a_Entities.push_back(Minecart.release()); } @@ -870,7 +875,30 @@ void cWSSAnvil::LoadMinecartRFromNBT(cEntityList & a_Entities, const cParsedNBT void cWSSAnvil::LoadMinecartCFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { - // TODO + int Items = a_NBT.FindChildByName(a_TagIdx, "Items"); + if ((Items < 0) || (a_NBT.GetType(Items) != TAG_List)) + { + return; // Make it an empty chest - the chunk loader will provide an empty cChestEntity for this + } + std::auto_ptr<cMinecartWithChest> Minecart(new cMinecartWithChest(0, 0, 0)); + if (!LoadEntityBaseFromNBT(*Minecart.get(), a_NBT, a_TagIdx)) + { + return; + } + for (int Child = a_NBT.GetFirstChild(Items); Child != -1; Child = a_NBT.GetNextSibling(Child)) + { + int Slot = a_NBT.FindChildByName(Child, "Slot"); + if ((Slot < 0) || (a_NBT.GetType(Slot) != TAG_Byte)) + { + continue; + } + cItem Item; + if (LoadItemFromNBT(Item, a_NBT, Child)) + { + Minecart->SetSlot(a_NBT.GetByte(Slot), Item); + } + } // for itr - ItemDefs[] + a_Entities.push_back(Minecart.release()); } @@ -879,7 +907,15 @@ void cWSSAnvil::LoadMinecartCFromNBT(cEntityList & a_Entities, const cParsedNBT void cWSSAnvil::LoadMinecartFFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { - // TODO + std::auto_ptr<cMinecartWithFurnace> Minecart(new cMinecartWithFurnace(0, 0, 0)); + if (!LoadEntityBaseFromNBT(*Minecart.get(), a_NBT, a_TagIdx)) + { + return; + } + + // TODO: Load the Push and Fuel tags + + a_Entities.push_back(Minecart.release()); } |