From 51ac12f2dbfb3e31556877632138225df57535af Mon Sep 17 00:00:00 2001 From: YannickMG Date: Thu, 23 Dec 2021 11:46:38 -0500 Subject: [PATCH 1/3] Add .vscode to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 40fb5e4a..025ed64a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /run/ /build/ /eclipse/ +.vscode .classpath .project /bin/ From 4ff50cfc0a9900ad7c3f180092864d8367247a6e Mon Sep 17 00:00:00 2001 From: YannickMG Date: Thu, 23 Dec 2021 22:15:04 -0500 Subject: [PATCH 2/3] - Fix tank tooltips rendering rendering under items - Changed tooltip to always display the tank's capacity - Enabled tank tooltips by default since they're no longer broken --- .../client/gui/GuiAdvBackpack.java | 61 ++++++++++++++++--- .../adventurebackpack/client/gui/GuiTank.java | 5 +- .../config/ConfigHandler.java | 4 +- 3 files changed, 58 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiAdvBackpack.java b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiAdvBackpack.java index 0d6cc736..c43bcc28 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiAdvBackpack.java +++ b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiAdvBackpack.java @@ -3,8 +3,12 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; +import codechicken.nei.guihook.GuiContainerManager; +import codechicken.nei.guihook.IContainerTooltipHandler; import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.FluidTank; @@ -25,6 +29,8 @@ import com.darkona.adventurebackpack.util.Resources; import com.darkona.adventurebackpack.util.TinkersUtils; +import java.util.List; + /** * Created on 12/10/2014 * @@ -101,14 +107,6 @@ else if (source == Source.HOLDING) else equipButton.draw(this, 77, 208); } - if (ConfigHandler.tanksHoveringText) - { - if (tankLeft.inTank(this, mouseX, mouseY)) - drawHoveringText(tankLeft.getTankTooltip(), mouseX, mouseY, fontRendererObj); - - if (tankRight.inTank(this, mouseX, mouseY)) - drawHoveringText(tankRight.getTankTooltip(), mouseX, mouseY, fontRendererObj); - } if (LoadedMods.TCONSTRUCT && ConfigHandler.tinkerToolsMaintenance) { @@ -192,4 +190,51 @@ public void updateScreen() } } } + + + public static class TooltipHandler implements IContainerTooltipHandler + { + + @Override + public List handleTooltip(GuiContainer gui, int mouseX, int mouseY, List currenttip) { + if (gui.getClass() != GuiAdvBackpack.class) + return currenttip; + + GuiWithTanks backpackGui = (GuiWithTanks) gui; + + // Fluid tank tooltips + if (ConfigHandler.tanksHoveringText && GuiContainerManager.shouldShowTooltip(gui) && currenttip.size() == 0) + { + if (tankLeft.inTank(backpackGui, mouseX, mouseY)) + currenttip.addAll(tankLeft.getTankTooltip()); + + if (tankRight.inTank(backpackGui, mouseX, mouseY)) + currenttip.addAll(tankRight.getTankTooltip()); + } + + return currenttip; + } + + /** + * Required by IContainerTooltipHandler implementation but not needed here + */ + @Override + public List handleItemDisplayName(GuiContainer gui, ItemStack itemstack, List currenttip) { + return currenttip; + } + + /** + * Required by IContainerTooltipHandler implementation but not needed here + */ + @Override + public List handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey, + List currenttip) { + return currenttip; + } + } + + static { + // Creating a single instance of TooltipHandler to handle tooltips for all instances of GuiAdvBackpack + GuiContainerManager.addTooltipHandler(new TooltipHandler()); + } } diff --git a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiTank.java b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiTank.java index e342d7a4..53d0e100 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiTank.java +++ b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiTank.java @@ -16,6 +16,7 @@ import com.darkona.adventurebackpack.common.Constants; import com.darkona.adventurebackpack.config.ConfigHandler; import com.darkona.adventurebackpack.util.LogHelper; +import com.darkona.adventurebackpack.util.TipUtils; /** * Created by Darkona on 12/10/2014. @@ -58,8 +59,8 @@ public GuiTank(int X, int Y, int H, int W, int resolution) public List getTankTooltip() { FluidStack fluid = tank.getFluid(); - String fluidName = (fluid != null) ? fluid.getLocalizedName() : "None"; - String fluidAmount = (fluid != null) ? fluid.amount + "/" + Constants.BASIC_TANK_CAPACITY : "Empty"; + String fluidName = (fluid != null) ? fluid.getLocalizedName() : TipUtils.l10n("empty"); + String fluidAmount = ((fluid != null) ? fluid.amount : 0) + "/" + Constants.BASIC_TANK_CAPACITY; ArrayList tankTips = new ArrayList(); tankTips.add(fluidName); tankTips.add(fluidAmount); diff --git a/src/main/java/com/darkona/adventurebackpack/config/ConfigHandler.java b/src/main/java/com/darkona/adventurebackpack/config/ConfigHandler.java index 36d9762a..b2fd2f77 100644 --- a/src/main/java/com/darkona/adventurebackpack/config/ConfigHandler.java +++ b/src/main/java/com/darkona/adventurebackpack/config/ConfigHandler.java @@ -31,7 +31,7 @@ public class ConfigHandler public static boolean enableTemperatureBar = false; public static boolean enableToolsRender = true; public static int typeTankRender = 2; - public static boolean tanksHoveringText = false; + public static boolean tanksHoveringText = true; public static boolean statusOverlay = true; public static boolean statusOverlayLeft = true; @@ -118,7 +118,7 @@ private static void loadConfiguration() enableFullnessBar = config.getBoolean("Enable Fullness Bar", "graphics", false, "Enable durability bar showing fullness of backpacks inventory"); enableTemperatureBar = config.getBoolean("Enable Temperature Bar", "graphics", false, "Enable durability bar showing temperature of jetpack"); enableToolsRender = config.getBoolean("Enable Tools Render", "graphics", true, "Enable rendering for tools in the backpack tool slots"); - tanksHoveringText = config.getBoolean("Hovering Text", "graphics", false, "Show hovering text on fluid tanks?"); + tanksHoveringText = config.getBoolean("Hovering Text", "graphics", true, "Show hovering text on fluid tanks?"); // Graphics.Status statusOverlay = config.getBoolean("Enable Overlay", "graphics.status", true, "Show player status effects on screen?"); From 75933fd7624f0d8dae53a98a4e3a2f2b2aed087e Mon Sep 17 00:00:00 2001 From: YannickMG Date: Thu, 23 Dec 2021 22:41:26 -0500 Subject: [PATCH 3/3] Only check whether tank tooltips are enabled once --- .../adventurebackpack/client/gui/GuiAdvBackpack.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiAdvBackpack.java b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiAdvBackpack.java index c43bcc28..c94ed5a8 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiAdvBackpack.java +++ b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiAdvBackpack.java @@ -191,7 +191,9 @@ public void updateScreen() } } - + /** + * An instance of this class will handle tooltips for all instances of GuiAdvBackpack + */ public static class TooltipHandler implements IContainerTooltipHandler { @@ -203,7 +205,7 @@ public List handleTooltip(GuiContainer gui, int mouseX, int mouseY, List GuiWithTanks backpackGui = (GuiWithTanks) gui; // Fluid tank tooltips - if (ConfigHandler.tanksHoveringText && GuiContainerManager.shouldShowTooltip(gui) && currenttip.size() == 0) + if (GuiContainerManager.shouldShowTooltip(gui) && currenttip.size() == 0) { if (tankLeft.inTank(backpackGui, mouseX, mouseY)) currenttip.addAll(tankLeft.getTankTooltip()); @@ -234,7 +236,9 @@ public List handleItemTooltip(GuiContainer gui, ItemStack itemstack, int } static { - // Creating a single instance of TooltipHandler to handle tooltips for all instances of GuiAdvBackpack - GuiContainerManager.addTooltipHandler(new TooltipHandler()); + // Only instantiate TooltipHandler if enabled in config. + if (ConfigHandler.tanksHoveringText) { + GuiContainerManager.addTooltipHandler(new TooltipHandler()); + } } }