From d95ef9e489e24807a3fa92691700ee3d43f68a80 Mon Sep 17 00:00:00 2001 From: Juuxel <6596629+Juuxel@users.noreply.github.com> Date: Sat, 27 Feb 2021 16:12:11 +0200 Subject: Fix labeled slider rendering --- .../github/cottonmc/cotton/gui/widget/WLabeledSlider.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java index ef5391e..ba5edd4 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java @@ -1,10 +1,10 @@ package io.github.cottonmc.cotton.gui.widget; -import com.mojang.blaze3d.systems.RenderSystem; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.gui.widget.AbstractButtonWidget; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.util.math.Vector3f; import net.minecraft.text.Text; import io.github.cottonmc.cotton.gui.client.ScreenDrawing; @@ -155,7 +155,6 @@ public class WLabeledSlider extends WAbstractSlider { return x >= 0 && x <= width && y >= 0 && y <= height; } - @SuppressWarnings("deprecation") @Environment(EnvType.CLIENT) @Override public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) { @@ -166,11 +165,11 @@ public class WLabeledSlider extends WAbstractSlider { : (direction == Direction.UP ? height - mouseY : mouseY); int rotMouseY = axis == Axis.HORIZONTAL ? mouseY : mouseX; - RenderSystem.pushMatrix(); - RenderSystem.translatef(x, y, 0); + matrices.push(); + matrices.translate(x, y, 0); if (axis == Axis.VERTICAL) { - RenderSystem.translatef(0, height, 0); - RenderSystem.rotatef(270, 0, 0, 1); + matrices.translate(0, height, 0); + matrices.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(270)); } drawButton(matrices, 0, 0, 0, aWidth); @@ -193,7 +192,7 @@ public class WLabeledSlider extends WAbstractSlider { int color = isMouseInsideBounds(mouseX, mouseY) ? 0xFFFFA0 : 0xE0E0E0; ScreenDrawing.drawStringWithShadow(matrices, label.asOrderedText(), labelAlignment, 2, aHeight / 2 - 4, aWidth - 4, color); } - RenderSystem.popMatrix(); + matrices.pop(); } // state = 1: regular, 2: hovered, 0: disabled/dragging -- cgit