aboutsummaryrefslogtreecommitdiff
path: root/src/client/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java
diff options
context:
space:
mode:
authorisXander <xandersmith2008@gmail.com>2023-01-19 21:15:26 +0000
committerisXander <xandersmith2008@gmail.com>2023-01-19 21:15:26 +0000
commitee53b51a1e8d88085c75f227f4710b68c03b19c8 (patch)
tree77a942242a982757da040a6120950bad30e49f77 /src/client/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java
parentffdd6e5ceacd71c76c55a8716702d4d6da17c7ab (diff)
downloadYetAnotherConfigLib-ee53b51a1e8d88085c75f227f4710b68c03b19c8.tar.gz
YetAnotherConfigLib-ee53b51a1e8d88085c75f227f4710b68c03b19c8.tar.bz2
YetAnotherConfigLib-ee53b51a1e8d88085c75f227f4710b68c03b19c8.zip
mojmap
Diffstat (limited to 'src/client/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java')
-rw-r--r--src/client/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/client/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java b/src/client/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java
index 2d0a99c..76ba14f 100644
--- a/src/client/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java
+++ b/src/client/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java
@@ -1,44 +1,44 @@
package dev.isxander.yacl.gui;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.font.TextRenderer;
-import net.minecraft.client.gui.tooltip.Tooltip;
-import net.minecraft.client.gui.widget.ButtonWidget;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.text.OrderedText;
-import net.minecraft.text.Text;
-import net.minecraft.util.math.MathHelper;
-
-public class TextScaledButtonWidget extends ButtonWidget {
+import com.mojang.blaze3d.vertex.PoseStack;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.Font;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.Tooltip;
+import net.minecraft.network.chat.Component;
+import net.minecraft.util.FormattedCharSequence;
+import net.minecraft.util.Mth;
+
+public class TextScaledButtonWidget extends Button {
public float textScale;
- public TextScaledButtonWidget(int x, int y, int width, int height, float textScale, Text message, PressAction onPress) {
- super(x, y, width, height, message, onPress, DEFAULT_NARRATION_SUPPLIER);
+ public TextScaledButtonWidget(int x, int y, int width, int height, float textScale, Component message, OnPress onPress) {
+ super(x, y, width, height, message, onPress, DEFAULT_NARRATION);
this.textScale = textScale;
}
- public TextScaledButtonWidget(int x, int y, int width, int height, float textScale, Text message, PressAction onPress, Tooltip tooltip) {
+ public TextScaledButtonWidget(int x, int y, int width, int height, float textScale, Component message, OnPress onPress, Tooltip tooltip) {
this(x, y, width, height, textScale, message, onPress);
setTooltip(tooltip);
}
@Override
- public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
+ public void renderButton(PoseStack matrices, int mouseX, int mouseY, float delta) {
// prevents super from rendering text
- Text message = getMessage();
- setMessage(Text.empty());
+ Component message = getMessage();
+ setMessage(Component.empty());
super.renderButton(matrices, mouseX, mouseY, delta);
setMessage(message);
int j = this.active ? 16777215 : 10526880;
- OrderedText orderedText = getMessage().asOrderedText();
- TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
+ FormattedCharSequence orderedText = getMessage().getVisualOrderText();
+ Font font = Minecraft.getInstance().font;
- matrices.push();
- matrices.translate(((this.getX() + this.width / 2f) - textRenderer.getWidth(orderedText) * textScale / 2), (float)this.getY() + (this.height - 8 * textScale) / 2f / textScale, 0);
+ matrices.pushPose();
+ matrices.translate(((this.getX() + this.width / 2f) - font.width(orderedText) * textScale / 2), (float)this.getY() + (this.height - 8 * textScale) / 2f / textScale, 0);
matrices.scale(textScale, textScale, 1);
- textRenderer.drawWithShadow(matrices, orderedText, 0, 0, j | MathHelper.ceil(this.alpha * 255.0F) << 24);
- matrices.pop();
+ font.drawShadow(matrices, orderedText, 0, 0, j | Mth.ceil(this.alpha * 255.0F) << 24);
+ matrices.popPose();
}
}