diff options
author | Howaner <franzi.moos@googlemail.com> | 2014-07-30 22:50:34 +0200 |
---|---|---|
committer | Howaner <franzi.moos@googlemail.com> | 2014-07-30 22:50:34 +0200 |
commit | dcd226d9040409dec41c8f1f8909262946308ab0 (patch) | |
tree | 79479a67d634ae8a622f247acc283d2ea57888c6 /src/WorldStorage/WSSAnvil.cpp | |
parent | Added beacon documentation. (diff) | |
download | cuberite-dcd226d9040409dec41c8f1f8909262946308ab0.tar cuberite-dcd226d9040409dec41c8f1f8909262946308ab0.tar.gz cuberite-dcd226d9040409dec41c8f1f8909262946308ab0.tar.bz2 cuberite-dcd226d9040409dec41c8f1f8909262946308ab0.tar.lz cuberite-dcd226d9040409dec41c8f1f8909262946308ab0.tar.xz cuberite-dcd226d9040409dec41c8f1f8909262946308ab0.tar.zst cuberite-dcd226d9040409dec41c8f1f8909262946308ab0.zip |
Diffstat (limited to '')
-rw-r--r-- | src/WorldStorage/WSSAnvil.cpp | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 71ff3ef99..5a1972fd4 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -16,6 +16,7 @@ #include "../StringCompression.h" #include "../SetChunkData.h" +#include "../BlockEntities/BeaconEntity.h" #include "../BlockEntities/ChestEntity.h" #include "../BlockEntities/CommandBlockEntity.h" #include "../BlockEntities/DispenserEntity.h" @@ -582,7 +583,11 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, con { continue; } - if (strncmp(a_NBT.GetData(sID), "Chest", a_NBT.GetDataLength(sID)) == 0) + if (strncmp(a_NBT.GetData(sID), "Beacon", a_NBT.GetDataLength(sID)) == 0) + { + LoadBeaconFromNBT(a_BlockEntities, a_NBT, Child); + } + else if (strncmp(a_NBT.GetData(sID), "Chest", a_NBT.GetDataLength(sID)) == 0) { LoadChestFromNBT(a_BlockEntities, a_NBT, Child, E_BLOCK_CHEST); } @@ -746,6 +751,49 @@ void cWSSAnvil::LoadItemGridFromNBT(cItemGrid & a_ItemGrid, const cParsedNBT & a +void cWSSAnvil::LoadBeaconFromNBT(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<cBeaconEntity> Beacon(new cBeaconEntity(x, y, z, m_World)); + + int CurrentLine = a_NBT.FindChildByName(a_TagIdx, "Levels"); + if (CurrentLine >= 0) + { + Beacon->SetBeaconLevel((char)a_NBT.GetInt(CurrentLine)); + } + + CurrentLine = a_NBT.FindChildByName(a_TagIdx, "Primary"); + if (CurrentLine >= 0) + { + Beacon->SelectPrimaryPotion((cEntityEffect::eType)a_NBT.GetInt(CurrentLine)); + } + + CurrentLine = a_NBT.FindChildByName(a_TagIdx, "Secondary"); + if (CurrentLine >= 0) + { + Beacon->SelectSecondaryPotion((cEntityEffect::eType)a_NBT.GetInt(CurrentLine)); + } + + // We are better than mojang, we load/save the beacon inventory! + int Items = a_NBT.FindChildByName(a_TagIdx, "Items"); + if ((Items >= 0) && (a_NBT.GetType(Items) == TAG_List)) + { + LoadItemGridFromNBT(Beacon->GetContents(), a_NBT, Items); + } + + a_BlockEntities.push_back(Beacon.release()); +} + + + + + void cWSSAnvil::LoadChestFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx, BLOCKTYPE a_ChestType) { ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound); |