diff options
Diffstat (limited to '')
-rwxr-xr-x | src/WorldStorage/WSSAnvil.cpp | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 31934e181..9915e9eb7 100755 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -1568,6 +1568,8 @@ void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a { "minecraft:zombie", &cWSSAnvil::LoadZombieFromNBT }, { "PigZombie", &cWSSAnvil::LoadPigZombieFromNBT }, { "minecraft:zombie_pigman", &cWSSAnvil::LoadPigZombieFromNBT }, + { "ZombieVillager", &cWSSAnvil::LoadZombieVillagerFromNBT }, + { "minecraft:zombie_villager", &cWSSAnvil::LoadZombieVillagerFromNBT }, }; auto it = EntityTypeToFunction.find(AString(a_IDTag, a_IDTagLength)); @@ -2968,15 +2970,40 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N void cWSSAnvil::LoadZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { - int IsVillagerIdx = a_NBT.FindChildByName(a_TagIdx, "IsVillager"); - if (IsVillagerIdx < 0) + std::unique_ptr<cZombie> Monster = cpp14::make_unique<cZombie>(); + if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; } - bool IsVillagerZombie = ((a_NBT.GetByte(IsVillagerIdx) == 1) ? true : false); + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) + { + return; + } + + int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age"); + if (AgeableIdx > 0) + { + int Age; + switch (a_NBT.GetType(AgeableIdx)) + { + case TAG_Byte: Age = static_cast<int>(a_NBT.GetByte(AgeableIdx)); break; + case TAG_Int: Age = a_NBT.GetInt(AgeableIdx); break; + default: Age = 0; break; + } + Monster->SetAge(Age); + } + + a_Entities.emplace_back(std::move(Monster)); +} + + + - std::unique_ptr<cZombie> Monster = cpp14::make_unique<cZombie>(IsVillagerZombie); + +void cWSSAnvil::LoadPigZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) +{ + std::unique_ptr<cZombiePigman> Monster = cpp14::make_unique<cZombiePigman>(); if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -3007,9 +3034,17 @@ void cWSSAnvil::LoadZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a -void cWSSAnvil::LoadPigZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) +void cWSSAnvil::LoadZombieVillagerFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { - std::unique_ptr<cZombiePigman> Monster = cpp14::make_unique<cZombiePigman>(); + int ProfessionIdx = a_NBT.FindChildByName(a_TagIdx, "Profession"); + if (ProfessionIdx < 0) + { + return; + } + + cVillager::eVillagerType Profession = static_cast<cVillager::eVillagerType>(a_NBT.GetInt(ProfessionIdx)); + + std::unique_ptr<cZombieVillager> Monster = cpp14::make_unique<cZombieVillager>(Profession); if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -3020,6 +3055,8 @@ void cWSSAnvil::LoadPigZombieFromNBT(cEntityList & a_Entities, const cParsedNBT return; } + // TODO: Conversion time + int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age"); if (AgeableIdx > 0) { @@ -3028,7 +3065,7 @@ void cWSSAnvil::LoadPigZombieFromNBT(cEntityList & a_Entities, const cParsedNBT { case TAG_Byte: Age = static_cast<int>(a_NBT.GetByte(AgeableIdx)); break; case TAG_Int: Age = a_NBT.GetInt (AgeableIdx); break; - default: Age = 0; break; + default: Age = 0; break; } Monster->SetAge(Age); } |