diff options
author | Pablo Beltrán <spekdrum@gmail.com> | 2017-08-21 10:46:41 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2017-08-21 10:46:41 +0200 |
commit | b18f6637b6c58db20353cd3e77584b646ab36b5c (patch) | |
tree | 77b1dcf42aec23ef4aa64a04c906282c5f61ba19 /src/WorldStorage/NBTChunkSerializer.cpp | |
parent | Changed MoveToWorld to ScheduleMoveToWorld in cPlayer::Respawn (#3922) (diff) | |
download | cuberite-b18f6637b6c58db20353cd3e77584b646ab36b5c.tar cuberite-b18f6637b6c58db20353cd3e77584b646ab36b5c.tar.gz cuberite-b18f6637b6c58db20353cd3e77584b646ab36b5c.tar.bz2 cuberite-b18f6637b6c58db20353cd3e77584b646ab36b5c.tar.lz cuberite-b18f6637b6c58db20353cd3e77584b646ab36b5c.tar.xz cuberite-b18f6637b6c58db20353cd3e77584b646ab36b5c.tar.zst cuberite-b18f6637b6c58db20353cd3e77584b646ab36b5c.zip |
Diffstat (limited to 'src/WorldStorage/NBTChunkSerializer.cpp')
-rw-r--r-- | src/WorldStorage/NBTChunkSerializer.cpp | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 480558fa3..62f981eb4 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -37,6 +37,7 @@ #include "../Entities/ExpOrb.h" #include "../Entities/HangingEntity.h" #include "../Entities/ItemFrame.h" +#include "../Entities/LeashKnot.h" #include "../Entities/Painting.h" #include "../Mobs/IncludeAllMonsters.h" @@ -574,6 +575,33 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster) m_Writer.AddByte("CanPickUpLoot", (a_Monster->CanPickUpLoot())? 1 : 0); m_Writer.AddString("CustomName", a_Monster->GetCustomName()); m_Writer.AddByte("CustomNameVisible", static_cast<Byte>(a_Monster->IsCustomNameAlwaysVisible())); + + // Mob was leashed + if (a_Monster->IsLeashed() || (a_Monster->GetLeashToPos() != nullptr)) + { + m_Writer.AddByte("Leashed", 1); + + const Vector3d * LeashedToPos = nullptr; + + if (a_Monster->GetLeashToPos() != nullptr) + { + LeashedToPos = a_Monster->GetLeashToPos(); + } + else if (a_Monster->GetLeashedTo()->IsLeashKnot()) + { + LeashedToPos = & a_Monster->GetLeashedTo()->GetPosition(); + } + + if (LeashedToPos != nullptr) + { + m_Writer.BeginCompound("Leash"); + m_Writer.AddDouble("X", LeashedToPos->x); + m_Writer.AddDouble("Y", LeashedToPos->y); + m_Writer.AddDouble("Z", LeashedToPos->z); + m_Writer.EndCompound(); + } + } + switch (a_Monster->GetMobType()) { case mtBat: @@ -850,8 +878,13 @@ void cNBTChunkSerializer::AddItemFrameEntity(cItemFrame * a_ItemFrame) m_Writer.EndCompound(); } - - +void cNBTChunkSerializer::AddLeashKnotEntity(cLeashKnot * a_LeashKnot) +{ + m_Writer.BeginCompound(""); + AddBasicEntity(a_LeashKnot, "LeashKnot"); + AddHangingEntity(a_LeashKnot); + m_Writer.EndCompound(); +} void cNBTChunkSerializer::AddPaintingEntity(cPainting * a_Painting) @@ -965,6 +998,7 @@ void cNBTChunkSerializer::Entity(cEntity * a_Entity) case cEntity::etTNT: AddTNTEntity (reinterpret_cast<cTNTEntity *> (a_Entity)); break; case cEntity::etExpOrb: AddExpOrbEntity (reinterpret_cast<cExpOrb *> (a_Entity)); break; case cEntity::etItemFrame: AddItemFrameEntity (reinterpret_cast<cItemFrame *> (a_Entity)); break; + case cEntity::etLeashKnot: AddLeashKnotEntity (reinterpret_cast<cLeashKnot *> (a_Entity)); break; case cEntity::etPainting: AddPaintingEntity (reinterpret_cast<cPainting *> (a_Entity)); break; case cEntity::etPlayer: return; // Players aren't saved into the world case cEntity::etFloater: return; // Floaters aren't saved either |