Fix smeltery tank renderer behaving oddly if the tank is drained while the UI is open
@@ -114,6 +114,9 @@ public class GuiSmelteryTank {
int checkX = mouseX - parent.guiLeft;
int checkY = mouseY - parent.guiTop;
if (withinTank(checkX, checkY)) {
+ if (tank.getContained() == 0) {
+ GuiUtil.renderHighlight(matrices, x, y, width, height);
+ } else {
int[] heights = calcLiquidHeights(false);
int hovered = getFluidFromMouse(heights, checkY);
@@ -131,6 +134,7 @@ public class GuiSmelteryTank {
}
}
}
+ }
/**
* Gets the tooltip for the tank based on the given mouse position
@@ -143,7 +147,7 @@ public class GuiSmelteryTank {
int checkX = mouseX - parent.guiLeft;
int checkY = mouseY - parent.guiTop;
if (withinTank(checkX, checkY)) {
- int hovered = getFluidFromMouse(calcLiquidHeights(false), checkY);
+ int hovered = tank.getContained() == 0 ? -1 : getFluidFromMouse(calcLiquidHeights(false), checkY);
List<ITextComponent> tooltip;
if (hovered == -1) {
BiConsumer<Integer, List<ITextComponent>> formatter =
@@ -176,7 +180,7 @@ public class GuiSmelteryTank {
* Checks if the tank was clicked at the given location
*/
public void handleClick(int mouseX, int mouseY) {
- if (withinTank(mouseX, mouseY)) {
+ if (tank.getContained() > 0 && withinTank(mouseX, mouseY)) {
int index = getFluidFromMouse(calcLiquidHeights(false), mouseY);
if (index != -1) {
TinkerNetwork.getInstance().sendToServer(new SmelteryFluidClickedPacket(index));
@@ -192,7 +196,7 @@ public class GuiSmelteryTank {
*/
@Nullable
public FluidStack getIngredient(int checkX, int checkY) {
- if (withinTank(checkX, checkY)) {
+ if (tank.getContained() > 0 && withinTank(checkX, checkY)) {
int index = getFluidFromMouse(calcLiquidHeights(false), checkY);
if (index != -1) {
return tank.getFluidInTank(index);
