From 410d6c00453f2207ddb7a184590251b62b4769fa Mon Sep 17 00:00:00 2001 From: 12xx12 <44411062+12xx12@users.noreply.github.com> Date: Sun, 27 Sep 2020 19:02:16 +0200 Subject: Fixing Mob spawner behaviour (#4930) * fixed mob spawner failure (whoopsie in the BlockEntity.GetChunkZ()) Style * fixed spawning behaviour * fixed saving entity type saving * checkstyle * removed debug log * removed short saving * Style Co-authored-by: 12xx12 <12xx12100@gmail.com> Co-authored-by: Tiger Wang --- src/WorldStorage/WSSAnvil.cpp | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'src/WorldStorage/WSSAnvil.cpp') diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index b01bb7fd5..03decbea3 100755 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -1338,27 +1338,14 @@ OwnedBlockEntity cWSSAnvil::LoadMobSpawnerFromNBT(const cParsedNBT & a_NBT, int auto MobSpawner = std::make_unique(a_BlockType, a_BlockMeta, a_Pos, m_World); - // Load entity (Cuberite worlds): - int Type = a_NBT.FindChildByName(a_TagIdx, "Entity"); - if ((Type >= 0) && (a_NBT.GetType(Type) == TAG_Short)) + // Load entity type + int Type = a_NBT.FindChildByName(a_TagIdx, "EntityId"); + if ((Type >= 0) && (a_NBT.GetType(Type) == TAG_String)) { - short MonsterType = a_NBT.GetShort(Type); - if ((MonsterType >= 50) && (MonsterType <= 120)) + eMonsterType MonsterType = cMonster::StringToMobType(a_NBT.GetString(Type)); + if (MonsterType != eMonsterType::mtInvalidType) { - MobSpawner->SetEntity(static_cast(MonsterType)); - } - } - else - { - // Load entity (vanilla worlds): - Type = a_NBT.FindChildByName(a_TagIdx, "EntityId"); - if ((Type >= 0) && (a_NBT.GetType(Type) == TAG_String)) - { - eMonsterType MonsterType = cMonster::StringToMobType(a_NBT.GetString(Type)); - if (MonsterType != eMonsterType::mtInvalidType) - { - MobSpawner->SetEntity(MonsterType); - } + MobSpawner->SetEntity(MonsterType); } } -- cgit v1.2.3