From 60de29e360c1d35fc0f3006fa131e03353e44a10 Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Wed, 27 Sep 2023 16:15:21 +0300 Subject: ScreenDrawing+Texture: Improve GUI sprite rendering - Fix choppiness from using int coordinates - UV order is normalised and flipping is explicitly not supported --- src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java | 4 ++-- src/main/java/io/github/cottonmc/cotton/gui/widget/data/Texture.java | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java index 6ddc9c0..9332bef 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java @@ -132,8 +132,8 @@ public class ScreenDrawing { if (Float.isInfinite(fullWidth) || Float.isInfinite(fullHeight)) break outer; // Calculate the offset left/top coordinates. - int xo = x - (int) (fullWidth * texture.u1()); - int yo = y - (int) (fullHeight * texture.v1()); + float xo = x - fullWidth * Math.min(texture.u1(), texture.u2()); + float yo = y - fullHeight * Math.min(texture.v1(), texture.v2()); MatrixStack matrices = context.getMatrices(); matrices.push(); diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/data/Texture.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/data/Texture.java index 5418c70..47b296f 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/data/Texture.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/data/Texture.java @@ -45,6 +45,8 @@ import java.util.Objects; * and they need to be drawn with specific {@code Texture}-accepting methods * or {@link net.minecraft.client.gui.DrawContext}. * + *

GUI sprite textures don't currently support flipping the texture by flipping UV coordinates. + * * @param image the image of this texture * @param type the type of this texture * @param u1 the start U-coordinate, between 0 and 1 -- cgit