Prechádzať zdrojové kódy

Optimise images and add warning screen for optifine.

Signed-off-by: shedaniel <daniel@shedaniel.me>
shedaniel 5 rokov pred
rodič
commit
f9e4d6ced8

+ 1 - 1
gradle.properties

@@ -1,5 +1,5 @@
 org.gradle.jvmargs=-Xmx3G
-mod_version=4.7.0
+mod_version=4.7.1
 supported_version=1.16.x
 minecraft_version=1.16.1
 yarn_version=1.16.1+build.4+legacy.20w09a+build.8

+ 3 - 0
src/main/java/me/shedaniel/rei/api/ConfigManager.java

@@ -24,9 +24,12 @@
 package me.shedaniel.rei.api;
 
 import me.shedaniel.rei.RoughlyEnoughItemsCore;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.screen.Screen;
 
+@Environment(EnvType.CLIENT)
 public interface ConfigManager {
     
     /**

+ 3 - 0
src/main/java/me/shedaniel/rei/api/TextRepresentable.java

@@ -25,11 +25,14 @@ package me.shedaniel.rei.api;
 
 import me.shedaniel.math.impl.PointHelper;
 import me.shedaniel.rei.api.widgets.Tooltip;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
 import net.minecraft.text.LiteralText;
 import net.minecraft.text.Text;
 import net.minecraft.util.Formatting;
 import org.jetbrains.annotations.NotNull;
 
+@Environment(EnvType.CLIENT)
 public interface TextRepresentable {
     @NotNull
     default Text asFormattedText() {

+ 40 - 0
src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java

@@ -49,11 +49,17 @@ import me.shedaniel.rei.gui.config.entry.NoFilteringEntry;
 import me.shedaniel.rei.gui.config.entry.RecipeScreenTypeEntry;
 import me.shedaniel.rei.gui.config.entry.ReloadPluginsEntry;
 import me.shedaniel.rei.gui.credits.CreditsScreen;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.fabricmc.loader.api.FabricLoader;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.screen.Screen;
+import net.minecraft.client.gui.screen.ScreenTexts;
 import net.minecraft.client.gui.widget.ButtonWidget;
 import net.minecraft.client.util.InputUtil;
+import net.minecraft.client.util.math.MatrixStack;
 import net.minecraft.text.LiteralText;
+import net.minecraft.text.Text;
 import net.minecraft.text.TranslatableText;
 import net.minecraft.util.math.MathHelper;
 import org.jetbrains.annotations.ApiStatus;
@@ -66,6 +72,7 @@ import static me.sargunvohra.mcmods.autoconfig1u.util.Utils.getUnsafely;
 import static me.sargunvohra.mcmods.autoconfig1u.util.Utils.setUnsafely;
 
 @ApiStatus.Internal
+@Environment(EnvType.CLIENT)
 public class ConfigManagerImpl implements ConfigManager {
     
     private boolean craftableOnly;
@@ -150,6 +157,9 @@ public class ConfigManagerImpl implements ConfigManager {
     @Override
     public Screen getConfigScreen(Screen parent) {
         try {
+            if (FabricLoader.getInstance().isModLoaded("optifabric")) {
+                return new ConfigErrorScreen(parent, new TranslatableText("text.rei.config.optifine.title"), new TranslatableText("text.rei.config.optifine.description"));
+            }
             ConfigScreenProvider<ConfigObjectImpl> provider = (ConfigScreenProvider<ConfigObjectImpl>) AutoConfig.getConfigScreen(ConfigObjectImpl.class, parent);
             provider.setI13nFunction(manager -> "config.roughlyenoughitems");
             provider.setOptionFunction((baseI13n, field) -> field.isAnnotationPresent(ConfigObjectImpl.DontApplyFieldName.class) ? baseI13n : String.format("%s.%s", baseI13n, field.getName()));
@@ -178,4 +188,34 @@ public class ConfigManagerImpl implements ConfigManager {
         return null;
     }
     
+    public static class ConfigErrorScreen extends Screen {
+        private final Text message;
+        private final Screen parent;
+        
+        public ConfigErrorScreen(Screen parent, Text title, Text message) {
+            super(title);
+            this.parent = parent;
+            this.message = message;
+        }
+        
+        @Override
+        protected void init() {
+            super.init();
+            this.addButton(new ButtonWidget(this.width / 2 - 100, 140, 200, 20, ScreenTexts.CANCEL, button -> this.client.openScreen(parent)));
+        }
+        
+        @Override
+        public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
+            this.renderBackground(matrices);
+            this.drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 90, 16777215);
+            this.drawCenteredText(matrices, this.textRenderer, this.message, this.width / 2, 110, 16777215);
+            super.render(matrices, mouseX, mouseY, delta);
+        }
+        
+        @Override
+        public boolean shouldCloseOnEsc() {
+            return false;
+        }
+    }
+    
 }

+ 2 - 0
src/main/resources/assets/roughlyenoughitems/lang/en_us.json

@@ -36,6 +36,8 @@
   "text.rei.composting.page": "Page %d",
   "text.rei.config": "Config",
   "text.rei.config_tooltip": "Open Config Screen\n§7Shift-Click to toggle cheat mode",
+  "text.rei.config.optifine.title": "Failed to open REI config screen",
+  "text.rei.config.optifine.description": "The configuration screen is incompatible with OptiFine / OptiFabric.",
   "text.rei.cheat_items": "Gave [{item_name}§f] x{item_count} to {player_name}.",
   "text.rei.failed_cheat_items": "§cFailed to give items.",
   "ordering.rei.ascending": "Ascending",

BIN
src/main/resources/assets/roughlyenoughitems/textures/gui/button.png


BIN
src/main/resources/assets/roughlyenoughitems/textures/gui/button_dark.png


BIN
src/main/resources/assets/roughlyenoughitems/textures/gui/display.png


BIN
src/main/resources/assets/roughlyenoughitems/textures/gui/display_dark.png


BIN
src/main/resources/assets/roughlyenoughitems/textures/gui/kirb.png


BIN
src/main/resources/assets/roughlyenoughitems/textures/gui/recipecontainer.png


BIN
src/main/resources/assets/roughlyenoughitems/textures/gui/recipecontainer_dark.png


BIN
src/main/resources/assets/roughlyenoughitems/textures/gui/screenshot.png


BIN
src/main/resources/assets/roughlyenoughitems/textures/gui/toasts.png


BIN
src/main/resources/icon.png