diff options
author | Mattes D <github@xoft.cz> | 2014-02-19 22:12:38 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-02-19 22:12:38 +0100 |
commit | 87db4b6a904f2877919446b8219d659848da89e8 (patch) | |
tree | 617bf18a768a493c2cd428297168f57df0901c26 /src/WorldStorage/WSSAnvil.cpp | |
parent | Merge pull request #694 from mc-server/itemframes (diff) | |
parent | Rename SkullEntity to MobHeadEntity (diff) | |
download | cuberite-87db4b6a904f2877919446b8219d659848da89e8.tar cuberite-87db4b6a904f2877919446b8219d659848da89e8.tar.gz cuberite-87db4b6a904f2877919446b8219d659848da89e8.tar.bz2 cuberite-87db4b6a904f2877919446b8219d659848da89e8.tar.lz cuberite-87db4b6a904f2877919446b8219d659848da89e8.tar.xz cuberite-87db4b6a904f2877919446b8219d659848da89e8.tar.zst cuberite-87db4b6a904f2877919446b8219d659848da89e8.zip |
Diffstat (limited to 'src/WorldStorage/WSSAnvil.cpp')
-rw-r--r-- | src/WorldStorage/WSSAnvil.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index e95813a3c..d4490c7fe 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -24,6 +24,7 @@ #include "../BlockEntities/JukeboxEntity.h" #include "../BlockEntities/NoteEntity.h" #include "../BlockEntities/SignEntity.h" +#include "../BlockEntities/MobHeadEntity.h" #include "../Mobs/Monster.h" @@ -597,6 +598,10 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, con { LoadSignFromNBT(a_BlockEntities, a_NBT, Child); } + else if (strncmp(a_NBT.GetData(sID), "Skull", a_NBT.GetDataLength(sID)) == 0) + { + LoadMobHeadFromNBT(a_BlockEntities, a_NBT, Child); + } else if (strncmp(a_NBT.GetData(sID), "Trap", a_NBT.GetDataLength(sID)) == 0) { LoadDispenserFromNBT(a_BlockEntities, a_NBT, Child); @@ -927,6 +932,41 @@ void cWSSAnvil::LoadSignFromNBT(cBlockEntityList & a_BlockEntities, const cParse +void cWSSAnvil::LoadMobHeadFromNBT(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<cMobHeadEntity> MobHead(new cMobHeadEntity(x, y, z, m_World)); + + int currentLine = a_NBT.FindChildByName(a_TagIdx, "SkullType"); + if (currentLine >= 0) + { + MobHead->SetType(static_cast<eMobHeadType>(a_NBT.GetByte(currentLine))); + } + + currentLine = a_NBT.FindChildByName(a_TagIdx, "Rot"); + if (currentLine >= 0) + { + MobHead->SetRotation(static_cast<eMobHeadRotation>(a_NBT.GetByte(currentLine))); + } + + currentLine = a_NBT.FindChildByName(a_TagIdx, "ExtraType"); + if (currentLine >= 0) + { + MobHead->SetOwner(a_NBT.GetString(currentLine)); + } + + a_BlockEntities.push_back(MobHead.release()); +} + + + + + void cWSSAnvil::LoadCommandBlockFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx) { ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound); |