mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
Fix mounted minecarts not persisting across world reloads
Signed-off-by: Ayush Thoren <ayushthoren@gmail.com>
This commit is contained in:
parent
88798b501d
commit
643d32a301
|
|
@ -1420,6 +1420,29 @@ void LevelChunk::load()
|
|||
#ifdef _LARGE_WORLDS
|
||||
if(m_bUnloaded && m_unloadedEntitiesTag)
|
||||
{
|
||||
auto addRidingEntities = [this](shared_ptr<Entity> rider, CompoundTag *riderTag)
|
||||
{
|
||||
CompoundTag *mountTag = riderTag;
|
||||
shared_ptr<Entity> ridingEntity = rider;
|
||||
|
||||
while (mountTag != NULL && mountTag->contains(Entity::RIDING_TAG))
|
||||
{
|
||||
CompoundTag *nextMountTag = mountTag->getCompound(Entity::RIDING_TAG);
|
||||
shared_ptr<Entity> mount = EntityIO::loadStatic(nextMountTag, level);
|
||||
if (mount == NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
mount->onLoadedFromSave();
|
||||
addEntity(mount);
|
||||
ridingEntity->ride(mount);
|
||||
|
||||
ridingEntity = mount;
|
||||
mountTag = nextMountTag;
|
||||
}
|
||||
};
|
||||
|
||||
ListTag<CompoundTag> *entityTags = (ListTag<CompoundTag> *) m_unloadedEntitiesTag->getList(L"Entities");
|
||||
if (entityTags != NULL)
|
||||
{
|
||||
|
|
@ -1431,6 +1454,7 @@ void LevelChunk::load()
|
|||
{
|
||||
ent->onLoadedFromSave();
|
||||
addEntity(ent);
|
||||
addRidingEntities(ent, teTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -392,6 +392,28 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, CompoundTag *tag)
|
|||
|
||||
void OldChunkStorage::loadEntities(LevelChunk *lc, Level *level, CompoundTag *tag)
|
||||
{
|
||||
auto addRidingEntities = [lc, level](shared_ptr<Entity> rider, CompoundTag *riderTag)
|
||||
{
|
||||
CompoundTag *mountTag = riderTag;
|
||||
shared_ptr<Entity> ridingEntity = rider;
|
||||
|
||||
while (mountTag != NULL && mountTag->contains(Entity::RIDING_TAG))
|
||||
{
|
||||
CompoundTag *nextMountTag = mountTag->getCompound(Entity::RIDING_TAG);
|
||||
shared_ptr<Entity> mount = EntityIO::loadStatic(nextMountTag, level);
|
||||
if (mount == NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
lc->addEntity(mount);
|
||||
ridingEntity->ride(mount);
|
||||
|
||||
ridingEntity = mount;
|
||||
mountTag = nextMountTag;
|
||||
}
|
||||
};
|
||||
|
||||
ListTag<CompoundTag> *entityTags = (ListTag<CompoundTag> *) tag->getList(L"Entities");
|
||||
if (entityTags != NULL)
|
||||
{
|
||||
|
|
@ -403,6 +425,7 @@ void OldChunkStorage::loadEntities(LevelChunk *lc, Level *level, CompoundTag *ta
|
|||
if (te != NULL)
|
||||
{
|
||||
lc->addEntity(te);
|
||||
addRidingEntities(te, teTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,6 +184,28 @@ void ZonedChunkStorage::flush()
|
|||
|
||||
void ZonedChunkStorage::loadEntities(Level *level, LevelChunk *lc)
|
||||
{
|
||||
auto addRidingEntities = [level, lc](shared_ptr<Entity> rider, CompoundTag *riderTag)
|
||||
{
|
||||
CompoundTag *mountTag = riderTag;
|
||||
shared_ptr<Entity> ridingEntity = rider;
|
||||
|
||||
while (mountTag != NULL && mountTag->contains(Entity::RIDING_TAG))
|
||||
{
|
||||
CompoundTag *nextMountTag = mountTag->getCompound(Entity::RIDING_TAG);
|
||||
shared_ptr<Entity> 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<CompoundTag *> *tags = zoneFile->entityFile->readAll(slot);
|
||||
|
|
@ -194,7 +216,11 @@ void ZonedChunkStorage::loadEntities(Level *level, LevelChunk *lc)
|
|||
if (type == 0)
|
||||
{
|
||||
shared_ptr<Entity> e = EntityIO::loadStatic(tag, level);
|
||||
if (e != nullptr) lc->addEntity(e);
|
||||
if (e != nullptr)
|
||||
{
|
||||
lc->addEntity(e);
|
||||
addRidingEntities(e, tag);
|
||||
}
|
||||
}
|
||||
else if (type == 1)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue