Skip to content

Commit

Permalink
Only check whether tank tooltips are enabled once
Browse files Browse the repository at this point in the history
  • Loading branch information
YannickMG committed Dec 24, 2021
1 parent 4ff50cf commit 75933fd
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand All @@ -203,7 +205,7 @@ public List<String> 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());
Expand Down Expand Up @@ -234,7 +236,9 @@ public List<String> 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());
}
}
}

0 comments on commit 75933fd

Please sign in to comment.