From 5481249d0f6025251e811f2e35daa79ee7c258aa Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 27 Aug 2017 22:37:39 +0100 Subject: Implement basic form of trading * Fixes #3450 * Addresses #1109 --- src/WorldStorage/NBTChunkSerializer.cpp | 5 +++-- src/WorldStorage/WSSAnvil.cpp | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/WorldStorage') diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 1e8543648..5011075f1 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -664,8 +664,9 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster) case mtVillager: { const cVillager *Villager = reinterpret_cast(a_Monster); - m_Writer.AddInt("Profession", Villager->GetVilType()); - m_Writer.AddInt("Age", Villager->GetAge()); + m_Writer.AddInt("Profession", static_cast(cVillager::VillagerCareerToProfession(Villager->GetCareer()))); + m_Writer.AddInt("Career", static_cast(Villager->GetCareer())); + m_Writer.AddInt("Age", Villager->GetAge()); break; } case mtWither: diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index a3251481f..774699b8f 100755 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -2837,9 +2837,13 @@ void cWSSAnvil::LoadVillagerFromNBT(cEntityList & a_Entities, const cParsedNBT & return; } - int Type = a_NBT.GetInt(TypeIdx); + int CareerIdx = a_NBT.FindChildByName(a_TagIdx, "Career"); + if (CareerIdx < 0) + { + return; + } - std::unique_ptr Monster = cpp14::make_unique(cVillager::eVillagerType(Type)); + std::unique_ptr Monster = cpp14::make_unique(cVillager::VillagerCareer(a_NBT.GetInt(TypeIdx)), 1U); if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; -- cgit v1.2.3