mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2025-01-27 18:51:21 +01:00
Change world-to-folder implementation for latest forge and fabric versions
to get the correct save-folder even if the actual world-name is different
This commit is contained in:
parent
9075dc6a76
commit
c677c28075
@ -57,6 +57,7 @@
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.WorldSavePath;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
public class FabricMod implements ModInitializer, ServerInterface {
|
||||
@ -161,8 +162,7 @@ public UUID getUUIDForWorld(ServerWorld world) throws IOException {
|
||||
|
||||
private UUID loadUUIDForWorld(ServerWorld world) throws IOException {
|
||||
MinecraftServer server = world.getServer();
|
||||
String worldName = server.getSaveProperties().getLevelName();
|
||||
File worldFolder = new File(world.getServer().getRunDirectory(), worldName);
|
||||
File worldFolder = world.getServer().getRunDirectory().toPath().resolve(server.getSavePath(WorldSavePath.ROOT)).toFile();
|
||||
File dimensionFolder = DimensionType.getSaveDirectory(world.getRegistryKey(), worldFolder);
|
||||
File dimensionDir = dimensionFolder.getCanonicalFile();
|
||||
return getUUIDForWorld(dimensionDir);
|
||||
|
@ -57,6 +57,7 @@
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.WorldSavePath;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
public class FabricMod implements ModInitializer, ServerInterface {
|
||||
@ -161,8 +162,7 @@ public UUID getUUIDForWorld(ServerWorld world) throws IOException {
|
||||
|
||||
private UUID loadUUIDForWorld(ServerWorld world) throws IOException {
|
||||
MinecraftServer server = world.getServer();
|
||||
String worldName = server.getSaveProperties().getLevelName();
|
||||
File worldFolder = new File(world.getServer().getRunDirectory(), worldName);
|
||||
File worldFolder = world.getServer().getRunDirectory().toPath().resolve(server.getSavePath(WorldSavePath.ROOT)).toFile();
|
||||
File dimensionFolder = DimensionType.getSaveDirectory(world.getRegistryKey(), worldFolder);
|
||||
File dimensionDir = dimensionFolder.getCanonicalFile();
|
||||
return getUUIDForWorld(dimensionDir);
|
||||
|
@ -53,6 +53,7 @@
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.world.storage.FolderName;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.TickEvent.ServerTickEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent.PlayerLoggedInEvent;
|
||||
@ -174,8 +175,7 @@ private UUID loadUUIDForWorld(ServerWorld world) throws IOException {
|
||||
|
||||
private File getFolderForWorld(ServerWorld world) throws IOException {
|
||||
MinecraftServer server = world.getServer();
|
||||
String worldName = server.func_240793_aU_().getWorldName();
|
||||
File worldFolder = new File(world.getServer().getDataDirectory(), worldName);
|
||||
File worldFolder = world.getServer().getDataDirectory().toPath().resolve(server.func_240776_a_(FolderName.field_237253_i_)).toFile();
|
||||
File dimensionFolder = DimensionType.func_236031_a_(world.func_234923_W_(), worldFolder);
|
||||
return dimensionFolder.getCanonicalFile();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user