aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/client/ConfigManager.java
diff options
context:
space:
mode:
authorUnknown <shekwancheung0528@gmail.com>2019-04-09 17:44:04 +0800
committerUnknown <shekwancheung0528@gmail.com>2019-04-09 17:44:04 +0800
commita2ca75303852c2c7612ef8e95d831331173f0014 (patch)
treecaeedf90f52fc74930fc85ae041f8b998859ee71 /src/main/java/me/shedaniel/rei/client/ConfigManager.java
parent7e7958b83c619490b4a57f7652b8cadeb7bf90eb (diff)
downloadRoughlyEnoughItems-a2ca75303852c2c7612ef8e95d831331173f0014.tar.gz
RoughlyEnoughItems-a2ca75303852c2c7612ef8e95d831331173f0014.tar.bz2
RoughlyEnoughItems-a2ca75303852c2c7612ef8e95d831331173f0014.zip
Loader 0.4
Diffstat (limited to 'src/main/java/me/shedaniel/rei/client/ConfigManager.java')
-rw-r--r--src/main/java/me/shedaniel/rei/client/ConfigManager.java46
1 files changed, 42 insertions, 4 deletions
diff --git a/src/main/java/me/shedaniel/rei/client/ConfigManager.java b/src/main/java/me/shedaniel/rei/client/ConfigManager.java
index 59a870234..7edfc08f7 100644
--- a/src/main/java/me/shedaniel/rei/client/ConfigManager.java
+++ b/src/main/java/me/shedaniel/rei/client/ConfigManager.java
@@ -6,7 +6,10 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import me.shedaniel.rei.RoughlyEnoughItemsCore;
import net.fabricmc.loader.api.FabricLoader;
+import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.Screen;
+import net.minecraft.client.resource.language.I18n;
+import net.minecraft.text.StringTextComponent;
import java.io.File;
import java.io.FileOutputStream;
@@ -14,6 +17,7 @@ import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
+import java.util.List;
public class ConfigManager implements me.shedaniel.rei.api.ConfigManager {
@@ -122,10 +126,44 @@ public class ConfigManager implements me.shedaniel.rei.api.ConfigManager {
@Override
public void openConfigScreen(Screen parent) {
- try {
- Class.forName("me.shedaniel.rei.utils.ClothRegistry").getDeclaredMethod("openConfigScreen", Screen.class).invoke(null, parent);
- } catch (IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
- e.printStackTrace();
+ if (FabricLoader.getInstance().isModLoaded("cloth-config")) {
+ try {
+ Class.forName("me.shedaniel.rei.utils.ClothScreenRegistry").getDeclaredMethod("openConfigScreen", Screen.class).invoke(null, parent);
+ } catch (IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
+ e.printStackTrace();
+ }
+ } else {
+ MinecraftClient.getInstance().openScreen(new Screen(new StringTextComponent("")) {
+ @Override
+ public void render(int int_1, int int_2, float float_1) {
+ renderDirtBackground(0);
+ List<String> list = minecraft.textRenderer.wrapStringToWidthAsList(I18n.translate("text.rei.no_config_api"), width - 100);
+ int y = (int) (height / 2 - minecraft.textRenderer.fontHeight * 1.3f / 2 * list.size());
+ for(int i = 0; i < list.size(); i++) {
+ String s = list.get(i);
+ drawCenteredString(minecraft.textRenderer, s, width / 2, y, -1);
+ y += minecraft.textRenderer.fontHeight;
+ }
+ super.render(int_1, int_2, float_1);
+ }
+
+ @Override
+ protected void init() {
+ super.init();
+ addButton(new net.minecraft.client.gui.widget.ButtonWidget(width / 2 - 100, height - 26, 200, 20, I18n.translate("gui.done"), buttonWidget -> {
+ this.minecraft.openScreen(parent);
+ }));
+ }
+
+ @Override
+ public boolean keyPressed(int int_1, int int_2, int int_3) {
+ if (int_1 == 256 && this.shouldCloseOnEsc()) {
+ this.minecraft.openScreen(parent);
+ return true;
+ }
+ return super.keyPressed(int_1, int_2, int_3);
+ }
+ });
}
}