diff options
| author | Unknown <shekwancheung0528@gmail.com> | 2019-01-07 13:33:08 +0800 |
|---|---|---|
| committer | Unknown <shekwancheung0528@gmail.com> | 2019-01-07 13:33:08 +0800 |
| commit | f2f55fd069c99bb0d53b0bfe58cb4d2b9c675de0 (patch) | |
| tree | 47f78f2b117fe9e1383bc2845775bfed5cca7761 /src/main/java | |
| parent | 4e1c5cc9e134d338b8b675eb9302a9841e5aeaed (diff) | |
| download | RoughlyEnoughItems-f2f55fd069c99bb0d53b0bfe58cb4d2b9c675de0.tar.gz RoughlyEnoughItems-f2f55fd069c99bb0d53b0bfe58cb4d2b9c675de0.tar.bz2 RoughlyEnoughItems-f2f55fd069c99bb0d53b0bfe58cb4d2b9c675de0.zip | |
Tooltip
Diffstat (limited to 'src/main/java')
8 files changed, 41 insertions, 17 deletions
diff --git a/src/main/java/me/shedaniel/Core.java b/src/main/java/me/shedaniel/Core.java index f8dd78e71..498b0a43b 100755 --- a/src/main/java/me/shedaniel/Core.java +++ b/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; } diff --git a/src/main/java/me/shedaniel/gui/widget/SmallButton.java b/src/main/java/me/shedaniel/gui/widget/SmallButton.java index 5eff8d206..2e6a7ad1b 100644 --- a/src/main/java/me/shedaniel/gui/widget/SmallButton.java +++ b/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); + } } } diff --git a/src/main/java/me/shedaniel/impl/REIRecipeManager.java b/src/main/java/me/shedaniel/impl/REIRecipeManager.java index 937e1cf6f..657187da8 100755 --- a/src/main/java/me/shedaniel/impl/REIRecipeManager.java +++ b/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; diff --git a/src/main/java/me/shedaniel/mixins/MixinDoneLoading.java b/src/main/java/me/shedaniel/mixins/MixinDoneLoading.java index 6d21e0d95..18d67479d 100755 --- a/src/main/java/me/shedaniel/mixins/MixinDoneLoading.java +++ b/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); } } diff --git a/src/main/java/me/shedaniel/plugin/blastfurnace/VanillaBlastFurnaceCategory.java b/src/main/java/me/shedaniel/plugin/blastfurnace/VanillaBlastFurnaceCategory.java index 48a977eb3..1721fac05 100755 --- a/src/main/java/me/shedaniel/plugin/blastfurnace/VanillaBlastFurnaceCategory.java +++ b/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); diff --git a/src/main/java/me/shedaniel/plugin/crafting/VanillaCraftingCategory.java b/src/main/java/me/shedaniel/plugin/crafting/VanillaCraftingCategory.java index 50fa4ad1e..6b858f456 100755 --- a/src/main/java/me/shedaniel/plugin/crafting/VanillaCraftingCategory.java +++ b/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); diff --git a/src/main/java/me/shedaniel/plugin/furnace/VanillaFurnaceCategory.java b/src/main/java/me/shedaniel/plugin/furnace/VanillaFurnaceCategory.java index 0603bb444..67b73076c 100755 --- a/src/main/java/me/shedaniel/plugin/furnace/VanillaFurnaceCategory.java +++ b/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); diff --git a/src/main/java/me/shedaniel/plugin/smoker/VanillaSmokerCategory.java b/src/main/java/me/shedaniel/plugin/smoker/VanillaSmokerCategory.java index 862d5ba35..37bd413f4 100755 --- a/src/main/java/me/shedaniel/plugin/smoker/VanillaSmokerCategory.java +++ b/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); |
