diff options
author | Mattes D <github@xoft.cz> | 2014-10-21 22:02:30 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-10-21 22:02:30 +0200 |
commit | a42fa071bc3ac1615e7c9b9d59fb4c882cc6097d (patch) | |
tree | ecd4214f8c2c11abb7bc0ff87cef26dd79ee6063 /src/WorldStorage/WSSAnvil.cpp | |
parent | Fixed trailing whitespace. (diff) | |
download | cuberite-a42fa071bc3ac1615e7c9b9d59fb4c882cc6097d.tar cuberite-a42fa071bc3ac1615e7c9b9d59fb4c882cc6097d.tar.gz cuberite-a42fa071bc3ac1615e7c9b9d59fb4c882cc6097d.tar.bz2 cuberite-a42fa071bc3ac1615e7c9b9d59fb4c882cc6097d.tar.lz cuberite-a42fa071bc3ac1615e7c9b9d59fb4c882cc6097d.tar.xz cuberite-a42fa071bc3ac1615e7c9b9d59fb4c882cc6097d.tar.zst cuberite-a42fa071bc3ac1615e7c9b9d59fb4c882cc6097d.zip |
Diffstat (limited to '')
-rw-r--r-- | src/WorldStorage/WSSAnvil.cpp | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 092b9514c..eba21c659 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -1660,30 +1660,41 @@ void cWSSAnvil::LoadExpOrbFromNBT(cEntityList & a_Entities, const cParsedNBT & a void cWSSAnvil::LoadHangingFromNBT(cHangingEntity & a_Hanging, const cParsedNBT & a_NBT, int a_TagIdx) { - int Direction = a_NBT.FindChildByName(a_TagIdx, "Direction"); - if (Direction > 0) + // "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) { - Direction = (int)a_NBT.GetByte(Direction); - if ((Direction < 2) || (Direction > 5)) + Facing = (int)a_NBT.GetByte(Facing); + if ((Facing >= 2) && (Facing <= 5)) { - a_Hanging.SetDirection(BLOCK_FACE_NORTH); - } - else - { - a_Hanging.SetDirection(static_cast<eBlockFace>(Direction)); + a_Hanging.SetFacing(static_cast<eBlockFace>(Facing)); } } else { - Direction = a_NBT.FindChildByName(a_TagIdx, "Dir"); - if (Direction > 0) + 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 { - switch ((int)a_NBT.GetByte(Direction)) + Facing = a_NBT.FindChildByName(a_TagIdx, "Dir"); // Has values 0 and 2 swapped + if (Facing > 0) { - case 0: a_Hanging.SetDirection(BLOCK_FACE_NORTH); break; - case 1: a_Hanging.SetDirection(BLOCK_FACE_TOP); break; - case 2: a_Hanging.SetDirection(BLOCK_FACE_BOTTOM); break; - case 3: a_Hanging.SetDirection(BLOCK_FACE_SOUTH); break; + 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; + } } } } |