shedaniel 5 년 전
부모
커밋
93534c9b5c

+ 0 - 8
build.gradle

@@ -57,10 +57,6 @@ dependencies {
     modImplementation("me.shedaniel.cloth:config-2:${cloth_config_version}") {
         transitive = false
     }
-    modApi("me.shedaniel.cloth:fiber2cloth:1.2.1") {
-        transitive = false
-    }
-    modApi "me.zeroeightsix:fiber:0.6.0-7"
     modApi("me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig1u}")
     if (includeDep) {
         include("me.shedaniel.cloth:cloth-events:${cloth_events_version}") {
@@ -69,13 +65,9 @@ dependencies {
         include("me.shedaniel.cloth:config-2:${cloth_config_version}") {
             transitive = false
         }
-        include("me.shedaniel.cloth:fiber2cloth:1.2.1") {
-            transitive = false
-        }
         include("me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig1u}") {
             transitive = false
         }
-        include "me.zeroeightsix:fiber:0.6.0-7"
     }
     modImplementation "io.github.prospector:modmenu:${modmenu_version}"
     compile "org.lwjgl:lwjgl-jemalloc:3.2.1"

+ 2 - 2
gradle.properties

@@ -1,4 +1,4 @@
-mod_version=3.2.9-unstable
+mod_version=3.2.10-unstable
 minecraft_version=1.15-pre1
 yarn_version=1.15-pre1+build.3
 fabricloader_version=0.7.1+build.173
@@ -6,4 +6,4 @@ cloth_events_version=1.0.1-unstable.201911010702
 cloth_config_version=2.4-unstable.201911031154
 modmenu_version=1.7.15-unstable.19w42a+build.11
 fabric_api=0.4.13+build.263-1.15
-autoconfig1u=1.1.0
+autoconfig1u=1.2.3

+ 1 - 11
src/main/java/me/shedaniel/rei/api/ConfigManager.java

@@ -6,7 +6,6 @@
 package me.shedaniel.rei.api;
 
 import me.shedaniel.rei.RoughlyEnoughItemsCore;
-import me.zeroeightsix.fiber.exception.FiberException;
 import net.minecraft.client.gui.screen.Screen;
 
 import java.io.IOException;
@@ -20,17 +19,8 @@ public interface ConfigManager {
     
     /**
      * Saves the config.
-     *
-     * @throws IOException when error
-     */
-    void saveConfig() throws IOException, FiberException;
-    
-    /**
-     * Loads the config from the json file, creates the file if not found.
-     *
-     * @throws IOException when error
      */
-    void loadConfig() throws IOException, FiberException;
+    void saveConfig();
     
     /**
      * Gets the config instance

+ 10 - 9
src/main/java/me/shedaniel/rei/api/ConfigObject.java

@@ -9,18 +9,14 @@ import me.shedaniel.rei.gui.config.ItemCheatingMode;
 import me.shedaniel.rei.gui.config.ItemListOrdering;
 import me.shedaniel.rei.gui.config.RecipeScreenType;
 import me.shedaniel.rei.gui.config.SearchFieldLocation;
-import me.zeroeightsix.fiber.tree.ConfigNode;
-import me.zeroeightsix.fiber.tree.ConfigValue;
-import me.zeroeightsix.fiber.tree.Node;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
 
 public interface ConfigObject {
     
-    Node getGeneral();
-    
-    ConfigNode getConfigNode();
-    
-    ConfigValue<Boolean> getOverlayVisibleNode();
-    
     boolean isLighterButtonHover();
     
     void setLighterButtonHover(boolean lighterButtonHover);
@@ -83,4 +79,9 @@ public interface ConfigObject {
     
     boolean doesRegisterRecipesInAnotherThread();
     
+    @Retention(RetentionPolicy.RUNTIME)
+    @Target({ElementType.FIELD})
+    public @interface DontApplyFieldName {
+    }
+    
 }

+ 3 - 3
src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java

@@ -164,7 +164,7 @@ public class ContainerScreenOverlay extends Widget {
         
         if (setPage)
             page = MathHelper.clamp(page, 0, getTotalPage());
-    
+        
         widgets.add(new ButtonWidget(new Rectangle(ConfigManager.getInstance().getConfig().isLeftHandSidePanel() ? window.getScaledWidth() - 30 : 10, 10, 20, 20), "") {
             @Override
             public void onPressed() {
@@ -182,9 +182,9 @@ public class ContainerScreenOverlay extends Widget {
                 Rectangle bounds = getBounds();
                 if (ClientHelper.getInstance().isCheating() && RoughlyEnoughItemsCore.hasOperatorPermission()) {
                     if (RoughlyEnoughItemsCore.hasPermissionToUsePackets())
-                        fill(bounds.x + 1, bounds.y+ 1, bounds.getMaxX() - 1, bounds.getMaxY() - 1, 721354752);
+                        fill(bounds.x + 1, bounds.y + 1, bounds.getMaxX() - 1, bounds.getMaxY() - 1, 721354752);
                     else
-                        fill(bounds.x+ 1, bounds.y+ 1, bounds.getMaxX() - 1, bounds.getMaxY() - 1, 1476440063);
+                        fill(bounds.x + 1, bounds.y + 1, bounds.getMaxX() - 1, bounds.getMaxY() - 1, 1476440063);
                 }
                 MinecraftClient.getInstance().getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
                 RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);

+ 1 - 7
src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java

@@ -16,7 +16,6 @@ import me.shedaniel.rei.gui.widget.ButtonWidget;
 import me.shedaniel.rei.gui.widget.Widget;
 import me.shedaniel.rei.gui.widget.WidgetWithBounds;
 import me.shedaniel.rei.impl.ScreenHelper;
-import me.zeroeightsix.fiber.exception.FiberException;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.Element;
 import net.minecraft.client.gui.screen.Screen;
@@ -28,7 +27,6 @@ import net.minecraft.text.TranslatableText;
 import net.minecraft.util.Formatting;
 import net.minecraft.util.Identifier;
 
-import java.io.IOException;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -55,11 +53,7 @@ public class PreRecipeViewingScreen extends Screen {
             @Override
             public void onPressed() {
                 ConfigManager.getInstance().getConfig().setRecipeScreenType(original ? RecipeScreenType.ORIGINAL : RecipeScreenType.VILLAGER);
-                try {
-                    ConfigManager.getInstance().saveConfig();
-                } catch (IOException | FiberException e) {
-                    e.printStackTrace();
-                }
+                ConfigManager.getInstance().saveConfig();
                 ClientHelper.getInstance().openRecipeViewingScreen(map);
             }
         });

+ 1 - 1
src/main/java/me/shedaniel/rei/gui/entries/RecipeEntry.java

@@ -104,9 +104,9 @@ public abstract class RecipeEntry extends DrawableHelper implements EntryStack {
         return this;
     }
     
+    @SuppressWarnings("deprecation")
     @Override
     public <T> ObjectHolder<T> getSetting(Settings<T> settings) {
-        //noinspection deprecation
         return new ObjectHolderImpl<>(settings.getDefaultValue());
     }
     

+ 1 - 7
src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java

@@ -16,7 +16,6 @@ import me.shedaniel.rei.gui.PreRecipeViewingScreen;
 import me.shedaniel.rei.gui.RecipeViewingScreen;
 import me.shedaniel.rei.gui.VillagerRecipeViewingScreen;
 import me.shedaniel.rei.gui.config.RecipeScreenType;
-import me.zeroeightsix.fiber.exception.FiberException;
 import net.fabricmc.api.ClientModInitializer;
 import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
 import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
@@ -38,7 +37,6 @@ import net.minecraft.util.Identifier;
 import net.minecraft.util.PacketByteBuf;
 import net.minecraft.util.registry.Registry;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -138,11 +136,7 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer {
     @Override
     public void setCheating(boolean cheating) {
         ConfigManager.getInstance().getConfig().setCheating(cheating);
-        try {
-            ConfigManager.getInstance().saveConfig();
-        } catch (IOException | FiberException e) {
-            e.printStackTrace();
-        }
+        ConfigManager.getInstance().saveConfig();
     }
     
     @Override

+ 16 - 61
src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java

@@ -5,87 +5,40 @@
 
 package me.shedaniel.rei.impl;
 
+import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
+import me.sargunvohra.mcmods.autoconfig1u.gui.ConfigScreenProvider;
+import me.sargunvohra.mcmods.autoconfig1u.serializer.JanksonConfigSerializer;
 import me.shedaniel.rei.RoughlyEnoughItemsCore;
 import me.shedaniel.rei.api.ConfigManager;
 import me.shedaniel.rei.api.ConfigObject;
 import me.shedaniel.rei.api.annotations.Internal;
-import me.zeroeightsix.fiber.JanksonSettings;
-import me.zeroeightsix.fiber.exception.FiberException;
-import net.fabricmc.loader.api.FabricLoader;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.screen.Screen;
 import net.minecraft.client.resource.language.I18n;
 import net.minecraft.text.LiteralText;
 
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
 import java.util.List;
 
 @Deprecated
 @Internal
 public class ConfigManagerImpl implements ConfigManager {
     
-    private final File configFile;
-    private ConfigObject config;
     private boolean craftableOnly;
     
     public ConfigManagerImpl() {
-        this.configFile = new File(FabricLoader.getInstance().getConfigDirectory(), "roughlyenoughitems/config.json5");
         this.craftableOnly = false;
-        try {
-            loadConfig();
-            RoughlyEnoughItemsCore.LOGGER.info("[REI] Config is loaded.");
-        } catch (IOException | FiberException e) {
-            e.printStackTrace();
-        }
+        AutoConfig.register(ConfigObjectImpl.class, JanksonConfigSerializer::new);
+        RoughlyEnoughItemsCore.LOGGER.info("[REI] Config is loaded.");
     }
     
     @Override
-    public void saveConfig() throws IOException, FiberException {
-        configFile.getParentFile().mkdirs();
-        if (!configFile.exists() && !configFile.createNewFile()) {
-            RoughlyEnoughItemsCore.LOGGER.error("[REI] Failed to save config! Overwriting with default config.");
-            config = new OldConfigObjectImpl();
-            return;
-        }
-        try {
-            new JanksonSettings().serialize(config.getConfigNode(), Files.newOutputStream(configFile.toPath()), false);
-        } catch (Exception e) {
-            e.printStackTrace();
-            RoughlyEnoughItemsCore.LOGGER.error("[REI] Failed to save config! Overwriting with default config.");
-            config = new OldConfigObjectImpl();
-            return;
-        }
-    }
-    
-    @Override
-    public void loadConfig() throws IOException, FiberException {
-        configFile.getParentFile().mkdirs();
-        if (!configFile.exists() || !configFile.canRead()) {
-            RoughlyEnoughItemsCore.LOGGER.warn("[REI] Config not found! Creating one.");
-            config = new OldConfigObjectImpl();
-            saveConfig();
-            return;
-        }
-        boolean failed = false;
-        try {
-            config = new OldConfigObjectImpl();
-            new JanksonSettings().deserialize(config.getConfigNode(), Files.newInputStream(configFile.toPath()));
-        } catch (Exception e) {
-            e.printStackTrace();
-            failed = true;
-        }
-        if (failed || config == null) {
-            RoughlyEnoughItemsCore.LOGGER.error("[REI] Failed to load config! Overwriting with default config.");
-            config = new OldConfigObjectImpl();
-        }
-        saveConfig();
+    public void saveConfig() {
+        ((me.sargunvohra.mcmods.autoconfig1u.ConfigManager<ConfigObjectImpl>) AutoConfig.getConfigHolder(ConfigObjectImpl.class)).save();
     }
     
     @Override
     public ConfigObject getConfig() {
-        return config;
+        return AutoConfig.getConfigHolder(ConfigObjectImpl.class).getConfig();
     }
     
     @Override
@@ -105,12 +58,14 @@ public class ConfigManagerImpl implements ConfigManager {
     
     @Override
     public Screen getConfigScreen(Screen parent) {
-        if (FabricLoader.getInstance().isModLoaded("cloth-config2")) {
-            try {
-                return Screen.class.cast(Class.forName("me.shedaniel.rei.utils.ClothScreenRegistry").getDeclaredMethod("getConfigScreen", Screen.class).invoke(null, parent));
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
+        try {
+            ConfigScreenProvider<ConfigObjectImpl> provider = (ConfigScreenProvider<ConfigObjectImpl>) AutoConfig.getConfigScreen(ConfigObjectImpl.class, parent);
+            provider.setI13nFunction(manager -> "config.roughlyenoughitems");
+            provider.setOptionFunction((baseI13n, field) -> field.isAnnotationPresent(ConfigObject.DontApplyFieldName.class) ? baseI13n : String.format("%s.%s", baseI13n, field.getName()));
+            provider.setCategoryFunction((baseI13n, categoryName) -> String.format("%s.%s", baseI13n, categoryName));
+            return provider.get();
+        } catch (Exception e) {
+            e.printStackTrace();
         }
         return new Screen(new LiteralText("")) {
             @Override

+ 257 - 0
src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java

@@ -0,0 +1,257 @@
+/*
+ * Roughly Enough Items by Danielshe.
+ * Licensed under the MIT License.
+ */
+
+package me.shedaniel.rei.impl;
+
+import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
+import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
+import me.sargunvohra.mcmods.autoconfig1u.annotation.ConfigEntry;
+import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.Comment;
+import me.shedaniel.rei.api.ConfigObject;
+import me.shedaniel.rei.api.annotations.Internal;
+import me.shedaniel.rei.gui.config.*;
+
+@Deprecated
+@Internal
+@Config(name = "roughlyenoughitems/config")
+public class ConfigObjectImpl implements ConfigObject, ConfigData {
+    
+    @ConfigEntry.Category("!general")
+    @ConfigEntry.Gui.TransitiveObject
+    @DontApplyFieldName
+    private General general = new General();
+    
+    @ConfigEntry.Category("appearance")
+    @ConfigEntry.Gui.TransitiveObject
+    @DontApplyFieldName
+    private Appearance appearance = new Appearance();
+    
+    @ConfigEntry.Category("modules")
+    @ConfigEntry.Gui.TransitiveObject
+    @DontApplyFieldName
+    private Modules modules = new Modules();
+    
+    @ConfigEntry.Category("technical")
+    @ConfigEntry.Gui.TransitiveObject
+    @DontApplyFieldName
+    private Technical technical = new Technical();
+    
+    @Override
+    public boolean isLighterButtonHover() {
+        return appearance.lighterButtonHover;
+    }
+    
+    @Override
+    public void setLighterButtonHover(boolean lighterButtonHover) {
+        appearance.lighterButtonHover = lighterButtonHover;
+    }
+    
+    @Override
+    public boolean isOverlayVisible() {
+        return general.overlayVisible;
+    }
+    
+    @Override
+    public void setOverlayVisible(boolean overlayVisible) {
+        general.overlayVisible = overlayVisible;
+    }
+    
+    @Override
+    public boolean isCheating() {
+        return general.cheating;
+    }
+    
+    @Override
+    public void setCheating(boolean cheating) {
+        general.cheating = cheating;
+    }
+    
+    @Override
+    public ItemListOrdering getItemListOrdering() {
+        return appearance.itemListOrdering.getOrdering();
+    }
+    
+    @Override
+    public boolean isItemListAscending() {
+        return appearance.itemListOrdering.isAscending();
+    }
+    
+    @Override
+    public boolean isUsingDarkTheme() {
+        return appearance.darkTheme;
+    }
+    
+    @Override
+    public boolean isToastDisplayedOnCopyIdentifier() {
+        return modules.toastDisplayedOnCopyIdentifier;
+    }
+    
+    @Override
+    public boolean doesRenderEntryExtraOverlay() {
+        return appearance.renderEntryExtraOverlay;
+    }
+    
+    @Override
+    public boolean isEntryListWidgetScrolled() {
+        return appearance.scrollingEntryListWidget;
+    }
+    
+    @Override
+    public boolean shouldAppendModNames() {
+        return appearance.appendModNames;
+    }
+    
+    @Override
+    public RecipeScreenType getRecipeScreenType() {
+        return appearance.recipeScreenType;
+    }
+    
+    @Override
+    public void setRecipeScreenType(RecipeScreenType recipeScreenType) {
+        appearance.recipeScreenType = recipeScreenType;
+    }
+    
+    @Override
+    public boolean isLoadingDefaultPlugin() {
+        return technical.loadDefaultPlugin;
+    }
+    
+    @Override
+    public SearchFieldLocation getSearchFieldLocation() {
+        return appearance.searchFieldLocation;
+    }
+    
+    @Override
+    public boolean isLeftHandSidePanel() {
+        return appearance.mirrorItemPanel;
+    }
+    
+    @Override
+    public boolean isCraftableFilterEnabled() {
+        return modules.enableCraftableOnlyButton;
+    }
+    
+    @Override
+    public String getGamemodeCommand() {
+        return technical.gamemodeCommand;
+    }
+    
+    @Override
+    public String getGiveCommand() {
+        return technical.giveCommand;
+    }
+    
+    @Override
+    public String getWeatherCommand() {
+        return technical.weatherCommand;
+    }
+    
+    @Override
+    public int getMaxRecipePerPage() {
+        return appearance.maxRecipePerPage;
+    }
+    
+    @Override
+    public boolean doesShowUtilsButtons() {
+        return modules.showUtilsButtons;
+    }
+    
+    @Override
+    public boolean doesDisableRecipeBook() {
+        return modules.disableRecipeBook;
+    }
+    
+    @Override
+    public boolean doesFixTabCloseContainer() {
+        return modules.fixTabCloseContainer;
+    }
+    
+    @Override
+    public boolean areClickableRecipeArrowsEnabled() {
+        return appearance.clickableRecipeArrows;
+    }
+    
+    @Override
+    public ItemCheatingMode getItemCheatingMode() {
+        return appearance.itemCheatingMode;
+    }
+    
+    @Override
+    public boolean isUsingLightGrayRecipeBorder() {
+        return appearance.lightGrayRecipeBorder;
+    }
+    
+    @Override
+    public boolean doesVillagerScreenHavePermanentScrollBar() {
+        return appearance.villagerScreenPermanentScrollBar;
+    }
+    
+    @Override
+    public boolean doesRegisterRecipesInAnotherThread() {
+        return technical.registerRecipesInAnotherThread;
+    }
+    
+    public static class General {
+        @Comment("Declares whether cheating mode is on.")
+        private boolean cheating = false;
+        @Comment("Declares whether REI is visible.")
+        @ConfigEntry.Gui.Excluded
+        private boolean overlayVisible = true;
+    }
+    
+    public static class Appearance {
+        @Comment("The ordering of the items on the item panel.")
+        private ItemListOrderingConfig itemListOrdering = ItemListOrderingConfig.REGISTRY_ASCENDING;
+        @Comment("Declares the appearance of REI windows.")
+        private boolean darkTheme = false;
+        @Comment("Whether REI should render entry's overlay.\nExample: Enchantment Glint")
+        private boolean renderEntryExtraOverlay = true;
+        @Comment("The ordering of the items on the item panel.")
+        private RecipeScreenType recipeScreenType = RecipeScreenType.UNSET;
+        @Comment("Declares the position of the search field.")
+        private SearchFieldLocation searchFieldLocation = SearchFieldLocation.CENTER;
+        @Comment("Declares the position of the item list panel.")
+        private boolean mirrorItemPanel = false;
+        @Comment("Declares the maximum amount of recipes displayed in a page if possible.")
+        @ConfigEntry.BoundedDiscrete(min = 2, max = 99)
+        private int maxRecipePerPage = 3;
+        @Comment("Declares whether REI should lighten the button if hovered.")
+        private boolean lighterButtonHover = true;
+        private boolean clickableRecipeArrows = true;
+        private ItemCheatingMode itemCheatingMode = ItemCheatingMode.REI_LIKE;
+        @Comment("Declares the appearance of recipe's border.")
+        private boolean lightGrayRecipeBorder = false;
+        @Comment("Declares whether REI should append mod names to item stacks.")
+        private boolean appendModNames = true;
+        @Comment("Declares how the scrollbar in villager screen should act.")
+        private boolean villagerScreenPermanentScrollBar = false;
+        @Comment("Declares whether if entry list widget is scrolled.")
+        private boolean scrollingEntryListWidget = false;
+    }
+    
+    public static class Technical {
+        @Comment("To disable REI's default plugin.\nDon't change this unless you understand what you are doing!")
+        private boolean loadDefaultPlugin = true;
+        @Comment("Declares the command used to change gamemode.")
+        private String gamemodeCommand = "/gamemode {gamemode}";
+        @Comment("Declares the command used in servers to cheat items.")
+        private String giveCommand = "/give {player_name} {item_identifier}{nbt} {count}";
+        @Comment("Declares the command used to change weather.")
+        private String weatherCommand = "/weather {weather}";
+        private boolean registerRecipesInAnotherThread = true;
+    }
+    
+    public static class Modules {
+        @Comment("Declares whether the craftable filter button is enabled.")
+        private boolean enableCraftableOnlyButton = true;
+        private boolean toastDisplayedOnCopyIdentifier = true;
+        @Comment("Declares whether the utils buttons are shown.")
+        private boolean showUtilsButtons = false;
+        @Comment("Declares whether REI should remove the recipe book.")
+        private boolean disableRecipeBook = false;
+        @Comment("Declares whether REI should fix closing container with tab.")
+        private boolean fixTabCloseContainer = false;
+    }
+}

+ 0 - 381
src/main/java/me/shedaniel/rei/impl/OldConfigObjectImpl.java

@@ -1,381 +0,0 @@
-/*
- * Roughly Enough Items by Danielshe.
- * Licensed under the MIT License.
- */
-
-package me.shedaniel.rei.impl;
-
-import me.shedaniel.rei.api.ConfigObject;
-import me.shedaniel.rei.api.annotations.Internal;
-import me.shedaniel.rei.gui.config.*;
-import me.zeroeightsix.fiber.exception.FiberException;
-import me.zeroeightsix.fiber.tree.ConfigNode;
-import me.zeroeightsix.fiber.tree.ConfigValue;
-import me.zeroeightsix.fiber.tree.Node;
-
-@Deprecated
-@Internal
-public class OldConfigObjectImpl implements ConfigObject {
-    
-    public ConfigNode configNode = new ConfigNode();
-    
-    private Node general = configNode.fork("!general");
-    private Node appearance = configNode.fork("appearance");
-    private Node modules = configNode.fork("modules");
-    private Node technical = configNode.fork("technical");
-    
-    private ConfigValue<Boolean> cheating = ConfigValue.builder(Boolean.class)
-            .withParent(general)
-            .withDefaultValue(false)
-            .withComment("Declares whether cheating mode is on.")
-            .withName("cheating")
-            .build();
-    
-    private ConfigValue<ItemListOrderingConfig> itemListOrdering = ConfigValue.builder(ItemListOrderingConfig.class)
-            .withParent(appearance)
-            .withDefaultValue(ItemListOrderingConfig.REGISTRY_ASCENDING)
-            .withComment("The ordering of the items on the item panel.")
-            .withName("itemListOrdering")
-            .build();
-    
-    private ConfigValue<Boolean> darkTheme = ConfigValue.builder(Boolean.class)
-            .withParent(appearance)
-            .withDefaultValue(false)
-            .withComment("Declares the appearance of REI windows.")
-            .withName("darkTheme")
-            .build();
-    
-    private ConfigValue<Boolean> renderEntryExtraOverlay = ConfigValue.builder(Boolean.class)
-            .withParent(appearance)
-            .withDefaultValue(true)
-            .withComment("Whether REI should render entry's overlay.\nExample: Enchantment Glint")
-            .withName("renderEntryExtraOverlay")
-            .build();
-    
-    private ConfigValue<RecipeScreenType> recipeScreenType = ConfigValue.builder(RecipeScreenType.class)
-            .withParent(appearance)
-            .withDefaultValue(RecipeScreenType.UNSET)
-            .withComment("The ordering of the items on the item panel.")
-            .withName("recipeScreenType")
-            .build();
-    
-    private ConfigValue<Boolean> loadDefaultPlugin = ConfigValue.builder(Boolean.class)
-            .withParent(technical)
-            .withDefaultValue(true)
-            .withComment("To disable REI's default plugin.\nDon't change this unless you understand what you are doing")
-            .withName("loadDefaultPlugin")
-            .build();
-    
-    private ConfigValue<SearchFieldLocation> sideSearchField = ConfigValue.builder(SearchFieldLocation.class)
-            .withParent(appearance)
-            .withDefaultValue(SearchFieldLocation.CENTER)
-            .withComment("Declares the position of the search field.")
-            .withName("searchFieldLocation")
-            .build();
-    
-    private ConfigValue<Boolean> mirrorItemPanel = ConfigValue.builder(Boolean.class)
-            .withParent(appearance)
-            .withDefaultValue(false)
-            .withComment("Declares the position of the item list panel.")
-            .withName("mirrorItemPanel")
-            .build();
-    
-    private ConfigValue<Boolean> enableCraftableOnlyButton = ConfigValue.builder(Boolean.class)
-            .withParent(modules)
-            .withDefaultValue(true)
-            .withComment("Declares whether the craftable filter button is enabled.")
-            .withName("enableCraftableOnlyButton")
-            .build();
-    
-    private ConfigValue<Boolean> toastDisplayedOnCopyIdentifier = ConfigValue.builder(Boolean.class)
-            .withParent(modules)
-            .withDefaultValue(true)
-            .withName("toastDisplayedOnCopyIdentifier")
-            .build();
-    
-    private ConfigValue<String> gamemodeCommand = ConfigValue.builder(String.class)
-            .withParent(technical)
-            .withDefaultValue("/gamemode {gamemode}")
-            .withComment("Declares the command used to change gamemode.")
-            .withName("gamemodeCommand")
-            .build();
-    
-    private ConfigValue<String> giveCommand = ConfigValue.builder(String.class)
-            .withParent(technical)
-            .withDefaultValue("/give {player_name} {item_identifier}{nbt} {count}")
-            .withComment("Declares the command used in servers to cheat items.")
-            .withName("giveCommand")
-            .build();
-    
-    private ConfigValue<String> weatherCommand = ConfigValue.builder(String.class)
-            .withParent(technical)
-            .withDefaultValue("/weather {weather}")
-            .withComment("Declares the command used to change weather.")
-            .withName("weatherCommand")
-            .build();
-    
-    private ConfigValue<Integer> maxRecipePerPage = ConfigValue.builder(Integer.class)
-            .withParent(appearance)
-            .withDefaultValue(3)
-            .withComment("Declares the maximum amount of recipes displayed in a page if possible.")
-            .withName("maxRecipePerPage")
-            .constraints()
-            .minNumerical(2)
-            .maxNumerical(99)
-            .finish()
-            .build();
-    
-    private ConfigValue<Boolean> showUtilsButtons = ConfigValue.builder(Boolean.class)
-            .withParent(modules)
-            .withDefaultValue(false)
-            .withComment("Declares whether the utils buttons are shown.")
-            .withName("showUtilsButtons")
-            .build();
-    
-    private ConfigValue<Boolean> disableRecipeBook = ConfigValue.builder(Boolean.class)
-            .withParent(modules)
-            .withDefaultValue(false)
-            .withComment("Declares whether REI should remove the recipe book.")
-            .withName("disableRecipeBook")
-            .build();
-    
-    private ConfigValue<Boolean> lighterButtonHover = ConfigValue.builder(Boolean.class)
-            .withParent(appearance)
-            .withDefaultValue(true)
-            .withComment("Declares whether REI should lighten the button if hovered.")
-            .withName("lighterButtonHover")
-            .build();
-    
-    private ConfigValue<Boolean> fixTabCloseContainer = ConfigValue.builder(Boolean.class)
-            .withParent(modules)
-            .withDefaultValue(false)
-            .withComment("Declares whether REI should fix closing container with tab.")
-            .withName("fixTabCloseContainer")
-            .build();
-    
-    private ConfigValue<Boolean> clickableRecipeArrows = ConfigValue.builder(Boolean.class)
-            .withParent(appearance)
-            .withDefaultValue(true)
-            .withName("clickableRecipeArrows")
-            .build();
-    
-    private ConfigValue<ItemCheatingMode> itemCheatingMode = ConfigValue.builder(ItemCheatingMode.class)
-            .withParent(appearance)
-            .withDefaultValue(ItemCheatingMode.REI_LIKE)
-            .withName("itemCheatingMode")
-            .build();
-    
-    private ConfigValue<Boolean> lightGrayRecipeBorder = ConfigValue.builder(Boolean.class)
-            .withParent(appearance)
-            .withDefaultValue(false)
-            .withComment("Declares the appearance of recipe's border.")
-            .withName("lightGrayRecipeBorder")
-            .build();
-    
-    private ConfigValue<Boolean> appendModNames = ConfigValue.builder(Boolean.class)
-            .withParent(appearance)
-            .withDefaultValue(false)
-            .withComment("Declares whether REI should append mod names to item stacks.")
-            .withName("appendModNames")
-            .build();
-    
-    private ConfigValue<Boolean> villagerScreenPermanentScrollBar = ConfigValue.builder(Boolean.class)
-            .withParent(appearance)
-            .withDefaultValue(false)
-            .withComment("Declares how the scrollbar in villager screen act.")
-            .withName("villagerScreenPermanentScrollBar")
-            .build();
-    
-    private ConfigValue<Boolean> registerRecipesInAnotherThread = ConfigValue.builder(Boolean.class)
-            .withParent(technical)
-            .withDefaultValue(true)
-            .withName("registerRecipesInAnotherThread")
-            .build();
-    
-    private ConfigValue<Boolean> scrollingEntryListWidget = ConfigValue.builder(Boolean.class)
-            .withParent(appearance)
-            .withDefaultValue(false)
-            .withComment("Declares whether if entry list widget is scrolled.")
-            .withName("scrollingEntryListWidget")
-            .build();
-    
-    private ConfigValue<Boolean> overlayVisible = ConfigValue.builder(Boolean.class)
-            .withParent(general)
-            .withDefaultValue(true)
-            .withName("overlayVisible")
-            .build();
-    
-    public OldConfigObjectImpl() throws FiberException {
-    
-    }
-    
-    @Override
-    public Node getGeneral() {
-        return general;
-    }
-    
-    @Override
-    public ConfigNode getConfigNode() {
-        return configNode;
-    }
-    
-    @Override
-    public ConfigValue<Boolean> getOverlayVisibleNode() {
-        return overlayVisible;
-    }
-    
-    @Override
-    public boolean isLighterButtonHover() {
-        return this.lighterButtonHover.getValue();
-    }
-    
-    @Override
-    public void setLighterButtonHover(boolean lighterButtonHover) {
-        this.lighterButtonHover.setValue(lighterButtonHover);
-    }
-    
-    @Override
-    public boolean isOverlayVisible() {
-        return this.overlayVisible.getValue();
-    }
-    
-    @Override
-    public void setOverlayVisible(boolean overlayVisible) {
-        this.overlayVisible.setValue(overlayVisible);
-    }
-    
-    @Override
-    public boolean isCheating() {
-        return cheating.getValue();
-    }
-    
-    @Override
-    public void setCheating(boolean cheating) {
-        this.cheating.setValue(cheating);
-    }
-    
-    @Override
-    public ItemListOrdering getItemListOrdering() {
-        return itemListOrdering.getValue().getOrdering();
-    }
-    
-    @Override
-    public boolean isItemListAscending() {
-        return itemListOrdering.getValue().isAscending();
-    }
-    
-    @Override
-    public boolean isUsingDarkTheme() {
-        return darkTheme.getValue().booleanValue();
-    }
-    
-    @Override
-    public boolean isToastDisplayedOnCopyIdentifier() {
-        return toastDisplayedOnCopyIdentifier.getValue();
-    }
-    
-    @Override
-    public boolean doesRenderEntryExtraOverlay() {
-        return renderEntryExtraOverlay.getValue().booleanValue();
-    }
-    
-    @Override
-    public boolean isEntryListWidgetScrolled() {
-        return scrollingEntryListWidget.getValue().booleanValue();
-    }
-    
-    @Override
-    public boolean shouldAppendModNames() {
-        return appendModNames.getValue().booleanValue();
-    }
-    
-    @Override
-    public RecipeScreenType getRecipeScreenType() {
-        return recipeScreenType.getValue();
-    }
-    
-    @Override
-    public void setRecipeScreenType(RecipeScreenType recipeScreenType) {
-        this.recipeScreenType.setValue(recipeScreenType);
-    }
-    
-    @Override
-    public boolean isLoadingDefaultPlugin() {
-        return loadDefaultPlugin.getValue().booleanValue();
-    }
-    
-    @Override
-    public SearchFieldLocation getSearchFieldLocation() {
-        return sideSearchField.getValue();
-    }
-    
-    @Override
-    public boolean isLeftHandSidePanel() {
-        return mirrorItemPanel.getValue().booleanValue();
-    }
-    
-    @Override
-    public boolean isCraftableFilterEnabled() {
-        return enableCraftableOnlyButton.getValue().booleanValue();
-    }
-    
-    @Override
-    public String getGamemodeCommand() {
-        return gamemodeCommand.getValue();
-    }
-    
-    @Override
-    public String getGiveCommand() {
-        return giveCommand.getValue();
-    }
-    
-    @Override
-    public String getWeatherCommand() {
-        return weatherCommand.getValue();
-    }
-    
-    @Override
-    public int getMaxRecipePerPage() {
-        return maxRecipePerPage.getValue().intValue();
-    }
-    
-    @Override
-    public boolean doesShowUtilsButtons() {
-        return showUtilsButtons.getValue().booleanValue();
-    }
-    
-    @Override
-    public boolean doesDisableRecipeBook() {
-        return disableRecipeBook.getValue().booleanValue();
-    }
-    
-    @Override
-    public boolean doesFixTabCloseContainer() {
-        return fixTabCloseContainer.getValue().booleanValue();
-    }
-    
-    @Override
-    public boolean areClickableRecipeArrowsEnabled() {
-        return clickableRecipeArrows.getValue().booleanValue();
-    }
-    
-    @Override
-    public ItemCheatingMode getItemCheatingMode() {
-        return itemCheatingMode.getValue();
-    }
-    
-    @Override
-    public boolean isUsingLightGrayRecipeBorder() {
-        return lightGrayRecipeBorder.getValue().booleanValue();
-    }
-    
-    @Override
-    public boolean doesVillagerScreenHavePermanentScrollBar() {
-        return villagerScreenPermanentScrollBar.getValue().booleanValue();
-    }
-    
-    @Override
-    public boolean doesRegisterRecipesInAnotherThread() {
-        return registerRecipesInAnotherThread.getValue().booleanValue();
-    }
-}

+ 1 - 7
src/main/java/me/shedaniel/rei/impl/ScreenHelper.java

@@ -13,7 +13,6 @@ import me.shedaniel.rei.api.ConfigManager;
 import me.shedaniel.rei.gui.ContainerScreenOverlay;
 import me.shedaniel.rei.gui.OverlaySearchField;
 import me.shedaniel.rei.listeners.ContainerScreenHooks;
-import me.zeroeightsix.fiber.exception.FiberException;
 import net.fabricmc.api.ClientModInitializer;
 import net.fabricmc.fabric.api.event.client.ClientTickCallback;
 import net.minecraft.client.MinecraftClient;
@@ -24,7 +23,6 @@ import net.minecraft.item.ItemStack;
 import net.minecraft.util.ActionResult;
 import org.apache.logging.log4j.util.TriConsumer;
 
-import java.io.IOException;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Optional;
@@ -77,11 +75,7 @@ public class ScreenHelper implements ClientModInitializer {
     
     public static void toggleOverlayVisible() {
         ConfigManager.getInstance().getConfig().setOverlayVisible(!ConfigManager.getInstance().getConfig().isOverlayVisible());
-        try {
-            ConfigManager.getInstance().saveConfig();
-        } catch (IOException | FiberException e) {
-            e.printStackTrace();
-        }
+        ConfigManager.getInstance().saveConfig();
     }
     
     public static Optional<ContainerScreenOverlay> getOptionalOverlay() {

+ 0 - 85
src/main/java/me/shedaniel/rei/utils/ClothScreenRegistry.java

@@ -1,85 +0,0 @@
-/*
- * Roughly Enough Items by Danielshe.
- * Licensed under the MIT License.
- */
-
-package me.shedaniel.rei.utils;
-
-import me.shedaniel.cloth.hooks.ScreenHooks;
-import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
-import me.shedaniel.fiber2cloth.api.Fiber2Cloth;
-import me.shedaniel.rei.api.ConfigManager;
-import me.shedaniel.rei.gui.config.ItemCheatingMode;
-import me.shedaniel.rei.gui.config.ItemListOrderingConfig;
-import me.shedaniel.rei.gui.config.RecipeScreenType;
-import me.shedaniel.rei.gui.config.SearchFieldLocation;
-import me.shedaniel.rei.gui.credits.CreditsScreen;
-import me.zeroeightsix.fiber.exception.FiberException;
-import me.zeroeightsix.fiber.tree.ConfigValue;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.gui.widget.AbstractPressableButtonWidget;
-import net.minecraft.client.resource.language.I18n;
-
-import java.io.IOException;
-import java.util.List;
-
-import static me.shedaniel.fiber2cloth.impl.Fiber2ClothImpl.error;
-import static me.shedaniel.fiber2cloth.impl.Fiber2ClothImpl.splitLine;
-
-public class ClothScreenRegistry {
-    
-    public static Screen getConfigScreen(Screen parent) {
-        final ConfigManager configManager = ConfigManager.getInstance();
-        ConfigEntryBuilder configEntryBuilder = ConfigEntryBuilder.create();
-        return Fiber2Cloth.create(parent, "roughlyenoughitems", configManager.getConfig().getConfigNode(), "config.roughlyenoughitems.title").setSaveRunnable(() -> {
-            try {
-                configManager.saveConfig();
-            } catch (IOException | FiberException e) {
-                e.printStackTrace();
-            }
-        }).hideTreeEntry(
-                configManager.getConfig().getOverlayVisibleNode()
-        ).registerNodeEntryFunction(ItemListOrderingConfig.class, o -> {
-            ConfigValue<ItemListOrderingConfig> configValue = (ConfigValue<ItemListOrderingConfig>) o;
-            return configEntryBuilder.startEnumSelector("config.roughlyenoughitems." + configValue.getName(), ItemListOrderingConfig.class, configValue.getValue())
-                    .setDefaultValue(configValue.getDefaultValue())
-                    .setTooltip(splitLine(configValue.getComment()))
-                    .setSaveConsumer(var -> configValue.setValue((ItemListOrderingConfig) var))
-                    .setErrorSupplier(var -> error((List) configValue.getConstraints(), var, ItemListOrderingConfig.class))
-                    .build();
-        }).registerNodeEntryFunction(RecipeScreenType.class, o -> {
-            ConfigValue<RecipeScreenType> configValue = (ConfigValue<RecipeScreenType>) o;
-            return configEntryBuilder.startEnumSelector("config.roughlyenoughitems." + configValue.getName(), RecipeScreenType.class, configValue.getValue())
-                    .setDefaultValue(configValue.getDefaultValue())
-                    .setTooltip(splitLine(configValue.getComment()))
-                    .setSaveConsumer(var -> configValue.setValue((RecipeScreenType) var))
-                    .setErrorSupplier(var -> error((List) configValue.getConstraints(), var, RecipeScreenType.class))
-                    .build();
-        }).registerNodeEntryFunction(ItemCheatingMode.class, o -> {
-            ConfigValue<ItemCheatingMode> configValue = (ConfigValue<ItemCheatingMode>) o;
-            return configEntryBuilder.startEnumSelector("config.roughlyenoughitems." + configValue.getName(), ItemCheatingMode.class, configValue.getValue())
-                    .setDefaultValue(configValue.getDefaultValue())
-                    .setTooltip(splitLine(configValue.getComment()))
-                    .setSaveConsumer(var -> configValue.setValue((ItemCheatingMode) var))
-                    .setErrorSupplier(var -> error((List) configValue.getConstraints(), var, ItemCheatingMode.class))
-                    .build();
-        }).registerNodeEntryFunction(SearchFieldLocation.class, o -> {
-            ConfigValue<SearchFieldLocation> configValue = (ConfigValue<SearchFieldLocation>) o;
-            return configEntryBuilder.startEnumSelector("config.roughlyenoughitems." + configValue.getName(), SearchFieldLocation.class, configValue.getValue())
-                    .setDefaultValue(configValue.getDefaultValue())
-                    .setTooltip(splitLine(configValue.getComment()))
-                    .setSaveConsumer(var -> configValue.setValue((SearchFieldLocation) var))
-                    .setErrorSupplier(var -> error((List) configValue.getConstraints(), var, SearchFieldLocation.class))
-                    .build();
-        }).setAfterInitConsumer(screen -> {
-            ((ScreenHooks) screen).cloth_addButton(new AbstractPressableButtonWidget(screen.width - 104, 4, 100, 20, I18n.translate("text.rei.credits")) {
-                @Override
-                public void onPress() {
-                    MinecraftClient.getInstance().openScreen(new CreditsScreen(screen));
-                }
-            });
-        }).setDefaultCategoryNode(configManager.getConfig().getGeneral()).build().getScreen();
-    }
-    
-}