From f73d876f36d3e4e8a1c5e5e1680de67bfb48253c Mon Sep 17 00:00:00 2001 From: medisant <medisant@gmx.de> Date: Thu, 22 Jun 2023 15:27:41 +0200 Subject: [PATCH] update to 1.20 --- build.gradle | 7 +- gradle.properties | 10 +-- .../config/gui/ChatWindowEditor.java | 2 +- .../config/gui/GuiTabEditor.java | 2 +- .../config/gui/WidgetMatchEntry.java | 3 +- .../advancedchathud/gui/ChatWindow.java | 87 +++++++++---------- .../advancedchathud/gui/HudSection.java | 5 +- .../advancedchathud/gui/TabButton.java | 7 +- .../advancedchathud/gui/WindowManager.java | 5 +- .../advancedchathud/mixin/MixinChatHud.java | 3 +- 10 files changed, 68 insertions(+), 63 deletions(-) diff --git a/build.gradle b/build.gradle index 8dde4e3..def253d 100644 --- a/build.gradle +++ b/build.gradle @@ -20,6 +20,7 @@ if (file("extra.properties").exists()) { repositories { mavenCentral() + mavenLocal() // only used to build the mod locally maven { url 'https://masa.dy.fi/maven' } maven { url 'https://jitpack.io' } } @@ -29,8 +30,10 @@ dependencies { mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" - modImplementation "fi.dy.masa.malilib:malilib-fabric-1.19.4:${project.malilib_version}" - modImplementation "com.github.DarkKronicle:AdvancedChatCore:${project.advancedchat_version}" + modImplementation "fi.dy.masa.malilib:malilib-fabric-1.20.1:${project.malilib_version}" + //modImplementation "com.github.DarkKronicle:AdvancedChatCore:${project.advancedchat_version}" + modImplementation "io.github.darkkronicle:AdvancedChatCore:1.20.1-1.5.10" // only used to build the mod locally + } processResources { diff --git a/gradle.properties b/gradle.properties index 8e04b91..e61a912 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,13 +1,13 @@ -minecraft_version=1.19.4 -yarn_mappings=1.19.4+build.1 -loader_version=0.14.11 -fabric_api_version=0.76.0+1.19.4 +minecraft_version=1.20.1 +yarn_mappings=1.20.1+build.5 +loader_version=0.14.21 +fabric_api_version=0.84.0+1.20.1 mod_version=1.3.8 maven_group=io.github.darkkronicle archives_base_name=AdvancedChatHUD -malilib_version = 0.15.2 +malilib_version = 0.16.0 org.gradle.jvmargs=-Xmx1G advancedchat_version=v1.5.10 diff --git a/src/main/java/io/github/darkkronicle/advancedchathud/config/gui/ChatWindowEditor.java b/src/main/java/io/github/darkkronicle/advancedchathud/config/gui/ChatWindowEditor.java index 54e0c15..7d718d7 100644 --- a/src/main/java/io/github/darkkronicle/advancedchathud/config/gui/ChatWindowEditor.java +++ b/src/main/java/io/github/darkkronicle/advancedchathud/config/gui/ChatWindowEditor.java @@ -138,7 +138,7 @@ public boolean onKeyTyped(int keyCode, int scanCode, int modifiers) { } if (keyCode == KeyCodes.KEY_ESCAPE - && this.parentScreen != GuiUtils.getCurrentScreen()) { + && this.getParent() != GuiUtils.getCurrentScreen()) { // Make sure to save closeGui(true); return true; diff --git a/src/main/java/io/github/darkkronicle/advancedchathud/config/gui/GuiTabEditor.java b/src/main/java/io/github/darkkronicle/advancedchathud/config/gui/GuiTabEditor.java index bfdc811..35b6c65 100644 --- a/src/main/java/io/github/darkkronicle/advancedchathud/config/gui/GuiTabEditor.java +++ b/src/main/java/io/github/darkkronicle/advancedchathud/config/gui/GuiTabEditor.java @@ -120,7 +120,7 @@ public boolean onKeyTyped(int keyCode, int scanCode, int modifiers) { } if (keyCode == KeyCodes.KEY_ESCAPE - && this.parentScreen != GuiUtils.getCurrentScreen()) { + && this.getParent() != GuiUtils.getCurrentScreen()) { // Make sure to save closeGui(true); return true; diff --git a/src/main/java/io/github/darkkronicle/advancedchathud/config/gui/WidgetMatchEntry.java b/src/main/java/io/github/darkkronicle/advancedchathud/config/gui/WidgetMatchEntry.java index cd4413c..9b32ec0 100644 --- a/src/main/java/io/github/darkkronicle/advancedchathud/config/gui/WidgetMatchEntry.java +++ b/src/main/java/io/github/darkkronicle/advancedchathud/config/gui/WidgetMatchEntry.java @@ -25,6 +25,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; @Environment(EnvType.CLIENT) @@ -95,7 +96,7 @@ public List<TextFieldWrapper<GuiTextFieldGeneric>> getTextFields() { } @Override - public void renderEntry(int mouseX, int mouseY, boolean selected, MatrixStack matrixStack) {} + public void renderEntry(int mouseX, int mouseY, boolean selected, DrawContext context) {} @Override public String getName() { diff --git a/src/main/java/io/github/darkkronicle/advancedchathud/gui/ChatWindow.java b/src/main/java/io/github/darkkronicle/advancedchathud/gui/ChatWindow.java index 806b76c..9d670e6 100644 --- a/src/main/java/io/github/darkkronicle/advancedchathud/gui/ChatWindow.java +++ b/src/main/java/io/github/darkkronicle/advancedchathud/gui/ChatWindow.java @@ -30,7 +30,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.sound.SoundEvents; @@ -208,20 +208,20 @@ public void updateScroll() { } public static void drawRect( - MatrixStack stack, int x, int y, int width, int height, int color) { - DrawableHelper.fill(stack, x, y, x + width, y + height, color); + DrawContext context, int x, int y, int width, int height, int color) { + context.fill(x, y, x + width, y + height, color); } - public static void fill(MatrixStack stack, int x, int y, int x2, int y2, int color) { - DrawableHelper.fill(stack, x, y, x2, y2, color); + public static void fill(DrawContext context, int x, int y, int x2, int y2, int color) { + context.fill(x, y, x2, y2, color); } private static void drawOutline( - MatrixStack stack, int x, int y, int width, int height, int color) { - drawRect(stack, x, y, 1, height, color); - drawRect(stack, x + width - 1, y, 1, height, color); - drawRect(stack, x + 1, y, width - 2, 1, color); - drawRect(stack, x + 1, y + height - 1, width - 2, 1, color); + DrawContext context, int x, int y, int width, int height, int color) { + drawRect(context, x, y, 1, height, color); + drawRect(context, x + width - 1, y, 1, height, color); + drawRect(context, x + 1, y, width - 2, 1, color); + drawRect(context, x + 1, y + height - 1, width - 2, 1, color); } public void resetScroll() { @@ -303,7 +303,7 @@ public int getTotalHeight() { return getTotalLines() * HudConfigStorage.General.LINE_SPACE.config.getIntegerValue() + (lines.size() - 1) * HudConfigStorage.General.MESSAGE_SPACE.config.getIntegerValue(); } - public void render(MatrixStack matrixStack, int ticks, boolean focused) { + public void render(DrawContext context, int ticks, boolean focused) { if (!focused) { resetScroll(); } @@ -321,8 +321,8 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) { scrolledHeight = totalHeight; } - matrixStack.push(); - matrixStack.scale((float) getScale(), (float) getScale(), 1); + context.getMatrices().push(); + context.getMatrices().scale((float) getScale(), (float) getScale(), 1); int lines = 0; int currentHeight = 0; @@ -369,7 +369,7 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) { } ChatMessage.AdvancedChatLine line = message.getLines().get(renderTopFirst ? message.getLineCount() - i - 1 : i); drawLine( - matrixStack, + context, line, leftX, renderTopFirst ? limit - y.getValue() + client.textRenderer.fontHeight : y.getValue(), @@ -407,7 +407,7 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) { if (focused && !isMinimalist()) { drawOutline( - matrixStack, + context, leftX, getActualY(0) - scaledHeight - 1, scaledWidth, @@ -418,35 +418,34 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) { String label = tab.getAbbreviation(); int labelWidth = StringUtils.getStringWidth(label) + 8; drawRect( - matrixStack, + context, leftX, getActualY(newY), labelWidth, scaledBar, tab.getMainColor().color()); drawOutline( - matrixStack, + context, leftX, getActualY(newY), labelWidth, scaledBar, tab.getBorderColor().color()); - DrawableHelper.drawCenteredTextWithShadow( - matrixStack, + context.drawCenteredTextWithShadow( MinecraftClient.getInstance().textRenderer, tab.getAbbreviation(), leftX + (labelWidth) / 2, getActualY(newY - 3), Colors.getInstance().getColorOrWhite("white").color()); drawRect( - matrixStack, + context, leftX + labelWidth, getActualY(newY), getScaledWidth() - labelWidth, scaledBar, selected ? tab.getMainColor().color() : tab.getInnerColor().color()); drawOutline( - matrixStack, + context, leftX + labelWidth, getActualY(newY), getScaledWidth() - labelWidth, @@ -454,21 +453,21 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) { tab.getBorderColor().color()); drawOutline( - matrixStack, + context, rightX - scaledBar, getActualY(newY), scaledBar, scaledBar, tab.getBorderColor().color()); drawOutline( - matrixStack, + context, rightX - scaledBar * 2 + 1, getActualY(newY), scaledBar, scaledBar, tab.getBorderColor().color()); drawOutline( - matrixStack, + context, rightX - scaledBar * 3 + 2, getActualY(newY), scaledBar, @@ -478,8 +477,8 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) { // Close RenderUtils.color(1, 1, 1, 1); RenderUtils.bindTexture(X_ICON); - DrawableHelper.drawTexture( - matrixStack, + context.drawTexture( + X_ICON, rightX - scaledBar + 1, getActualY(newY - 1), scaledBar - 2, @@ -494,8 +493,8 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) { // Resize RenderUtils.color(1, 1, 1, 1); RenderUtils.bindTexture(RESIZE_ICON); - DrawableHelper.drawTexture( - matrixStack, + context.drawTexture( + X_ICON, rightX - scaledBar * 2 + 2, getActualY(newY - 1), scaledBar - 2, @@ -509,8 +508,8 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) { // Visibility RenderUtils.bindTexture(visibility.getTexture()); - DrawableHelper.drawTexture( - matrixStack, + context.drawTexture( + visibility.getTexture(), rightX - scaledBar * 3 + 3, getActualY(newY - 1), scaledBar - 2, @@ -525,8 +524,7 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) { double mouseX = client.mouse.getX() / 2; double mouseY = client.mouse.getY() / 2; if (isMouseOverVisibility(mouseX, mouseY)) { - DrawableHelper.drawCenteredTextWithShadow( - matrixStack, + context.drawCenteredTextWithShadow( client.textRenderer, visibility.getDisplayName(), (int) (mouseX / getScale() + 4), @@ -539,7 +537,7 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) { if (y.getValue() < getScaledHeight()) { // Check to see if we've already gone above the boundaries fill( - matrixStack, + context, leftX, getActualY(renderTopFirst ? limit - y.getValue() : y.getValue()), rightX, @@ -550,18 +548,18 @@ public void render(MatrixStack matrixStack, int ticks, boolean focused) { float add = (float) (scrolledHeight) / (getTotalHeight()); int scrollHeight = (int) (add * (getScaledHeight() - 10)); drawRect( - matrixStack, + context, getScaledWidth() + leftX - 1, getActualY(scrollHeight + 10), 1, 10, Colors.getInstance().getColorOrWhite("white").color()); } - matrixStack.pop(); + context.getMatrices().pop(); } private void drawLine( - MatrixStack matrixStack, + DrawContext context, ChatMessage.AdvancedChatLine line, int x, int y, @@ -656,9 +654,9 @@ private void drawLine( backgroundY -= 1 + HudConfigStorage.General.TOP_PAD.config.getIntegerValue(); } if (renderRight) { - drawRect(matrixStack, x + (scaledWidth - backgroundWidth), backgroundY, backgroundWidth, height, background.color()); + drawRect(context, x + (scaledWidth - backgroundWidth), backgroundY, backgroundWidth, height, background.color()); } else { - drawRect(matrixStack, x, backgroundY, backgroundWidth, height, background.color()); + drawRect(context, x, backgroundY, backgroundWidth, height, background.color()); } if (lineIndex == line.getParent().getLineCount() - 1 && line.getParent().getOwner() != null @@ -675,15 +673,14 @@ private void drawLine( headX = pLX - 10; } int headY = getActualY(y); - DrawableHelper.drawTexture( - matrixStack, headX, headY, 8, 8, 8, 8, 8, 8, 64, 64); - DrawableHelper.drawTexture( - matrixStack, headX, headY, 8, 8, 40, 8, 8, 8, 64, 64); + context.drawTexture( + line.getParent().getOwner().getTexture(), headX, headY, 8, 8, 8, 8, 8, 8, 64, 64); + context.drawTexture( + line.getParent().getOwner().getTexture(), headX, headY, 8, 8, 40, 8, 8, 8, 64, 64); RenderSystem.setShaderColor(1, 1, 1, 1); } - - client.textRenderer.drawWithShadow( - matrixStack, render.asOrderedText(), renderRight ? pRX - lineWidth : pLX, getActualY(y) + 1, text.color()); + context.drawTextWithShadow( + client.textRenderer, render.asOrderedText(), renderRight ? pRX - lineWidth : pLX, getActualY(y) + 1, text.color()); } public Style getText(double mouseX, double mouseY) { diff --git a/src/main/java/io/github/darkkronicle/advancedchathud/gui/HudSection.java b/src/main/java/io/github/darkkronicle/advancedchathud/gui/HudSection.java index 25614fa..1664f1c 100644 --- a/src/main/java/io/github/darkkronicle/advancedchathud/gui/HudSection.java +++ b/src/main/java/io/github/darkkronicle/advancedchathud/gui/HudSection.java @@ -27,6 +27,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Style; @@ -107,9 +108,9 @@ public void initGui() { } @Override - public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { + public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) { if (menu != null) { - menu.render(mouseX, mouseY, true, matrixStack); + menu.render(mouseX, mouseY, true, context); } } diff --git a/src/main/java/io/github/darkkronicle/advancedchathud/gui/TabButton.java b/src/main/java/io/github/darkkronicle/advancedchathud/gui/TabButton.java index e984fe1..33c5c32 100644 --- a/src/main/java/io/github/darkkronicle/advancedchathud/gui/TabButton.java +++ b/src/main/java/io/github/darkkronicle/advancedchathud/gui/TabButton.java @@ -16,6 +16,7 @@ import io.github.darkkronicle.advancedchathud.config.HudConfigStorage; import io.github.darkkronicle.advancedchathud.itf.IChatHud; import io.github.darkkronicle.advancedchathud.tabs.AbstractChatTab; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.sound.SoundEvents; @@ -36,7 +37,7 @@ private TabButton(AbstractChatTab tab, int x, int y, int width, int height) { } @Override - public void render(int mouseX, int mouseY, boolean unused, MatrixStack matrixStack) { + public void render(int mouseX, int mouseY, boolean unused, DrawContext context) { int relMX = mouseX - x; int relMY = mouseY - y; hovered = relMX >= 0 && relMX <= width && relMY >= 0 && relMY <= height; @@ -61,7 +62,7 @@ public void render(int mouseX, int mouseY, boolean unused, MatrixStack matrixSta RenderUtils.drawRect(x, y, width, height, color.color()); drawStringWithShadow( - x + PADDING, y + PADDING, selected ? WHITE : GRAY, displayString, matrixStack); + x + PADDING, y + PADDING, selected ? WHITE : GRAY, displayString, context); if (tab.isShowUnread() && tab.getUnread() > 0) { String unread = TextUtil.toSuperscript(Math.min(tab.getUnread(), 99)); drawCenteredString( @@ -69,7 +70,7 @@ public void render(int mouseX, int mouseY, boolean unused, MatrixStack matrixSta y + PADDING, RED, unread, - matrixStack); + context); } } diff --git a/src/main/java/io/github/darkkronicle/advancedchathud/gui/WindowManager.java b/src/main/java/io/github/darkkronicle/advancedchathud/gui/WindowManager.java index 75269cd..9739c30 100644 --- a/src/main/java/io/github/darkkronicle/advancedchathud/gui/WindowManager.java +++ b/src/main/java/io/github/darkkronicle/advancedchathud/gui/WindowManager.java @@ -32,6 +32,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ChatScreen; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.util.math.MatrixStack; @@ -109,14 +110,14 @@ public JsonArray saveJson() { } @Override - public void onRenderGameOverlayPost(MatrixStack matrixStack) { + public void onRenderGameOverlayPost(DrawContext context) { boolean isFocused = isChatFocused(); int ticks = client.inGameHud.getTicks(); if (!HudConfigStorage.General.RENDER_IN_OTHER_GUI.config.getBooleanValue() && !isFocused && client.currentScreen != null) { return; } for (int i = windows.size() - 1; i >= 0; i--) { - windows.get(i).render(matrixStack, ticks, isFocused); + windows.get(i).render(context, ticks, isFocused); } } diff --git a/src/main/java/io/github/darkkronicle/advancedchathud/mixin/MixinChatHud.java b/src/main/java/io/github/darkkronicle/advancedchathud/mixin/MixinChatHud.java index 326a1bb..a0be468 100644 --- a/src/main/java/io/github/darkkronicle/advancedchathud/mixin/MixinChatHud.java +++ b/src/main/java/io/github/darkkronicle/advancedchathud/mixin/MixinChatHud.java @@ -19,6 +19,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.client.gui.hud.ChatHudLine; import net.minecraft.client.util.ChatMessages; @@ -72,7 +73,7 @@ private void scroll(int amount, CallbackInfo ci) { } @Inject(at = @At("HEAD"), method = "render", cancellable = true) - private void render(MatrixStack stack, int delta, int mouseX, int mouseY, CallbackInfo ci) { + private void render(DrawContext context, int delta, int mouseX, int mouseY, CallbackInfo ci) { // Ignore rendering vanilla chat if disabled if (!HudConfigStorage.General.VANILLA_HUD.config.getBooleanValue()) { ci.cancel();