From 174c51618f46cd86949b094e129760eca2a3f65e Mon Sep 17 00:00:00 2001 From: khodakarami Date: Sat, 11 Nov 2023 22:50:30 +0330 Subject: [PATCH] fixed water fluid drawing in gem cleanser --- .../screen/custom/GemCleanserScreen.java | 21 +++++-------------- .../handler/GemCleanserScreenHandler.java | 2 +- .../utils/fluid/FluidStackRenderer.java | 10 +++++++++ 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/main/java/jiraiyah/allthatmatters/screen/custom/GemCleanserScreen.java b/src/main/java/jiraiyah/allthatmatters/screen/custom/GemCleanserScreen.java index b5004fb..dbdd1ae 100644 --- a/src/main/java/jiraiyah/allthatmatters/screen/custom/GemCleanserScreen.java +++ b/src/main/java/jiraiyah/allthatmatters/screen/custom/GemCleanserScreen.java @@ -1,6 +1,7 @@ package jiraiyah.allthatmatters.screen.custom; import io.github.cottonmc.cotton.gui.client.CottonInventoryScreen; +import io.github.cottonmc.cotton.gui.client.ScreenDrawing; import io.github.cottonmc.cotton.gui.widget.WPanel; import jiraiyah.allthatmatters.block.entity.GemCleanserBE; import jiraiyah.allthatmatters.screen.handler.GemCleanserScreenHandler; @@ -25,40 +26,28 @@ public GemCleanserScreen(GemCleanserScreenHandler container, PlayerEntity player super(container, player, title); this.container = container; this.fluidStackRenderer = new FluidStackRenderer(GemCleanserBE.FLUID_CAPACITY, true, 15, 61); - } - - @Override - protected void handledScreenTick() { - super.handledScreenTick(); - if (description!=null) { - WPanel root = description.getRootPanel(); - if (root!=null) { - root.tick(); - } - } + this.fluidStackRenderer.setzOrder(1); } @Override protected void drawBackground(DrawContext context, float partialTicks, int mouseX, int mouseY) { - fluidStackRenderer.drawFluid(context, container.fluidStack, x + 10, y + 0, 100, 200, GemCleanserBE.FLUID_CAPACITY); super.drawBackground(context, partialTicks, mouseX, mouseY); - fluidStackRenderer.drawFluid(context, container.fluidStack, x + 10, y + 0, 100, 200, GemCleanserBE.FLUID_CAPACITY); } @Override public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) { - fluidStackRenderer.drawFluid(context, container.fluidStack, x + 10, y + 0, 100, 200, GemCleanserBE.FLUID_CAPACITY); super.render(context, mouseX, mouseY, partialTicks); - fluidStackRenderer.drawFluid(context, container.fluidStack, x + 10, y + 0, 100, 200, GemCleanserBE.FLUID_CAPACITY); + + fluidStackRenderer.drawFluid(context, container.fluidStack, x + 93, y + 22, 16, 61, GemCleanserBE.FLUID_CAPACITY); } @Override protected void drawForeground(DrawContext context, int mouseX, int mouseY) { super.drawForeground(context, mouseX, mouseY); - renderFLuidTooltip(context, mouseX, mouseY, x, y, container.fluidStack, 93, 21, fluidStackRenderer); + renderFLuidTooltip(context, mouseX, mouseY, x, y, container.fluidStack, 93, 22, fluidStackRenderer); } private void renderFLuidTooltip(DrawContext context, int mouseX, int mouseY, int x, int y, FluidStack fluidStack, int offsetX, int offsetY, FluidStackRenderer renderer) diff --git a/src/main/java/jiraiyah/allthatmatters/screen/handler/GemCleanserScreenHandler.java b/src/main/java/jiraiyah/allthatmatters/screen/handler/GemCleanserScreenHandler.java index 64c9ce4..7814af1 100644 --- a/src/main/java/jiraiyah/allthatmatters/screen/handler/GemCleanserScreenHandler.java +++ b/src/main/java/jiraiyah/allthatmatters/screen/handler/GemCleanserScreenHandler.java @@ -52,7 +52,7 @@ public GemCleanserScreenHandler(int syncId, PlayerInventory playerInventory, Scr WPlainPanel root = new WPlainPanel (); setRootPanel(root); - root.setSize(200, 168); + root.setSize(200, 178); root.setInsets(Insets.ROOT_PANEL); WItemSlot base_input_slot = WItemSlot.of(blockInventory, GemCleanserBE.BASE_INPUT_SLOT); diff --git a/src/main/java/jiraiyah/allthatmatters/utils/fluid/FluidStackRenderer.java b/src/main/java/jiraiyah/allthatmatters/utils/fluid/FluidStackRenderer.java index 5ec4455..fe68137 100644 --- a/src/main/java/jiraiyah/allthatmatters/utils/fluid/FluidStackRenderer.java +++ b/src/main/java/jiraiyah/allthatmatters/utils/fluid/FluidStackRenderer.java @@ -31,6 +31,7 @@ public class FluidStackRenderer implements IIngredientRenderer private final TooltipMode tooltipMode; private final int width; private final int height; + private int zOrder; enum TooltipMode { @@ -65,6 +66,12 @@ private FluidStackRenderer(long capacityMb, TooltipMode tooltipMode, int width, this.tooltipMode = tooltipMode; this.width = width; this.height = height; + this.zOrder = 0; + } + + public void setzOrder(int index) + { + this.zOrder = index; } /* @@ -91,7 +98,10 @@ public void drawFluid(DrawContext context, FluidStack fluid, int x, int y, int w { final int curHeight = offsetHeight < iconHeight ? offsetHeight : iconHeight; + context.getMatrices().push(); + context.getMatrices().translate(0f, 0f, 0.01f * zOrder); context.drawSprite(x, y - offsetHeight, 0, width, curHeight, sprite); + context.getMatrices().pop(); offsetHeight -= curHeight; iteration++; if (iteration > 50)