summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage/WSSAnvil.cpp
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-09-25 19:01:44 +0200
committerHowaner <franzi.moos@googlemail.com>2014-09-25 19:01:44 +0200
commit7cdcf0a8833b56a98d60a87a341607fed988cac7 (patch)
tree42631bf20d000587139067926e464a7880785a9b /src/WorldStorage/WSSAnvil.cpp
parentUse the json writer to write sign texts. (diff)
downloadcuberite-7cdcf0a8833b56a98d60a87a341607fed988cac7.tar
cuberite-7cdcf0a8833b56a98d60a87a341607fed988cac7.tar.gz
cuberite-7cdcf0a8833b56a98d60a87a341607fed988cac7.tar.bz2
cuberite-7cdcf0a8833b56a98d60a87a341607fed988cac7.tar.lz
cuberite-7cdcf0a8833b56a98d60a87a341607fed988cac7.tar.xz
cuberite-7cdcf0a8833b56a98d60a87a341607fed988cac7.tar.zst
cuberite-7cdcf0a8833b56a98d60a87a341607fed988cac7.zip
Diffstat (limited to 'src/WorldStorage/WSSAnvil.cpp')
-rw-r--r--src/WorldStorage/WSSAnvil.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 7a9490cd4..092b9514c 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -1752,7 +1752,7 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
// Load pickup state:
int PickupIdx = a_NBT.FindChildByName(a_TagIdx, "pickup");
- if (PickupIdx > 0)
+ if ((PickupIdx > 0) && (a_NBT.GetType(PickupIdx) == TAG_Byte))
{
Arrow->SetPickupState((cArrowEntity::ePickupState)a_NBT.GetByte(PickupIdx));
}
@@ -1760,7 +1760,7 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
{
// Try the older "player" tag:
int PlayerIdx = a_NBT.FindChildByName(a_TagIdx, "player");
- if (PlayerIdx > 0)
+ if ((PlayerIdx > 0) && (a_NBT.GetType(PlayerIdx) == TAG_Byte))
{
Arrow->SetPickupState((a_NBT.GetByte(PlayerIdx) == 0) ? cArrowEntity::psNoPickup : cArrowEntity::psInSurvivalOrCreative);
}
@@ -1768,7 +1768,7 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
// Load damage:
int DamageIdx = a_NBT.FindChildByName(a_TagIdx, "damage");
- if (DamageIdx > 0)
+ if ((DamageIdx > 0) && (a_NBT.GetType(DamageIdx) == TAG_Double))
{
Arrow->SetDamageCoeff(a_NBT.GetDouble(DamageIdx));
}
@@ -1779,7 +1779,24 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
int InBlockZIdx = a_NBT.FindChildByName(a_TagIdx, "zTile");
if ((InBlockXIdx > 0) && (InBlockYIdx > 0) && (InBlockZIdx > 0))
{
- Arrow->SetBlockHit(Vector3i(a_NBT.GetInt(InBlockXIdx), a_NBT.GetInt(InBlockYIdx), a_NBT.GetInt(InBlockZIdx)));
+ if (a_NBT.GetType(InBlockXIdx) == a_NBT.GetType(InBlockYIdx) == a_NBT.GetType(InBlockZIdx))
+ {
+ switch (a_NBT.GetType(InBlockXIdx))
+ {
+ case TAG_Int:
+ {
+ // Old MCS code used this, keep reading it for compatibility reasons:
+ Arrow->SetBlockHit(Vector3i(a_NBT.GetInt(InBlockXIdx), a_NBT.GetInt(InBlockYIdx), a_NBT.GetInt(InBlockZIdx)));
+ break;
+ }
+ case TAG_Short:
+ {
+ // Vanilla uses this
+ Arrow->SetBlockHit(Vector3i((int)a_NBT.GetShort(InBlockXIdx), (int)a_NBT.GetShort(InBlockYIdx), (int)a_NBT.GetShort(InBlockZIdx)));
+ break;
+ }
+ }
+ }
}
// Store the new arrow in the entities list: