From 3a86e9d2ba89466f7f9ef51c29eb5879bcb8a98e Mon Sep 17 00:00:00 2001 From: isXander Date: Thu, 17 Nov 2022 17:18:19 +0000 Subject: 22w46a --- src/main/java/dev/isxander/yacl/gui/AbstractWidget.java | 2 +- src/main/java/dev/isxander/yacl/gui/CategoryListWidget.java | 4 ++-- .../java/dev/isxander/yacl/gui/LowProfileButtonWidget.java | 10 ++++++---- src/main/java/dev/isxander/yacl/gui/OptionListWidget.java | 6 +++--- src/main/java/dev/isxander/yacl/gui/SearchFieldWidget.java | 2 +- .../java/dev/isxander/yacl/gui/TextScaledButtonWidget.java | 11 ++++++----- src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java | 4 ++-- src/main/java/dev/isxander/yacl/gui/YACLScreen.java | 9 ++++----- src/main/resources/fabric.mod.json | 5 +++-- 9 files changed, 28 insertions(+), 25 deletions(-) (limited to 'src/main') diff --git a/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java b/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java index 03dc9b9..bede0ae 100644 --- a/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java +++ b/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java @@ -82,7 +82,7 @@ public abstract class AbstractWidget implements Element, Drawable, Selectable { int width = x2 - x1; int height = y2 - y1; - RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShader(GameRenderer::getPositionTexProgram); RenderSystem.setShaderTexture(0, ClickableWidget.WIDGETS_TEXTURE); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); int i = !enabled ? 0 : hovered ? 2 : 1; diff --git a/src/main/java/dev/isxander/yacl/gui/CategoryListWidget.java b/src/main/java/dev/isxander/yacl/gui/CategoryListWidget.java index 2cb6bb6..46a9fdf 100644 --- a/src/main/java/dev/isxander/yacl/gui/CategoryListWidget.java +++ b/src/main/java/dev/isxander/yacl/gui/CategoryListWidget.java @@ -15,7 +15,7 @@ public class CategoryListWidget extends ElementListWidget widget.render(matrices, mouseX, mouseY, tickDelta); if (resetButton != null) { - resetButton.y = y; + resetButton.setY(y); resetButton.render(matrices, mouseX, mouseY, tickDelta); } } @@ -402,8 +402,8 @@ public class OptionListWidget extends ElementListWidget public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) { this.y = y; - expandMinimizeButton.x = x; - expandMinimizeButton.y = y + entryHeight / 2 - expandMinimizeButton.getHeight() / 2; + expandMinimizeButton.setX(x); + expandMinimizeButton.setY(y + entryHeight / 2 - expandMinimizeButton.getHeight() / 2); expandMinimizeButton.render(matrices, mouseX, mouseY, tickDelta); wrappedName.drawCenterWithShadow(matrices, x + entryWidth / 2, y + getYPadding()); diff --git a/src/main/java/dev/isxander/yacl/gui/SearchFieldWidget.java b/src/main/java/dev/isxander/yacl/gui/SearchFieldWidget.java index 6184405..5b7c9dc 100644 --- a/src/main/java/dev/isxander/yacl/gui/SearchFieldWidget.java +++ b/src/main/java/dev/isxander/yacl/gui/SearchFieldWidget.java @@ -25,7 +25,7 @@ public class SearchFieldWidget extends TextFieldWidget { public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) { super.renderButton(matrices, mouseX, mouseY, delta); if (isVisible() && isEmpty()) { - textRenderer.drawWithShadow(matrices, emptyText, x + 4, this.y + (this.height - 8) / 2f, 0x707070); + textRenderer.drawWithShadow(matrices, emptyText, getX() + 4, this.getY() + (this.height - 8) / 2f, 0x707070); } } diff --git a/src/main/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java b/src/main/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java index d588d52..197a162 100644 --- a/src/main/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java +++ b/src/main/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java @@ -2,6 +2,7 @@ package dev.isxander.yacl.gui; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.screen.Tooltip; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.OrderedText; @@ -12,13 +13,13 @@ public class TextScaledButtonWidget extends ButtonWidget { 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); + super(x, y, width, height, message, onPress, ButtonWidget.DEFAULT_NARRATION_SUPPLIER); this.textScale = textScale; } - public TextScaledButtonWidget(int x, int y, int width, int height, float textScale, Text message, PressAction onPress, TooltipSupplier tooltipSupplier) { - super(x, y, width, height, message, onPress, tooltipSupplier); - this.textScale = textScale; + public TextScaledButtonWidget(int x, int y, int width, int height, float textScale, Text message, PressAction onPress, Tooltip tooltip) { + this(x, y, width, height, textScale, message, onPress); + setTooltip(tooltip); } @Override @@ -35,7 +36,7 @@ public class TextScaledButtonWidget extends ButtonWidget { TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; matrices.push(); - matrices.translate(((this.x + this.width / 2f) - textRenderer.getWidth(orderedText) * textScale / 2), (float)this.y + (this.height - 8 * textScale) / 2f / textScale, 0); + matrices.translate(((this.getX() + this.width / 2f) - textRenderer.getWidth(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(); diff --git a/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java b/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java index d105f7b..706765a 100644 --- a/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java +++ b/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java @@ -13,14 +13,14 @@ public class TooltipButtonWidget extends ButtonWidget { protected MultilineText wrappedDescription; public TooltipButtonWidget(Screen screen, int x, int y, int width, int height, Text message, Text tooltip, PressAction onPress) { - super(x, y, width, height, message, onPress); + super(x, y, width, height, message, onPress, ButtonWidget.DEFAULT_NARRATION_SUPPLIER); this.screen = screen; setTooltip(tooltip); } public void renderHoveredTooltip(MatrixStack matrices) { if (isHovered()) { - YACLScreen.renderMultilineTooltip(matrices, MinecraftClient.getInstance().textRenderer, wrappedDescription, x + width / 2, y - 4, y + height + 4, screen.width, screen.height); + YACLScreen.renderMultilineTooltip(matrices, MinecraftClient.getInstance().textRenderer, wrappedDescription, getX() + width / 2, getY() - 4, getY() + height + 4, screen.width, screen.height); } } diff --git a/src/main/java/dev/isxander/yacl/gui/YACLScreen.java b/src/main/java/dev/isxander/yacl/gui/YACLScreen.java index 629fd4c..e36c8e8 100644 --- a/src/main/java/dev/isxander/yacl/gui/YACLScreen.java +++ b/src/main/java/dev/isxander/yacl/gui/YACLScreen.java @@ -13,8 +13,7 @@ import net.minecraft.client.render.*; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; import net.minecraft.util.Formatting; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Matrix4f; +import org.joml.Matrix4f; import java.util.HashSet; import java.util.Set; @@ -85,7 +84,7 @@ public class YACLScreen extends Screen { OptionUtils.forEachOptions(config, Option::forgetPendingValue); }); - searchFieldWidget = new SearchFieldWidget(this, textRenderer, width / 3 / 2 - paddedWidth / 2 + 1, undoButton.y - 22, paddedWidth - 2, 18, Text.translatable("gui.recipebook.search_hint"), Text.translatable("gui.recipebook.search_hint")); + searchFieldWidget = new SearchFieldWidget(this, textRenderer, width / 3 / 2 - paddedWidth / 2 + 1, undoButton.getY() - 22, paddedWidth - 2, 18, Text.translatable("gui.recipebook.search_hint"), Text.translatable("gui.recipebook.search_hint")); categoryList = new CategoryListWidget(client, this, width, height); addSelectableChild(categoryList); @@ -241,7 +240,7 @@ public class YACLScreen extends Screen { matrices.push(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferBuilder = tessellator.getBuffer(); - RenderSystem.setShader(GameRenderer::getPositionColorShader); + RenderSystem.setShader(GameRenderer::getPositionColorProgram); bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); Matrix4f matrix4f = matrices.peek().getPositionMatrix(); fillGradient(matrix4f, bufferBuilder, drawX - 3, drawY - 4, drawX + maxWidth + 3, drawY - 3, 400, -267386864, -267386864); @@ -257,7 +256,7 @@ public class YACLScreen extends Screen { RenderSystem.disableTexture(); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); - BufferRenderer.drawWithShader(bufferBuilder.end()); + BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); RenderSystem.disableBlend(); RenderSystem.enableTexture(); matrices.translate(0.0, 0.0, 400.0); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index fc5a14f..37b150e 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -20,8 +20,9 @@ }, "depends": { "fabricloader": ">=0.14.0", - "minecraft": "1.19.x", - "java": ">=17" + "minecraft": "~1.19.3-alpha.22.46.a", + "java": ">=17", + "fabric-resource-loader-v0": "*" }, "mixins": [ "yet-another-config-lib.mixins.json" -- cgit