Serialization + modmenu stuff
This commit is contained in:
parent
4337af9aa6
commit
fa9e5502a4
2 changed files with 12 additions and 3 deletions
|
@ -294,6 +294,14 @@ public final class ModConfig {
|
|||
}
|
||||
}
|
||||
|
||||
public static void serialize() {
|
||||
try {
|
||||
Files.write(CONFIG_PATH, GSON.toJson(CODEC.encodeStart(JsonOps.INSTANCE, INSTANCE).getOrThrow(false, System.err::println)).getBytes(StandardCharsets.UTF_8));
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("An Unexpected error occured when serializing the Config", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static int deserialize() {
|
||||
LimboDecay.init();
|
||||
try {
|
||||
|
@ -313,8 +321,7 @@ public final class ModConfig {
|
|||
).getOrThrow(false, System.err::println).getFirst();
|
||||
return 1;
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("An Unexpected error occured when deserializing the Config. Using default values for now.");
|
||||
e.printStackTrace();
|
||||
LOGGER.error("An Unexpected error occured when deserializing the Config. Using default values", e);
|
||||
INSTANCE = FALLBACK;
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package org.dimdev.dimdoors.client.config;
|
|||
|
||||
import io.github.prospector.modmenu.api.ConfigScreenFactory;
|
||||
import io.github.prospector.modmenu.api.ModMenuApi;
|
||||
import org.dimdev.dimdoors.ModConfig;
|
||||
import org.dimdev.dimdoors.client.util.ScreenGenerator;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
@ -10,6 +12,6 @@ import net.fabricmc.api.Environment;
|
|||
public class ModMenuImpl implements ModMenuApi {
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||
return LoadConfigScreen::new;
|
||||
return screen -> ScreenGenerator.create(screen, ModConfig.INSTANCE, ModConfig::serialize);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue