Эх сурвалжийг харах

Support new Cloth Config

Signed-off-by: shedaniel <daniel@shedaniel.me>
shedaniel 5 жил өмнө
parent
commit
6dd3a76c33

+ 2 - 2
gradle.properties

@@ -1,11 +1,11 @@
 org.gradle.jvmargs=-Xmx3G
-mod_version=4.3.9-unstable
+mod_version=4.3.10-unstable
 supported_version=20w20a
 minecraft_version=20w20a
 yarn_version=20w20a+build.1+legacy.20w09a+build.8
 fabricloader_version=0.8.2+build.194
 cloth_events_version=2.2.0-unstable
-cloth_config_version=4.3.0-unstable
+cloth_config_version=4.3.2-unstable
 modmenu_version=1.11.4+build.9
 fabric_api=0.10.8+build.345-1.16
 autoconfig1u=3.0.1-unstable

+ 11 - 3
src/main/java/me/shedaniel/rei/gui/config/entry/FilteringEntry.java

@@ -28,6 +28,7 @@ import com.google.common.collect.Sets;
 import com.mojang.blaze3d.systems.RenderSystem;
 import me.shedaniel.clothconfig2.ClothConfigInitializer;
 import me.shedaniel.clothconfig2.api.AbstractConfigListEntry;
+import me.shedaniel.clothconfig2.api.ScrollingContainer;
 import me.shedaniel.clothconfig2.gui.ClothConfigScreen;
 import me.shedaniel.clothconfig2.gui.widget.DynamicNewSmoothScrollingEntryListWidget;
 import me.shedaniel.math.Point;
@@ -40,7 +41,6 @@ import me.shedaniel.rei.api.REIHelper;
 import me.shedaniel.rei.api.widgets.Tooltip;
 import me.shedaniel.rei.gui.OverlaySearchField;
 import me.shedaniel.rei.gui.widget.EntryWidget;
-import me.shedaniel.clothconfig2.api.ScrollingContainer;
 import me.shedaniel.rei.impl.ScreenHelper;
 import me.shedaniel.rei.impl.SearchArgument;
 import me.shedaniel.rei.utils.CollectionUtils;
@@ -102,6 +102,8 @@ public class FilteringEntry extends AbstractConfigListEntry<List<EntryStack>> {
     private ButtonWidget hideButton;
     private ButtonWidget showButton;
     
+    private boolean edited = false;
+    
     private List<SearchArgument.SearchArguments> lastSearchArguments = Collections.emptyList();
     
     public FilteringEntry(List<EntryStack> configFiltered, List<EntryStack> defaultValue, Consumer<List<EntryStack>> saveConsumer) {
@@ -133,7 +135,7 @@ public class FilteringEntry extends AbstractConfigListEntry<List<EntryStack>> {
                     entry.getBounds().y = (int) (entry.backupY - scrolling.scrollAmount);
                     if (entry.isSelected() && !entry.isFiltered()) {
                         configFiltered.add(stack);
-                        getScreen().setEdited(true, false);
+                        edited = true;
                     }
                 }
             });
@@ -146,7 +148,7 @@ public class FilteringEntry extends AbstractConfigListEntry<List<EntryStack>> {
                     EntryListEntry entry = entries.get(i);
                     entry.getBounds().y = (int) (entry.backupY - scrolling.scrollAmount);
                     if (entry.isSelected() && configFiltered.remove(stack)) {
-                        getScreen().setEdited(true, false);
+                        edited = true;
                     }
                 }
             });
@@ -178,6 +180,12 @@ public class FilteringEntry extends AbstractConfigListEntry<List<EntryStack>> {
     @Override
     public void save() {
         saveConsumer.accept(getValue());
+        this.edited = false;
+    }
+    
+    @Override
+    public boolean isEdited() {
+        return super.isEdited() || edited;
     }
     
     @SuppressWarnings("rawtypes")

+ 7 - 1
src/main/java/me/shedaniel/rei/gui/config/entry/RecipeScreenTypeEntry.java

@@ -43,6 +43,7 @@ import java.util.function.Consumer;
 
 public class RecipeScreenTypeEntry extends TooltipListEntry<RecipeScreenType> {
     private int width;
+    private final RecipeScreenType original;
     private RecipeScreenType type;
     private RecipeScreenType defaultValue;
     private Consumer<RecipeScreenType> save;
@@ -52,7 +53,6 @@ public class RecipeScreenTypeEntry extends TooltipListEntry<RecipeScreenType> {
             MinecraftClient.getInstance().openScreen(new PreRecipeViewingScreen(getScreen(), type, false, original -> {
                 MinecraftClient.getInstance().openScreen(getScreen());
                 type = original ? RecipeScreenType.ORIGINAL : RecipeScreenType.VILLAGER;
-                getScreen().setEdited(true, isRequiresRestart());
             }));
         }
         
@@ -67,12 +67,18 @@ public class RecipeScreenTypeEntry extends TooltipListEntry<RecipeScreenType> {
     @SuppressWarnings("deprecation")
     public RecipeScreenTypeEntry(int width, Text fieldName, RecipeScreenType type, RecipeScreenType defaultValue, Consumer<RecipeScreenType> save) {
         super(fieldName, null);
+        this.original = type;
         this.width = width;
         this.type = type;
         this.defaultValue = defaultValue;
         this.save = save;
     }
     
+    @Override
+    public boolean isEdited() {
+        return super.isEdited() || getValue() != original;
+    }
+    
     @Override
     public RecipeScreenType getValue() {
         return type;