|
14 | 14 | import org.spongepowered.asm.mixin.injection.At; |
15 | 15 | import org.spongepowered.asm.mixin.injection.Inject; |
16 | 16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
17 | | -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
18 | 17 |
|
19 | 18 | import java.nio.file.Path; |
20 | | -import java.util.concurrent.CompletableFuture; |
21 | 19 |
|
22 | 20 | /** |
23 | 21 | * Hooks into {@link ChunkMap} saving code-paths for "hard" save operations. |
@@ -51,46 +49,15 @@ public ChunkMapMixin(final Path path, final DataFixer dataFixer, final boolean s |
51 | 49 | super(path, dataFixer, sync); |
52 | 50 | } |
53 | 51 |
|
54 | | - /** |
55 | | - * This is for the code-path taken when a chunk is being unloaded. |
56 | | - */ |
57 | | - @Inject(method = "lambda$scheduleUnload$11", at = {@At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;save(Lnet/minecraft/world/level/chunk/ChunkAccess;)Z")}) |
58 | | - private void beforeSaveOnUnload(final ChunkHolder chunkHolder, final CompletableFuture<?> chunkToSave, final long chunkId, final ChunkAccess chunkAccess, final CallbackInfo ci) { |
59 | | - if (chunkAccess instanceof ChunkAccessExt ext) { |
60 | | - ext.applyAndClearLazyUnsaved(); |
61 | | - } |
62 | | - } |
63 | | - |
64 | | - /** |
65 | | - * This is for the code-path taken when saving all chunks upon server shutdown or when |
66 | | - * running a save command with the "flush" flag. |
67 | | - */ |
68 | | - @Inject(method = "lambda$saveAllChunks$8", at = {@At(value = "HEAD")}) |
69 | | - private static void beforeSyncSave(final ChunkAccess chunkAccess, final CallbackInfoReturnable<Boolean> cir) { |
70 | | - if (chunkAccess instanceof ChunkAccessExt ext) { |
71 | | - ext.applyAndClearLazyUnsaved(); |
72 | | - } |
73 | | - } |
74 | | - |
75 | | - /** |
76 | | - * This is for the code-path taken when saving chunk upon pausing the game or when |
77 | | - * running a save command without the "flush" flag. |
78 | | - */ |
79 | 52 | @Inject(method = "saveAllChunks", at = {@At(value = "HEAD")}) |
80 | | - private void beforeAsyncSave(final boolean sync, final CallbackInfo ci) { |
81 | | - // The sync case is handled in beforeSyncSave. |
82 | | - if (!sync) { |
83 | | - // Need to iterate this ourselves, because I can't find the hook for the save call |
84 | | - // inside the foreach in the method. Slightly annoying, but only happens on explicit |
85 | | - // save requests, so not too much of a performance worry. |
86 | | - visibleChunkMap.values().forEach(holder -> { |
87 | | - if (holder.wasAccessibleSinceLastSave()) { |
88 | | - final ChunkAccess chunkToSave = holder.getChunkToSave().getNow(null); |
89 | | - if (chunkToSave instanceof ChunkAccessExt ext) { |
90 | | - ext.applyAndClearLazyUnsaved(); |
91 | | - } |
| 53 | + private void beforeAsyncSave(final CallbackInfo ci) { |
| 54 | + visibleChunkMap.values().forEach(holder -> { |
| 55 | + if (holder.wasAccessibleSinceLastSave()) { |
| 56 | + final ChunkAccess chunkToSave = holder.getChunkToSave().getNow(null); |
| 57 | + if (chunkToSave instanceof ChunkAccessExt ext) { |
| 58 | + ext.applyAndClearLazyUnsaved(); |
92 | 59 | } |
93 | | - }); |
94 | | - } |
| 60 | + } |
| 61 | + }); |
95 | 62 | } |
96 | 63 | } |
0 commit comments