diff --git a/Minecraft.World/LevelChunk.cpp b/Minecraft.World/LevelChunk.cpp index 5ca429bf7..ad722aea7 100644 --- a/Minecraft.World/LevelChunk.cpp +++ b/Minecraft.World/LevelChunk.cpp @@ -1222,6 +1222,30 @@ void LevelChunk::addEntity(shared_ptr e) #endif } +void LevelChunk::addRidingEntities(shared_ptr rider, CompoundTag *riderTag) +{ +#ifdef _LARGE_WORLDS #This shouldnt be called when we dont have large worlds enabled + CompoundTag *mountTag = riderTag; + shared_ptr ridingEntity = rider; + + while (mountTag != NULL && mountTag->contains(Entity::RIDING_TAG)) + { + CompoundTag *nextMountTag = mountTag->getCompound(Entity::RIDING_TAG); + shared_ptr mount = EntityIO::loadStatic(nextMountTag, level); + if (mount == NULL) + { + break; + } + + mount->onLoadedFromSave(); + addEntity(mount); + ridingEntity->ride(mount); + + ridingEntity = mount; + mountTag = nextMountTag; + } +#endif +}; void LevelChunk::removeEntity(shared_ptr e) { @@ -1420,29 +1444,6 @@ void LevelChunk::load() #ifdef _LARGE_WORLDS if(m_bUnloaded && m_unloadedEntitiesTag) { - auto addRidingEntities = [this](shared_ptr rider, CompoundTag *riderTag) - { - CompoundTag *mountTag = riderTag; - shared_ptr ridingEntity = rider; - - while (mountTag != NULL && mountTag->contains(Entity::RIDING_TAG)) - { - CompoundTag *nextMountTag = mountTag->getCompound(Entity::RIDING_TAG); - shared_ptr mount = EntityIO::loadStatic(nextMountTag, level); - if (mount == NULL) - { - break; - } - - mount->onLoadedFromSave(); - addEntity(mount); - ridingEntity->ride(mount); - - ridingEntity = mount; - mountTag = nextMountTag; - } - }; - ListTag *entityTags = (ListTag *) m_unloadedEntitiesTag->getList(L"Entities"); if (entityTags != NULL) { diff --git a/Minecraft.World/LevelChunk.h b/Minecraft.World/LevelChunk.h index fdb2ba6c2..bd2b3b910 100644 --- a/Minecraft.World/LevelChunk.h +++ b/Minecraft.World/LevelChunk.h @@ -192,6 +192,7 @@ public: virtual void setBrightness(LightLayer::variety layer, int x, int y, int z, int brightness); virtual int getRawBrightness(int x, int y, int z, int skyDampen); virtual void addEntity(shared_ptr e); + virtual void addRidingEntities(shared_ptr rider, CompoundTag *riderTag); virtual void removeEntity(shared_ptr e); virtual void removeEntity(shared_ptr e, int yc); virtual bool isSkyLit(int x, int y, int z); diff --git a/Minecraft.World/OldChunkStorage.cpp b/Minecraft.World/OldChunkStorage.cpp index a45e9c035..ae4a08c45 100644 --- a/Minecraft.World/OldChunkStorage.cpp +++ b/Minecraft.World/OldChunkStorage.cpp @@ -392,28 +392,6 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, CompoundTag *tag) void OldChunkStorage::loadEntities(LevelChunk *lc, Level *level, CompoundTag *tag) { - auto addRidingEntities = [lc, level](shared_ptr rider, CompoundTag *riderTag) - { - CompoundTag *mountTag = riderTag; - shared_ptr ridingEntity = rider; - - while (mountTag != NULL && mountTag->contains(Entity::RIDING_TAG)) - { - CompoundTag *nextMountTag = mountTag->getCompound(Entity::RIDING_TAG); - shared_ptr mount = EntityIO::loadStatic(nextMountTag, level); - if (mount == NULL) - { - break; - } - - lc->addEntity(mount); - ridingEntity->ride(mount); - - ridingEntity = mount; - mountTag = nextMountTag; - } - }; - ListTag *entityTags = (ListTag *) tag->getList(L"Entities"); if (entityTags != NULL) { @@ -425,7 +403,7 @@ void OldChunkStorage::loadEntities(LevelChunk *lc, Level *level, CompoundTag *ta if (te != NULL) { lc->addEntity(te); - addRidingEntities(te, teTag); + lc->addRidingEntities(te, teTag); } } } diff --git a/Minecraft.World/ZonedChunkStorage.cpp b/Minecraft.World/ZonedChunkStorage.cpp index 8124376b5..53a85921f 100644 --- a/Minecraft.World/ZonedChunkStorage.cpp +++ b/Minecraft.World/ZonedChunkStorage.cpp @@ -184,28 +184,6 @@ void ZonedChunkStorage::flush() void ZonedChunkStorage::loadEntities(Level *level, LevelChunk *lc) { - auto addRidingEntities = [level, lc](shared_ptr rider, CompoundTag *riderTag) - { - CompoundTag *mountTag = riderTag; - shared_ptr ridingEntity = rider; - - while (mountTag != NULL && mountTag->contains(Entity::RIDING_TAG)) - { - CompoundTag *nextMountTag = mountTag->getCompound(Entity::RIDING_TAG); - shared_ptr mount = EntityIO::loadStatic(nextMountTag, level); - if (mount == nullptr) - { - break; - } - - lc->addEntity(mount); - ridingEntity->ride(mount); - - ridingEntity = mount; - mountTag = nextMountTag; - } - }; - int slot = getSlot(lc->x, lc->z); ZoneFile *zoneFile = getZoneFile(lc->x, lc->z, true); vector *tags = zoneFile->entityFile->readAll(slot); @@ -219,7 +197,7 @@ void ZonedChunkStorage::loadEntities(Level *level, LevelChunk *lc) if (e != nullptr) { lc->addEntity(e); - addRidingEntities(e, tag); + lc->addRidingEntities(e, tag); } } else if (type == 1)