summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage/WSSAnvil.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 77d1e46b8..7aa3eb0cd 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -50,10 +50,12 @@
#include "../Entities/ExpOrb.h"
#include "../Entities/HangingEntity.h"
#include "../Entities/ItemFrame.h"
+#include "../Entities/LeashKnot.h"
#include "../Entities/Painting.h"
#include "../Protocol/MojangAPI.h"
#include "Server.h"
+#include "BoundingBox.h"
@@ -1540,6 +1542,8 @@ void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a
{ "minecraft:xp_orb", &cWSSAnvil::LoadExpOrbFromNBT },
{ "ItemFrame", &cWSSAnvil::LoadItemFrameFromNBT },
{ "minecraft:item_frame", &cWSSAnvil::LoadItemFrameFromNBT },
+ { "LeashKnot", &cWSSAnvil::LoadLeashKnotFromNBT },
+ { "minecraft:leash_knot", &cWSSAnvil::LoadLeashKnotFromNBT },
{ "Arrow", &cWSSAnvil::LoadArrowFromNBT },
{ "minecraft:arrow", &cWSSAnvil::LoadArrowFromNBT },
{ "SplashPotion", &cWSSAnvil::LoadSplashPotionFromNBT },
@@ -1958,6 +1962,24 @@ void cWSSAnvil::LoadItemFrameFromNBT(cEntityList & a_Entities, const cParsedNBT
+void cWSSAnvil::LoadLeashKnotFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
+{
+ auto LeashKnot = cpp14::make_unique<cLeashKnot>(BLOCK_FACE_NONE, 0.0, 0.0, 0.0);
+
+ if (!LoadEntityBaseFromNBT(*LeashKnot.get(), a_NBT, a_TagIdx))
+ {
+ return;
+ }
+
+ LoadHangingFromNBT(*LeashKnot.get(), a_NBT, a_TagIdx);
+
+ a_Entities.emplace_back(std::move(LeashKnot));
+}
+
+
+
+
+
void cWSSAnvil::LoadPaintingFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
// Load painting name:
@@ -3182,6 +3204,13 @@ bool cWSSAnvil::LoadMonsterBaseFromNBT(cMonster & a_Monster, const cParsedNBT &
a_Monster.SetCustomNameAlwaysVisible(CustomNameVisible);
}
+ // Leashed to a knot
+ int LeashedIdx = a_NBT.FindChildByName(a_TagIdx, "Leashed");
+ if ((LeashedIdx >= 0) && a_NBT.GetByte(LeashedIdx))
+ {
+ LoadLeashToPosition(a_Monster, a_NBT, a_TagIdx);
+ }
+
return true;
}
@@ -3189,6 +3218,54 @@ bool cWSSAnvil::LoadMonsterBaseFromNBT(cMonster & a_Monster, const cParsedNBT &
+void cWSSAnvil::LoadLeashToPosition(cMonster & a_Monster, const cParsedNBT & a_NBT, int a_TagIdx)
+{
+ int LeashIdx = a_NBT.FindChildByName(a_TagIdx, "Leash");
+ if (LeashIdx < 0)
+ {
+ return;
+ }
+
+ double PosX = 0.0, PosY = 0.0, PosZ = 0.0;
+ bool KnotPosPresent = true;
+ int LeashDataLine = a_NBT.FindChildByName(LeashIdx, "X");
+ if (LeashDataLine >= 0)
+ {
+ PosX = a_NBT.GetDouble(LeashDataLine);
+ }
+ else
+ {
+ KnotPosPresent = false;
+ }
+ LeashDataLine = a_NBT.FindChildByName(LeashIdx, "Y");
+ if (LeashDataLine >= 0)
+ {
+ PosY = a_NBT.GetDouble(LeashDataLine);
+ }
+ else
+ {
+ KnotPosPresent = false;
+ }
+ LeashDataLine = a_NBT.FindChildByName(LeashIdx, "Z");
+ if (LeashDataLine >= 0)
+ {
+ PosZ = a_NBT.GetDouble(LeashDataLine);
+ }
+ else
+ {
+ KnotPosPresent = false;
+ }
+ if (KnotPosPresent)
+ {
+ // Set leash pos for the mob
+ a_Monster.SetLeashToPos(new Vector3d(PosX, PosY, PosZ));
+ }
+}
+
+
+
+
+
bool cWSSAnvil::LoadProjectileBaseFromNBT(cProjectileEntity & a_Entity, const cParsedNBT & a_NBT, int a_TagIdx)
{
if (!LoadEntityBaseFromNBT(a_Entity, a_NBT, a_TagIdx))