summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage/WSSAnvil.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-03-15 14:30:23 +0100
committerMattes D <github@xoft.cz>2015-03-15 14:30:23 +0100
commit0add3d461782b7a89ff614f78f77cbb37476594d (patch)
tree22f4c7f9023efc0554cc0c2b67235b93b8bd82fb /src/WorldStorage/WSSAnvil.cpp
parentMerge pull request #1811 from mc-server/grass (diff)
parentFixed style violations (diff)
downloadcuberite-0add3d461782b7a89ff614f78f77cbb37476594d.tar
cuberite-0add3d461782b7a89ff614f78f77cbb37476594d.tar.gz
cuberite-0add3d461782b7a89ff614f78f77cbb37476594d.tar.bz2
cuberite-0add3d461782b7a89ff614f78f77cbb37476594d.tar.lz
cuberite-0add3d461782b7a89ff614f78f77cbb37476594d.tar.xz
cuberite-0add3d461782b7a89ff614f78f77cbb37476594d.tar.zst
cuberite-0add3d461782b7a89ff614f78f77cbb37476594d.zip
Diffstat (limited to 'src/WorldStorage/WSSAnvil.cpp')
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp72
1 files changed, 35 insertions, 37 deletions
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index cc8b8d3f5..7244bcb73 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -50,6 +50,7 @@
#include "../Entities/ExpOrb.h"
#include "../Entities/HangingEntity.h"
#include "../Entities/ItemFrame.h"
+#include "../Entities/Painting.h"
#include "../Protocol/MojangAPI.h"
#include "Server.h"
@@ -1337,6 +1338,10 @@ void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a
{
LoadPickupFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
}
+ else if (strncmp(a_IDTag, "Painting", a_IDTagLength) == 0)
+ {
+ LoadPaintingFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
+ }
else if (strncmp(a_IDTag, "PrimedTnt", a_IDTagLength) == 0)
{
LoadTNTFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
@@ -1747,52 +1752,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))
);
}
}
@@ -1838,6 +1813,29 @@ void cWSSAnvil::LoadItemFrameFromNBT(cEntityList & a_Entities, const cParsedNBT
+void cWSSAnvil::LoadPaintingFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
+{
+ // Load painting name:
+ int MotiveTag = a_NBT.FindChildByName(a_TagIdx, "Motive");
+ if ((MotiveTag < 0) || (a_NBT.GetType(MotiveTag) != TAG_String))
+ {
+ return;
+ }
+
+ std::unique_ptr<cPainting> Painting(new cPainting(a_NBT.GetString(MotiveTag), BLOCK_FACE_NONE, 0.0, 0.0, 0.0));
+ if (!LoadEntityBaseFromNBT(*Painting.get(), a_NBT, a_TagIdx))
+ {
+ return;
+ }
+
+ LoadHangingFromNBT(*Painting.get(), a_NBT, a_TagIdx);
+ a_Entities.push_back(Painting.release());
+}
+
+
+
+
+
void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
std::unique_ptr<cArrowEntity> Arrow(new cArrowEntity(nullptr, 0, 0, 0, Vector3d(0, 0, 0)));