From 68f11180d0d813f8370cd2cf09d948820a3928d6 Mon Sep 17 00:00:00 2001 From: Maria Date: Sat, 26 Aug 2023 15:29:14 -0500 Subject: [PATCH] fix: update hammer, fix guis --- .../astromine/common/widget/BodySelectionWidget.java | 11 +++++++---- .../mixinors/astromine/common/widget/BodyWidget.java | 6 +++++- .../astromine/common/widget/FluidFilterWidget.java | 6 +++++- .../common/widget/RedstoneControlWidget.java | 5 ++++- .../astromine/common/widget/StorageSidingWidget.java | 5 ++++- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/github/mixinors/astromine/common/widget/BodySelectionWidget.java b/src/main/java/com/github/mixinors/astromine/common/widget/BodySelectionWidget.java index 0753d0ccc..4ea6dd960 100644 --- a/src/main/java/com/github/mixinors/astromine/common/widget/BodySelectionWidget.java +++ b/src/main/java/com/github/mixinors/astromine/common/widget/BodySelectionWidget.java @@ -85,7 +85,10 @@ protected void onMouseClicked(MouseClickedEvent event) { } @Override - public void draw(MatrixStack matrices, VertexConsumerProvider provider, float tickDelta) { + public void draw(DrawContext context, float tickDelta) { + var matrices = context.getMatrices(); + var provider = context.getVertexConsumers(); + if (body == null) return; var client = InstanceUtil.getClient(); @@ -158,8 +161,8 @@ public void draw(MatrixStack matrices, VertexConsumerProvider provider, float ti // Translate to the Title's position. matrices.translate(informationWidth / 2.0F - TextUtil.getWidth(bodyName) / 2.0F, 0.0F, 0.0F); - var context = new DrawContext(MinecraftClient.getInstance(), MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers()); - context.drawText(textRenderer, bodyName, 0, 0, Color.WHITE.toRgb(), false); + var newContext = new DrawContext(MinecraftClient.getInstance(), MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers()); + newContext.drawText(textRenderer, bodyName, 0, 0, Color.WHITE.toRgb(), false); matrices.pop(); // 2 @@ -174,7 +177,7 @@ public void draw(MatrixStack matrices, VertexConsumerProvider provider, float ti matrices.translate(0.0F, 4.0F + TextUtil.getHeight(bodyName), 0.0F); for (var line : bodyDescriptionLines) { - context.drawText(textRenderer, line, 0, 0, Color.GRAY.toRgb(), false); + newContext.drawText(textRenderer, line, 0, 0, Color.GRAY.toRgb(), false); // Offset the line's size. // TODO: Remove the ""! diff --git a/src/main/java/com/github/mixinors/astromine/common/widget/BodyWidget.java b/src/main/java/com/github/mixinors/astromine/common/widget/BodyWidget.java index 5ca7b6b69..7ced47fc0 100644 --- a/src/main/java/com/github/mixinors/astromine/common/widget/BodyWidget.java +++ b/src/main/java/com/github/mixinors/astromine/common/widget/BodyWidget.java @@ -11,6 +11,7 @@ import dev.vini2003.hammer.core.api.client.util.InstanceUtil; import dev.vini2003.hammer.core.api.client.util.PositionUtil; import dev.vini2003.hammer.gui.api.common.widget.Widget; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.util.math.MatrixStack; @@ -86,7 +87,10 @@ public List getTooltip() { } @Override - public void draw(MatrixStack matrices, VertexConsumerProvider provider, float tickDelta) { + public void draw(DrawContext context, float tickDelta) { + var matrices = context.getMatrices(); + var provider = context.getVertexConsumers(); + // Get the offset caused by mouse dragging. var offsetX = BodySelectorHandledScreen.getOffsetX(); var offsetY = BodySelectorHandledScreen.getOffsetY(); diff --git a/src/main/java/com/github/mixinors/astromine/common/widget/FluidFilterWidget.java b/src/main/java/com/github/mixinors/astromine/common/widget/FluidFilterWidget.java index 051e10cd5..8fd40545c 100644 --- a/src/main/java/com/github/mixinors/astromine/common/widget/FluidFilterWidget.java +++ b/src/main/java/com/github/mixinors/astromine/common/widget/FluidFilterWidget.java @@ -11,6 +11,7 @@ import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage; import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant; import net.fabricmc.fabric.api.transfer.v1.storage.StorageUtil; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; @@ -84,7 +85,10 @@ protected void onMouseClicked(MouseClickedEvent event) { } @Override - public void draw(MatrixStack matrices, VertexConsumerProvider provider, float tickDelta) { + public void draw(DrawContext context, float tickDelta) { + var matrices = context.getMatrices(); + var provider = context.getVertexConsumers(); + backgroundTexture.get().draw(matrices, provider, getX(), getY(), getWidth(), getHeight()); if (fluidVariant.get().isBlank()) { diff --git a/src/main/java/com/github/mixinors/astromine/common/widget/RedstoneControlWidget.java b/src/main/java/com/github/mixinors/astromine/common/widget/RedstoneControlWidget.java index e1cf46e71..7012dd868 100644 --- a/src/main/java/com/github/mixinors/astromine/common/widget/RedstoneControlWidget.java +++ b/src/main/java/com/github/mixinors/astromine/common/widget/RedstoneControlWidget.java @@ -98,7 +98,10 @@ protected void onMouseClicked(MouseClickedEvent event) { } @Override - public void draw(MatrixStack matrices, VertexConsumerProvider provider, float tickDelta) { + public void draw(DrawContext context, float tickDelta) { + var matrices = context.getMatrices(); + var provider = context.getVertexConsumers(); + if (blockEntity == null) { return; } diff --git a/src/main/java/com/github/mixinors/astromine/common/widget/StorageSidingWidget.java b/src/main/java/com/github/mixinors/astromine/common/widget/StorageSidingWidget.java index 301b4ed9e..bcfd23183 100644 --- a/src/main/java/com/github/mixinors/astromine/common/widget/StorageSidingWidget.java +++ b/src/main/java/com/github/mixinors/astromine/common/widget/StorageSidingWidget.java @@ -13,6 +13,7 @@ import dev.vini2003.hammer.gui.api.common.event.MouseClickedEvent; import dev.vini2003.hammer.gui.api.common.widget.Widget; import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; @@ -131,7 +132,9 @@ protected void onMouseClicked(MouseClickedEvent event) { } @Override - public void draw(MatrixStack matrices, VertexConsumerProvider provider, float tickDelta) { + public void draw(DrawContext context, float tickDelta) { + var matrices = context.getMatrices(); + var provider = context.getVertexConsumers(); getTexture().draw(matrices, provider, getX(), getY(), getWidth(), getHeight()); }