diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-06-04 21:52:54 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-06-04 21:52:54 +0200 |
commit | ea49abd113050eb36fb85ac792cdab0e901b77e6 (patch) | |
tree | ee779c823cf4e48697fc7f175fd4244dfbbe2104 /src/WorldStorage | |
parent | Health of monsters is now saved (diff) | |
download | cuberite-ea49abd113050eb36fb85ac792cdab0e901b77e6.tar cuberite-ea49abd113050eb36fb85ac792cdab0e901b77e6.tar.gz cuberite-ea49abd113050eb36fb85ac792cdab0e901b77e6.tar.bz2 cuberite-ea49abd113050eb36fb85ac792cdab0e901b77e6.tar.lz cuberite-ea49abd113050eb36fb85ac792cdab0e901b77e6.tar.xz cuberite-ea49abd113050eb36fb85ac792cdab0e901b77e6.tar.zst cuberite-ea49abd113050eb36fb85ac792cdab0e901b77e6.zip |
Diffstat (limited to '')
-rw-r--r-- | src/WorldStorage/WSSAnvil.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index f58e876e0..c84763ac2 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -2454,9 +2454,16 @@ bool cWSSAnvil::LoadMonsterBaseFromNBT(cMonster & a_Monster, const cParsedNBT & a_Monster.SetDropChanceChestplate(DropChance[2]); a_Monster.SetDropChanceLeggings(DropChance[3]); a_Monster.SetDropChanceBoots(DropChance[4]); - bool CanPickUpLoot = (a_NBT.GetByte(a_NBT.FindChildByName(a_TagIdx, "CanPickUpLoot")) == 1); - a_Monster.SetCanPickUpLoot(CanPickUpLoot); - a_Monster.SetHealth(a_NBT.GetShort(a_NBT.FindChildByName(a_TagIdx, "Health"))); + + int LootTag = a_NBT.FindChildByName(a_TagIdx, "CanPickUpLoot"); + if (LootTag > 0) + { + bool CanPickUpLoot = (a_NBT.GetByte(LootTag) == 1); + a_Monster.SetCanPickUpLoot(CanPickUpLoot); + } + + int HealthTag = a_NBT.FindChildByName(a_TagIdx, "Health"); + a_Monster.SetHealth(HealthTag > 0 ? a_NBT.GetShort(HealthTag) : a_Monster.GetMaxHealth()); return true; } |