Unknown 6 жил өмнө
parent
commit
f2f55fd069

+ 1 - 1
build.gradle

@@ -6,7 +6,7 @@ sourceCompatibility = 1.8
 targetCompatibility = 1.8
 
 archivesBaseName = "RoughlyEnoughItems"
-version = "1.5-14"
+version = "1.5-15"
 
 minecraft {
 }

+ 2 - 2
src/main/java/me/shedaniel/Core.java

@@ -91,7 +91,7 @@ public class Core implements ClientModInitializer {
             failed = true;
         }
         if (failed || config == null) {
-            Core.LOGGER.error("Failed to load config! Overwriting with default config.");
+            Core.LOGGER.error("REI: Failed to load config! Overwriting with default config.");
             config = new REIConfig();
         }
         saveConfig();
@@ -100,7 +100,7 @@ public class Core implements ClientModInitializer {
     public static void saveConfig() throws IOException {
         configFile.getParentFile().mkdirs();
         if (!configFile.exists() && !configFile.createNewFile()) {
-            Core.LOGGER.error("Failed to save config! Overwriting with default config.");
+            Core.LOGGER.error("REI: Failed to save config! Overwriting with default config.");
             config = new REIConfig();
             return;
         }

+ 14 - 3
src/main/java/me/shedaniel/gui/widget/SmallButton.java

@@ -5,31 +5,37 @@ import me.shedaniel.gui.REIRenderHelper;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.font.FontRenderer;
 import net.minecraft.client.gui.ContainerGui;
+import net.minecraft.client.gui.Gui;
 import net.minecraft.util.Identifier;
 
 import java.awt.*;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Function;
 
 public class SmallButton extends Control {
     
     private String buttonText;
+    private Function<Boolean, String> toolTipSupplier;
     protected static final Identifier BUTTON_TEXTURES = new Identifier("roughlyenoughitems", "textures/gui/recipecontainer.png");
     
     
-    public SmallButton(int x, int y, int width, int height, String buttonText) {
+    public SmallButton(int x, int y, int width, int height, String buttonText, Function<Boolean, String> toolTipSupplier) {
         super(x, y, width, height);
         this.buttonText = buttonText;
+        this.toolTipSupplier = toolTipSupplier;
     }
     
-    public SmallButton(Rectangle rect, String buttonText) {
+    public SmallButton(Rectangle rect, String buttonText, Function<Boolean, String> toolTipSupplier) {
         super(rect);
         this.buttonText = buttonText;
+        this.toolTipSupplier = toolTipSupplier;
     }
     
     public void setString(String text) {
         buttonText = text;
     }
     
-    
     @Override
     public void draw() {
         GlStateManager.pushMatrix();
@@ -56,6 +62,11 @@ public class SmallButton extends Control {
         gui.drawStringCentered(lvt_5_1_, this.buttonText, rect.x + rect.width / 2, rect.y + (rect.height - 8) / 2, lvt_7_1_);
         GlStateManager.enableLighting();
         GlStateManager.popMatrix();
+        if (isHighlighted()) {
+            List<String> toolTip = Arrays.asList(toolTipSupplier.apply(isEnabled()).split("\n"));
+            if (toolTip != null && toolTip.size() != 0)
+                gui.drawTooltip(toolTip, REIRenderHelper.getMouseLoc().x, REIRenderHelper.getMouseLoc().y);
+        }
     }
     
 }

+ 1 - 1
src/main/java/me/shedaniel/impl/REIRecipeManager.java

@@ -40,7 +40,7 @@ public class REIRecipeManager implements IRecipeManager {
     
     public static REIRecipeManager instance() {
         if (myInstance == null) {
-            Core.LOGGER.info("Newing me up.");
+            Core.LOGGER.info("REI: Newing me up.");
             myInstance = new REIRecipeManager();
         }
         return myInstance;

+ 1 - 1
src/main/java/me/shedaniel/mixins/MixinDoneLoading.java

@@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
 public class MixinDoneLoading {
     @Inject(method = "initialize", at = @At("RETURN"))
     private static void onBootstrapRegister(CallbackInfo ci) {
-        Core.LOGGER.info("Done Loading");
+        Core.LOGGER.info("REI: Done Loading");
         Core.getListeners(DoneLoading.class).forEach(DoneLoading::onDoneLoading);
     }
 }

+ 5 - 5
src/main/java/me/shedaniel/plugin/blastfurnace/VanillaBlastFurnaceCategory.java

@@ -1,21 +1,17 @@
 package me.shedaniel.plugin.blastfurnace;
 
 import me.shedaniel.api.DisplayCategoryCraftable;
-import me.shedaniel.api.IDisplayCategory;
 import me.shedaniel.gui.RecipeGui;
 import me.shedaniel.gui.widget.Control;
 import me.shedaniel.gui.widget.REISlot;
 import me.shedaniel.gui.widget.SmallButton;
 import me.shedaniel.gui.widget.WidgetArrow;
 import me.shedaniel.listenerdefinitions.IMixinRecipeBookGui;
-import me.shedaniel.plugin.smoker.VanillaSmokerRecipe;
 import net.minecraft.block.Blocks;
 import net.minecraft.block.entity.BlastFurnaceBlockEntity;
-import net.minecraft.block.entity.SmokerBlockEntity;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.Gui;
 import net.minecraft.client.gui.container.BlastFurnaceGui;
-import net.minecraft.client.gui.container.SmokerGui;
 import net.minecraft.client.resource.language.I18n;
 import net.minecraft.item.Item;
 import net.minecraft.item.ItemStack;
@@ -113,7 +109,11 @@ public class VanillaBlastFurnaceCategory implements DisplayCategoryCraftable<Van
     
     @Override
     public void registerAutoCraftButton(List<Control> control, RecipeGui recipeGui, Gui parentGui, VanillaBlastFurnaceRecipe recipe, int number) {
-        SmallButton button = new SmallButton(128, 75 + 6 + 26 + number * 75, 10, 10, "+");
+        SmallButton button = new SmallButton(128, 75 + 6 + 26 + number * 75, 10, 10, "+", enabled -> {
+            if (!(parentGui instanceof BlastFurnaceGui))
+                return I18n.translate("text.auto_craft.wrong_gui");
+            return "";
+        });
         button.setOnClick(mouse -> {
             recipeGui.close();
             MinecraftClient.getInstance().openGui(parentGui);

+ 7 - 1
src/main/java/me/shedaniel/plugin/crafting/VanillaCraftingCategory.java

@@ -139,7 +139,13 @@ public class VanillaCraftingCategory implements DisplayCategoryCraftable<Vanilla
     
     @Override
     public void registerAutoCraftButton(List<Control> control, RecipeGui recipeGui, Gui parentGui, VanillaCraftingRecipe recipe, int number) {
-        SmallButton button = new SmallButton(78, 75 + 6 + 36 + number * 75, 10, 10, "+");
+        SmallButton button = new SmallButton(78, 75 + 6 + 36 + number * 75, 10, 10, "+", enabled -> {
+            if (!(parentGui instanceof CraftingTableGui || parentGui instanceof PlayerInventoryGui))
+                return I18n.translate("text.auto_craft.wrong_gui");
+            if (parentGui instanceof PlayerInventoryGui && !(recipe.getHeight() < 3 && recipe.getWidth() < 3))
+                return I18n.translate("text.auto_craft.crafting.too_small");
+            return "";
+        });
         button.setOnClick(mouse -> {
             recipeGui.close();
             MinecraftClient.getInstance().openGui(parentGui);

+ 6 - 1
src/main/java/me/shedaniel/plugin/furnace/VanillaFurnaceCategory.java

@@ -11,6 +11,7 @@ import net.minecraft.block.Blocks;
 import net.minecraft.block.entity.FurnaceBlockEntity;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.container.BlastFurnaceGui;
 import net.minecraft.client.gui.container.FurnaceGui;
 import net.minecraft.client.resource.language.I18n;
 import net.minecraft.item.Item;
@@ -109,7 +110,11 @@ public class VanillaFurnaceCategory implements DisplayCategoryCraftable<VanillaF
     
     @Override
     public void registerAutoCraftButton(List<Control> control, RecipeGui recipeGui, Gui parentGui, VanillaFurnaceRecipe recipe, int number) {
-        SmallButton button = new SmallButton(128, 75 + 6 + 26 + number * 75, 10, 10, "+");
+        SmallButton button = new SmallButton(128, 75 + 6 + 26 + number * 75, 10, 10, "+", enabled -> {
+            if (!(parentGui instanceof FurnaceGui))
+                return I18n.translate("text.auto_craft.wrong_gui");
+            return "";
+        });
         button.setOnClick(mouse -> {
             recipeGui.close();
             MinecraftClient.getInstance().openGui(parentGui);

+ 5 - 3
src/main/java/me/shedaniel/plugin/smoker/VanillaSmokerCategory.java

@@ -1,7 +1,6 @@
 package me.shedaniel.plugin.smoker;
 
 import me.shedaniel.api.DisplayCategoryCraftable;
-import me.shedaniel.api.IDisplayCategory;
 import me.shedaniel.gui.RecipeGui;
 import me.shedaniel.gui.widget.Control;
 import me.shedaniel.gui.widget.REISlot;
@@ -12,7 +11,6 @@ import net.minecraft.block.Blocks;
 import net.minecraft.block.entity.SmokerBlockEntity;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.Gui;
-import net.minecraft.client.gui.container.FurnaceGui;
 import net.minecraft.client.gui.container.SmokerGui;
 import net.minecraft.client.resource.language.I18n;
 import net.minecraft.item.Item;
@@ -111,7 +109,11 @@ public class VanillaSmokerCategory implements DisplayCategoryCraftable<VanillaSm
     
     @Override
     public void registerAutoCraftButton(List<Control> control, RecipeGui recipeGui, Gui parentGui, VanillaSmokerRecipe recipe, int number) {
-        SmallButton button = new SmallButton(128, 75 + 6 + 26 + number * 75, 10, 10, "+");
+        SmallButton button = new SmallButton(128, 75 + 6 + 26 + number * 75, 10, 10, "+", enabled -> {
+            if (!(parentGui instanceof SmokerGui))
+                return I18n.translate("text.auto_craft.wrong_gui");
+            return "";
+        });
         button.setOnClick(mouse -> {
             recipeGui.close();
             MinecraftClient.getInstance().openGui(parentGui);

+ 3 - 1
src/main/resources/assets/roughlyenoughitems/lang/en_us.json

@@ -27,5 +27,7 @@
   "ordering.rei.descending": "Descending",
   "ordering.rei.registry": "Registry",
   "ordering.rei.name": "Name",
-  "ordering.rei.item_groups": "Item Groups"
+  "ordering.rei.item_groups": "Item Groups",
+  "text.auto_craft.wrong_gui": "§cCan't auto craft in this inventory!",
+  "text.auto_craft.crafting.too_small": "§cThis inventory is too small!"
 }

+ 10 - 1
src/main/resources/assets/roughlyenoughitems/lang/zh_cn.json

@@ -18,5 +18,14 @@
   "text.rei.config": "设置",
   "text.rei.listeningkey": "正聆听按键",
   "text.rei.centre_searchbox": "置中搜索栏: %s%b",
-  "text.rei.centre_searchbox.tooltip": "更改此设置后请重启游戏以完成更改"
+  "text.rei.centre_searchbox.tooltip": "更改此设置后请重启游戏以完成更改",
+  "text.rei.list_ordering": "物品清单排序",
+  "text.rei.list_ordering_button": "%s [%s]",
+  "ordering.rei.ascending": "顺序",
+  "ordering.rei.descending": "倒序",
+  "ordering.rei.registry": "注册",
+  "ordering.rei.name": "名字",
+  "ordering.rei.item_groups": "物品分类",
+  "text.auto_craft.wrong_gui": "§c不能在此菜单中自动合成!",
+  "text.auto_craft.crafting.too_small": "§c合成格太小!"
 }

+ 10 - 1
src/main/resources/assets/roughlyenoughitems/lang/zh_tw.json

@@ -18,5 +18,14 @@
   "text.rei.config": "設置",
   "text.rei.listeningkey": "正聆聽按鍵",
   "text.rei.centre_searchbox": "置中搜索欄: %s%b",
-  "text.rei.centre_searchbox.tooltip": "更改此設置後請重啟遊戲以完成更改"
+  "text.rei.centre_searchbox.tooltip": "更改此設置後請重啟遊戲以完成更改",
+  "text.rei.list_ordering": "物品清單排序",
+  "text.rei.list_ordering_button": "%s [%s]",
+  "ordering.rei.ascending": "順序",
+  "ordering.rei.descending": "倒序",
+  "ordering.rei.registry": "註冊",
+  "ordering.rei.name": "名字",
+  "ordering.rei.item_groups": "物品分類",
+  "text.auto_craft.wrong_gui": "§c不能在此菜單中自動合成!",
+  "text.auto_craft.crafting.too_small": "§c合成格太小!"
 }