Skip to content

Commit

Permalink
Update ServerLevelMixin::save to match the vanilla impl again (#4148)
Browse files Browse the repository at this point in the history
  • Loading branch information
nelind3 authored and aromaa committed Nov 14, 2024
1 parent 43f6ac3 commit dbdc282
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -136,6 +138,7 @@ public abstract class ServerLevelMixin extends LevelMixin implements ServerLevel

// @formatter:off
@Shadow @Final private ServerLevelData serverLevelData;
@Shadow @Final private PersistentEntitySectionManager<Entity> entityManager;
@Shadow @Final private LevelTicks<Block> blockTicks;
@Shadow @Final private LevelTicks<Fluid> fluidTicks;
@Shadow private int emptyTime;
Expand Down Expand Up @@ -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)));
}
}
Expand Down

0 comments on commit dbdc282

Please sign in to comment.