aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World
diff options
context:
space:
mode:
authorAyush Thoren <ayushthoren@gmail.com>2026-03-13 04:16:05 -0700
committerGitHub <noreply@github.com>2026-03-13 11:16:05 +0000
commitd131a551bff13b76d98dc708756daa1fd975e7ca (patch)
tree536443a04a20bf261d798f67fde43e398eba9482 /Minecraft.World
parentad74d443001ff17c5ab10e4438952e2805e05f38 (diff)
Fix mounted minecarts not persisting across world reloads (#979)
* Fix mounted minecarts not persisting across world reloads Signed-off-by: Ayush Thoren <ayushthoren@gmail.com> * Apply patch --------- Signed-off-by: Ayush Thoren <ayushthoren@gmail.com>
Diffstat (limited to 'Minecraft.World')
-rw-r--r--Minecraft.World/LevelChunk.cpp25
-rw-r--r--Minecraft.World/LevelChunk.h1
-rw-r--r--Minecraft.World/OldChunkStorage.cpp1
-rw-r--r--Minecraft.World/ZonedChunkStorage.cpp6
4 files changed, 32 insertions, 1 deletions
diff --git a/Minecraft.World/LevelChunk.cpp b/Minecraft.World/LevelChunk.cpp
index 29308e29..584e3df1 100644
--- a/Minecraft.World/LevelChunk.cpp
+++ b/Minecraft.World/LevelChunk.cpp
@@ -1222,6 +1222,30 @@ void LevelChunk::addEntity(shared_ptr<Entity> e)
#endif
}
+void LevelChunk::addRidingEntities(shared_ptr<Entity> rider, CompoundTag *riderTag)
+{
+#ifdef _LARGE_WORLDS #This shouldnt be called when we dont have large worlds enabled
+ 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;
+ }
+#endif
+};
void LevelChunk::removeEntity(shared_ptr<Entity> e)
{
@@ -1431,6 +1455,7 @@ void LevelChunk::load()
{
ent->onLoadedFromSave();
addEntity(ent);
+ addRidingEntities(ent, teTag);
}
}
}
diff --git a/Minecraft.World/LevelChunk.h b/Minecraft.World/LevelChunk.h
index fdb2ba6c..bd2b3b91 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<Entity> e);
+ virtual void addRidingEntities(shared_ptr<Entity> rider, CompoundTag *riderTag);
virtual void removeEntity(shared_ptr<Entity> e);
virtual void removeEntity(shared_ptr<Entity> 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 9a8822fa..15b4c734 100644
--- a/Minecraft.World/OldChunkStorage.cpp
+++ b/Minecraft.World/OldChunkStorage.cpp
@@ -403,6 +403,7 @@ void OldChunkStorage::loadEntities(LevelChunk *lc, Level *level, CompoundTag *ta
if (te != nullptr)
{
lc->addEntity(te);
+ lc->addRidingEntities(te, teTag);
}
}
}
diff --git a/Minecraft.World/ZonedChunkStorage.cpp b/Minecraft.World/ZonedChunkStorage.cpp
index 19023242..75df6a0c 100644
--- a/Minecraft.World/ZonedChunkStorage.cpp
+++ b/Minecraft.World/ZonedChunkStorage.cpp
@@ -194,7 +194,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);
+ lc->addRidingEntities(e, tag);
+ }
}
else if (type == 1)
{