Accept world

This commit is contained in:
mcrcortex
2025-05-19 21:38:28 +10:00
parent d808486cd0
commit 68e6621e7e

View File

@@ -15,6 +15,7 @@ import me.cortex.voxy.common.thread.ServiceThreadPool;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.world.ClientWorld; import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.WorldSavePath; import net.minecraft.util.WorldSavePath;
import net.minecraft.world.World;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
@@ -119,7 +120,7 @@ public class ContextSelectionSystem {
} }
//Gets dimension independent base world, if singleplayer, its the world name, if multiplayer, its the server ip //Gets dimension independent base world, if singleplayer, its the world name, if multiplayer, its the server ip
private static Path getBasePath(ClientWorld world) { private static Path getBasePath() {
//TODO: improve this //TODO: improve this
Path basePath = MinecraftClient.getInstance().runDirectory.toPath().resolve(".voxy").resolve("saves"); Path basePath = MinecraftClient.getInstance().runDirectory.toPath().resolve(".voxy").resolve("saves");
var iserver = MinecraftClient.getInstance().getServer(); var iserver = MinecraftClient.getInstance().getServer();
@@ -159,7 +160,7 @@ public class ContextSelectionSystem {
return hexString.toString(); return hexString.toString();
} }
private static String getWorldId(ClientWorld world) { private static String getWorldId(World world) {
String data = world.getBiomeAccess().seed + world.getRegistryKey().toString(); String data = world.getBiomeAccess().seed + world.getRegistryKey().toString();
try { try {
return bytesToHex(MessageDigest.getInstance("SHA-256").digest(data.getBytes())).substring(0, 32); return bytesToHex(MessageDigest.getInstance("SHA-256").digest(data.getBytes())).substring(0, 32);
@@ -175,8 +176,8 @@ public class ContextSelectionSystem {
} }
public Selection getBestSelectionOrCreate(ClientWorld world) { public Selection getBestSelectionOrCreate(World world) {
var path = getBasePath(world); var path = getBasePath();
try { try {
Files.createDirectories(path); Files.createDirectories(path);
} catch (IOException e) { } catch (IOException e) {