|
29 | 29 | import net.minecraft.client.gui.screen.Screen; |
30 | 30 | import net.minecraft.client.sound.MusicTracker; |
31 | 31 | import net.minecraft.client.sound.SoundManager; |
32 | | -import net.minecraft.nbt.CompoundTag; |
33 | | -import net.minecraft.nbt.NbtIo; |
34 | 32 | import net.minecraft.resource.DataPackSettings; |
35 | 33 | import net.minecraft.resource.ResourceManager; |
36 | 34 | import net.minecraft.resource.ServerResourceManager; |
37 | 35 | import net.minecraft.server.MinecraftServer; |
38 | 36 | import net.minecraft.server.integrated.IntegratedServer; |
39 | 37 | import net.minecraft.util.UserCache; |
40 | | -import net.minecraft.util.WorldSavePath; |
41 | 38 | import net.minecraft.util.registry.RegistryTracker; |
42 | 39 | import net.minecraft.world.SaveProperties; |
43 | 40 | import net.minecraft.world.level.storage.LevelStorage; |
|
56 | 53 |
|
57 | 54 | import java.io.File; |
58 | 55 | import java.net.Proxy; |
59 | | -import java.nio.file.Files; |
60 | | -import java.nio.file.Path; |
61 | 56 | import java.util.Optional; |
62 | 57 | import java.util.concurrent.Executor; |
63 | 58 | import java.util.concurrent.atomic.AtomicReference; |
@@ -366,35 +361,15 @@ private boolean cancelWorldGenTrackerSetNull(AtomicReference<?> instance, Object |
366 | 361 | return !SeedQueue.inQueue(); |
367 | 362 | } |
368 | 363 |
|
369 | | - @WrapOperation( |
| 364 | + @WrapWithCondition( |
370 | 365 | method = "startIntegratedServer(Ljava/lang/String;Lnet/minecraft/util/registry/RegistryTracker$Modifiable;Ljava/util/function/Function;Lcom/mojang/datafixers/util/Function4;ZLnet/minecraft/client/MinecraftClient$WorldLoadAction;)V", |
371 | 366 | at = @At( |
372 | 367 | value = "INVOKE", |
373 | 368 | target = "Lnet/minecraft/world/level/storage/LevelStorage$Session;backupLevelDataFile(Lnet/minecraft/util/registry/RegistryTracker;Lnet/minecraft/world/SaveProperties;)V" |
374 | 369 | ) |
375 | 370 | ) |
376 | | - private void cancelSessionLevelDatInit(LevelStorage.Session session, RegistryTracker tracker, SaveProperties properties, Operation<Void> original) { |
377 | | - if (SeedQueue.inQueue()) { |
378 | | - // since this world is guaranteed to be new, |
379 | | - // we can optimize level.dat creation by saving the file |
380 | | - // without backing up the old file (which doesn't exist) |
381 | | - Path path = session.getDirectory(WorldSavePath.LEVEL_DAT); |
382 | | - CompoundTag data = properties.cloneWorldTag(tracker, null); |
383 | | - CompoundTag tag = new CompoundTag(); |
384 | | - tag.put("Data", data); |
385 | | - |
386 | | - try { |
387 | | - NbtIo.writeCompressed(tag, Files.newOutputStream(path)); |
388 | | - } catch (Exception e) { |
389 | | - SeedQueue.LOGGER.error("Failed to save level {}", path, e); |
390 | | - } |
391 | | - return; |
392 | | - } |
393 | | - if (SeedQueue.currentEntry != null) { |
394 | | - // already saved level.dat on SeedQueueThread |
395 | | - return; |
396 | | - } |
397 | | - original.call(session, tracker, properties); |
| 371 | + private boolean cancelSessionLevelDatInit(LevelStorage.Session instance, RegistryTracker registryTracker, SaveProperties saveProperties) { |
| 372 | + return SeedQueue.inQueue() || SeedQueue.currentEntry == null; |
398 | 373 | } |
399 | 374 |
|
400 | 375 | @WrapWithCondition( |
|
0 commit comments