diff options
Diffstat (limited to '')
-rw-r--r-- | src/WorldStorage/NBTChunkSerializer.cpp | 22 | ||||
-rwxr-xr-x | src/WorldStorage/WSSAnvil.cpp | 44 |
2 files changed, 11 insertions, 55 deletions
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index c87397542..4f78dd245 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -726,24 +726,10 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile) void cNBTChunkSerializer::AddHangingEntity(cHangingEntity * a_Hanging) { - m_Writer.AddInt("TileX", a_Hanging->GetBlockX()); - m_Writer.AddInt("TileY", a_Hanging->GetBlockY()); - m_Writer.AddInt("TileZ", a_Hanging->GetBlockZ()); - switch (a_Hanging->GetFacing()) - { - case BLOCK_FACE_XM: m_Writer.AddByte("Facing", 1); break; - case BLOCK_FACE_XP: m_Writer.AddByte("Facing", 3); break; - case BLOCK_FACE_ZM: m_Writer.AddByte("Facing", 2); break; - case BLOCK_FACE_ZP: m_Writer.AddByte("Facing", 0); break; - - case BLOCK_FACE_YM: - case BLOCK_FACE_YP: - case BLOCK_FACE_NONE: - { - // These directions are invalid, but they may have been previously loaded, so keep them. - break; - } - } + m_Writer.AddInt("TileX", FloorC(a_Hanging->GetPosX())); + m_Writer.AddInt("TileY", FloorC(a_Hanging->GetPosY())); + m_Writer.AddInt("TileZ", FloorC(a_Hanging->GetPosZ())); + m_Writer.AddByte("Facing", a_Hanging->GetProtocolFacing()); } diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index cc8b8d3f5..0aa26834c 100755 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -1747,52 +1747,22 @@ void cWSSAnvil::LoadHangingFromNBT(cHangingEntity & a_Hanging, const cParsedNBT { // "Facing" tag is the prime source of the Facing; if not available, translate from older "Direction" or "Dir" int Facing = a_NBT.FindChildByName(a_TagIdx, "Facing"); - if (Facing > 0) + if (Facing < 0) { - Facing = (int)a_NBT.GetByte(Facing); - if ((Facing >= 2) && (Facing <= 5)) - { - a_Hanging.SetFacing(static_cast<eBlockFace>(Facing)); - } - } - else - { - Facing = a_NBT.FindChildByName(a_TagIdx, "Direction"); - if (Facing > 0) - { - switch ((int)a_NBT.GetByte(Facing)) - { - case 0: a_Hanging.SetFacing(BLOCK_FACE_ZM); break; - case 1: a_Hanging.SetFacing(BLOCK_FACE_XM); break; - case 2: a_Hanging.SetFacing(BLOCK_FACE_ZP); break; - case 3: a_Hanging.SetFacing(BLOCK_FACE_XP); break; - } - } - else - { - Facing = a_NBT.FindChildByName(a_TagIdx, "Dir"); // Has values 0 and 2 swapped - if (Facing > 0) - { - switch ((int)a_NBT.GetByte(Facing)) - { - case 0: a_Hanging.SetFacing(BLOCK_FACE_ZP); break; - case 1: a_Hanging.SetFacing(BLOCK_FACE_XM); break; - case 2: a_Hanging.SetFacing(BLOCK_FACE_ZM); break; - case 3: a_Hanging.SetFacing(BLOCK_FACE_XP); break; - } - } - } + return; } + a_Hanging.SetProtocolFacing(a_NBT.GetByte(Facing)); + int TileX = a_NBT.FindChildByName(a_TagIdx, "TileX"); int TileY = a_NBT.FindChildByName(a_TagIdx, "TileY"); int TileZ = a_NBT.FindChildByName(a_TagIdx, "TileZ"); if ((TileX > 0) && (TileY > 0) && (TileZ > 0)) { a_Hanging.SetPosition( - (double)a_NBT.GetInt(TileX), - (double)a_NBT.GetInt(TileY), - (double)a_NBT.GetInt(TileZ) + static_cast<double>(a_NBT.GetInt(TileX)), + static_cast<double>(a_NBT.GetInt(TileY)), + static_cast<double>(a_NBT.GetInt(TileZ)) ); } } |