diff options
author | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-05-08 19:31:13 +0300 |
---|---|---|
committer | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-05-08 19:31:13 +0300 |
commit | 008d6e0462e70164759afcf7e476a3482b0e5556 (patch) | |
tree | eb9d191878a91e94dcc108edb42dc3909aecd80e /src | |
parent | d5592ae7ab7ee624f594098f99b2f9af964abab8 (diff) | |
download | LibGui-008d6e0462e70164759afcf7e476a3482b0e5556.tar.gz LibGui-008d6e0462e70164759afcf7e476a3482b0e5556.tar.bz2 LibGui-008d6e0462e70164759afcf7e476a3482b0e5556.zip |
Replace deprecated RenderSystem matrix usages in widget rendering
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WItem.java | 6 | ||||
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java | 15 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItem.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItem.java index c7e70ae..c1e07e8 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItem.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItem.java @@ -54,17 +54,13 @@ public class WItem extends WWidget { @Environment(EnvType.CLIENT) @Override public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) { - RenderSystem.pushMatrix(); RenderSystem.enableDepthTest(); - RenderSystem.translatef(x, y, 0); MinecraftClient mc = MinecraftClient.getInstance(); ItemRenderer renderer = mc.getItemRenderer(); renderer.zOffset = 100f; - renderer.renderGuiItem(mc.player, items.get(current), getWidth() / 2 - 9, getHeight() / 2 - 9); + renderer.renderGuiItem(mc.player, items.get(current), x + getWidth() / 2 - 9, y + getHeight() / 2 - 9); renderer.zOffset = 0f; - - RenderSystem.popMatrix(); } /** 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 4b5617c..3d14674 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,6 +1,5 @@ package io.github.cottonmc.cotton.gui.widget; -import com.mojang.blaze3d.systems.RenderSystem; import io.github.cottonmc.cotton.gui.client.ScreenDrawing; import io.github.cottonmc.cotton.gui.widget.data.Alignment; import io.github.cottonmc.cotton.gui.widget.data.Axis; @@ -8,7 +7,9 @@ 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 net.minecraft.util.math.Quaternion; import javax.annotation.Nullable; @@ -22,6 +23,8 @@ import javax.annotation.Nullable; * @see WAbstractSlider for more information about listeners */ public class WLabeledSlider extends WAbstractSlider { + private static final Quaternion ROTATION_Z_270 = Vector3f.POSITIVE_X.getDegreesQuaternion(270); + @Nullable private Text label = null; @Nullable private LabelUpdater labelUpdater = null; private Alignment labelAlignment = Alignment.CENTER; @@ -163,11 +166,11 @@ public class WLabeledSlider extends WAbstractSlider { int rotMouseX = axis == Axis.HORIZONTAL ? mouseX : (height - 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(ROTATION_Z_270); } drawButton(0, 0, 0, aWidth); @@ -190,7 +193,7 @@ public class WLabeledSlider extends WAbstractSlider { int color = isMouseInsideBounds(mouseX, mouseY) ? 0xFFFFA0 : 0xE0E0E0; ScreenDrawing.drawStringWithShadow(matrices, label, labelAlignment, 2, aHeight / 2 - 4, aWidth - 4, color); } - RenderSystem.popMatrix(); + matrices.pop(); } // state = 1: regular, 2: hovered, 0: disabled/dragging |