Ver código fonte

Custom Ordering

Unknown 6 anos atrás
pai
commit
6b36550eba

+ 1 - 1
build.gradle

@@ -6,7 +6,7 @@ sourceCompatibility = 1.8
 targetCompatibility = 1.8
 
 archivesBaseName = "RoughlyEnoughItems"
-version = "2.0.0.33"
+version = "2.0.0.34"
 
 minecraft {
 }

+ 8 - 0
src/main/java/me/shedaniel/rei/client/ConfigHelper.java

@@ -63,6 +63,14 @@ public class ConfigHelper {
         return config.itemListOrdering;
     }
     
+    public void setItemListOrdering(REIItemListOrdering ordering) {
+        config.itemListOrdering = ordering;
+    }
+    
+    public void setAscending(boolean ascending) {
+        config.isAscending = ascending;
+    }
+    
     public boolean isAscending() {
         return config.isAscending;
     }

+ 29 - 0
src/main/java/me/shedaniel/rei/gui/widget/ConfigWidget.java

@@ -2,14 +2,17 @@ package me.shedaniel.rei.gui.widget;
 
 import com.google.common.collect.Lists;
 import me.shedaniel.rei.RoughlyEnoughItemsCore;
+import me.shedaniel.rei.client.REIItemListOrdering;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.Gui;
 import net.minecraft.client.gui.GuiEventListener;
 import net.minecraft.client.render.GuiLighting;
 import net.minecraft.client.resource.language.I18n;
 import net.minecraft.client.util.Window;
+import org.apache.logging.log4j.core.Core;
 
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.List;
 
 public class ConfigWidget extends Gui {
@@ -79,6 +82,32 @@ public class ConfigWidget extends Gui {
                 super.draw(mouseX, mouseY, partialTicks);
             }
         });
+        widgets.add(new ButtonWidget(window.getScaledWidth() / 2 - 90, 90, 150, 20, "") {
+            @Override
+            public void onPressed(int button, double mouseX, double mouseY) {
+                int index = Arrays.asList(REIItemListOrdering.values()).indexOf(RoughlyEnoughItemsCore.getConfigHelper().getItemListOrdering()) + 1;
+                if (index >= REIItemListOrdering.values().length) {
+                    index = 0;
+                    RoughlyEnoughItemsCore.getConfigHelper().setAscending(!RoughlyEnoughItemsCore.getConfigHelper().isAscending());
+                }
+                RoughlyEnoughItemsCore.getConfigHelper().setItemListOrdering(REIItemListOrdering.values()[index]);
+                try {
+                    RoughlyEnoughItemsCore.getConfigHelper().saveConfig();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        
+            @Override
+            public void draw(int int_1, int int_2, float float_1) {
+                GuiLighting.disable();
+                this.text = I18n.translate("text.rei.list_ordering_button", I18n.translate(RoughlyEnoughItemsCore.getConfigHelper().getItemListOrdering().getNameTranslationKey()),
+                        I18n.translate(RoughlyEnoughItemsCore.getConfigHelper().isAscending() ? "ordering.rei.ascending" : "ordering.rei.descending"));
+                String t = I18n.translate("text.rei.list_ordering") + ": ";
+                drawString(MinecraftClient.getInstance().fontRenderer, t, parent.width / 2 - 95 - MinecraftClient.getInstance().fontRenderer.getStringWidth(t), 90 + 6, -1);
+                super.draw(int_1, int_2, float_1);
+            }
+        });
     }
     
     private String getTrueFalseText(boolean showCraftableOnlyButton) {

+ 0 - 1
src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java

@@ -51,7 +51,6 @@ public class DefaultPlugin implements IRecipePlugin {
             else if (value instanceof BlastingRecipe)
                 RecipeHelper.registerRecipe(BLASTING, new DefaultBlastingDisplay((BlastingRecipe) value));
         BREWING_DISPLAYS.forEach(display -> RecipeHelper.registerRecipe(BREWING, display));
-        RoughlyEnoughItemsCore.LOGGER.info("bad lol " + BREWING_DISPLAYS.size());
     }
     
 }

+ 1 - 1
src/main/resources/fabric.mod.json

@@ -2,7 +2,7 @@
   "id": "roughlyenoughitems",
   "name": "RoughlyEnoughItems",
   "description": "To allow players to view items and recipes.",
-  "version": "2.0.0.33",
+  "version": "2.0.0.34",
   "side": "client",
   "authors": [
     "Danielshe"