diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ServerLevelMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ServerLevelMixin.java index 3f7af4b2ea8..ce4e2f2b124 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ServerLevelMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ServerLevelMixin.java @@ -46,6 +46,7 @@ import net.minecraft.sounds.SoundEvents; import net.minecraft.util.ProgressListener; import net.minecraft.world.RandomSequences; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.ai.village.poi.PoiManager; import net.minecraft.world.entity.ai.village.poi.PoiType; import net.minecraft.world.entity.player.Player; @@ -60,6 +61,7 @@ import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.dimension.end.EndDragonFight; +import net.minecraft.world.level.entity.PersistentEntitySectionManager; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.storage.LevelStorageSource; @@ -136,6 +138,7 @@ public abstract class ServerLevelMixin extends LevelMixin implements ServerLevel // @formatter:off @Shadow @Final private ServerLevelData serverLevelData; + @Shadow @Final private PersistentEntitySectionManager entityManager; @Shadow @Final private LevelTicks blockTicks; @Shadow @Final private LevelTicks fluidTicks; @Shadow private int emptyTime; @@ -398,6 +401,12 @@ public void save(@Nullable final ProgressListener progress, final boolean flush, chunkProvider.save(flush); } + if (flush) { + this.entityManager.saveAll(); + } else { + this.entityManager.autoSave(); + } + Sponge.eventManager().post(SpongeEventFactory.createSaveWorldEventPost(currentCause, ((ServerWorld) this))); } }