aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/shcm/shsupercm/fabric/citresewn/config
diff options
context:
space:
mode:
authorSHsuperCM <shsupercm@gmail.com>2022-01-21 14:21:23 +0200
committerSHsuperCM <shsupercm@gmail.com>2022-01-21 14:21:23 +0200
commit897172bde9128da47181a6db6c1ff4885081ba8d (patch)
tree462e0c45eddaf727596a77b6a17d41560fa4796e /src/main/java/shcm/shsupercm/fabric/citresewn/config
parentc3c547c6f950ebbc047cd31672f6a794483a9d0e (diff)
downloadCITResewn-897172bde9128da47181a6db6c1ff4885081ba8d.tar.gz
CITResewn-897172bde9128da47181a6db6c1ff4885081ba8d.tar.bz2
CITResewn-897172bde9128da47181a6db6c1ff4885081ba8d.zip
Re(moved) most of the old sources
Diffstat (limited to 'src/main/java/shcm/shsupercm/fabric/citresewn/config')
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfig.java8
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfigScreenFactory.java9
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnModMenu.java16
3 files changed, 17 insertions, 16 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfig.java b/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfig.java
index 04b3166..2f051f0 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfig.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfig.java
@@ -4,8 +4,6 @@ import com.google.gson.Gson;
import com.google.gson.stream.JsonWriter;
import org.apache.commons.io.IOUtils;
import shcm.shsupercm.fabric.citresewn.CITResewn;
-import shcm.shsupercm.fabric.citresewn.pack.CITParser;
-import shcm.shsupercm.fabric.citresewn.pack.cits.CITItem;
import java.io.*;
@@ -13,14 +11,12 @@ public class CITResewnConfig {
public boolean enabled = true;
public boolean mute_errors = false;
public boolean mute_warns = false;
- public float citenchantment_scroll_multiplier = 8f;
public int cache_ms = 50;
public boolean broken_paths = false;
private static final File FILE = new File("config/citresewn.json");
- public static CITResewnConfig INSTANCE() {
- return CITResewn.INSTANCE.config;
- }
+
+ public static final CITResewnConfig INSTANCE = read();
public static CITResewnConfig read() {
if (!FILE.exists())
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfigScreenFactory.java b/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfigScreenFactory.java
index 055c976..33f4950 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfigScreenFactory.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnConfigScreenFactory.java
@@ -11,7 +11,7 @@ import net.minecraft.util.Formatting;
public class CITResewnConfigScreenFactory {
public static Screen create(Screen parent) {
- CITResewnConfig currentConfig = CITResewnConfig.INSTANCE(), defaultConfig = new CITResewnConfig();
+ CITResewnConfig currentConfig = CITResewnConfig.INSTANCE, defaultConfig = new CITResewnConfig();
ConfigBuilder builder = ConfigBuilder.create()
.setParentScreen(parent)
@@ -44,13 +44,6 @@ public class CITResewnConfigScreenFactory {
.setDefaultValue(defaultConfig.mute_warns)
.build());
- category.addEntry(entryBuilder.startFloatField(new TranslatableText("config.citresewn.citenchantment_scroll_multiplier.title"), currentConfig.citenchantment_scroll_multiplier)
- .setTooltip(new TranslatableText("config.citresewn.citenchantment_scroll_multiplier.tooltip"))
- .setSaveConsumer(newConfig -> currentConfig.citenchantment_scroll_multiplier = newConfig)
- .setDefaultValue(defaultConfig.citenchantment_scroll_multiplier)
- .setMin(0f)
- .build());
-
category.addEntry(entryBuilder.startIntSlider(new TranslatableText("config.citresewn.cache_ms.title"), currentConfig.cache_ms / 50, 0, 5 * 20)
.setTooltip(new TranslatableText("config.citresewn.cache_ms.tooltip"))
.setSaveConsumer(newConfig -> currentConfig.cache_ms = newConfig * 50)
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnModMenu.java b/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnModMenu.java
index 7a4954c..cf6d9bd 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnModMenu.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/config/CITResewnModMenu.java
@@ -3,11 +3,23 @@ package shcm.shsupercm.fabric.citresewn.config;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import net.fabricmc.loader.api.FabricLoader;
-import shcm.shsupercm.fabric.citresewn.OptionalCompat;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.screen.NoticeScreen;
+import net.minecraft.text.Text;
public class CITResewnModMenu implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
- return OptionalCompat.getModConfigScreenFactory()::apply;
+ if (FabricLoader.getInstance().isModLoaded("cloth-config2"))
+ return new ClothConfigOpenImpl().getModConfigScreenFactory();
+
+ return parent -> new NoticeScreen(() -> MinecraftClient.getInstance().setScreen(parent), Text.of("CIT Resewn"), Text.of("CIT Resewn requires Cloth Config to be able to show the config."));
+ }
+
+ private static class ClothConfigOpenImpl implements ModMenuApi {
+ @Override
+ public ConfigScreenFactory<?> getModConfigScreenFactory() {
+ return CITResewnConfigScreenFactory::create;
+ }
}
}