diff --git a/.gitignore b/.gitignore index 21638f0..8dfb399 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,14 @@ .idea/ +.vscode/ *.iml *.ipr *.iws lib/ run/ out/ +bin/ build/ .gradle/ classes/ -lombok.config \ No newline at end of file +lombok.config +extra.properties diff --git a/build.gradle b/build.gradle index db10b40..c6bf133 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,19 @@ plugins { - id 'fabric-loom' version '1.0-SNAPSHOT' - id 'maven-publish' - id "io.freefair.lombok" version "6.0.0-m2" + id "fabric-loom" version "1.11-SNAPSHOT" + id "maven-publish" + id "io.freefair.lombok" version "8.10" } -apply from: 'https://raw.githubusercontent.com/DarkKronicle/GradleScripts/main/gradle/publish.gradle' +java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } +} -sourceCompatibility = JavaVersion.VERSION_17 -targetCompatibility = JavaVersion.VERSION_17 +// apply from: 'https://raw.githubusercontent.com/DarkKronicle/GradleScripts/main/gradle/publish.gradle' + +sourceCompatibility = JavaVersion.VERSION_21 +targetCompatibility = JavaVersion.VERSION_21 archivesBaseName = project.archives_base_name version = "${project.minecraft_version}-${project.mod_version}" @@ -29,10 +35,14 @@ dependencies { minecraft "com.mojang:minecraft:${project.minecraft_version}" 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.20.2:${project.malilib_version}" - //modImplementation "com.github.DarkKronicle:AdvancedChatCore:${project.advancedchat_version}" - modImplementation "io.github.darkkronicle:AdvancedChatCore:1.20.4-1.5.10" // only used to build the mod locally + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + modImplementation "com.github.sakura-ryoko:malilib:${project.malilib_version}" + // modImplementation "com.github.DarkKronicle:AdvancedChatCore:${project.advancedchat_version}" + modImplementation "io.github.darkkronicle:AdvancedChatCore:${project.minecraft_version}-${project.mod_version}" + // modImplementation files("libs/AdvancedChatCore-${project.advancedchat_version}.jar") + + modImplementation "com.github.DarkKronicle.Konstruct:addons:${project.konstruct_version}" + modImplementation "com.github.DarkKronicle.Konstruct:core:${project.konstruct_version}" } @@ -46,14 +56,15 @@ processResources { tasks.withType(JavaCompile).configureEach { it.options.encoding = "UTF-8" - it.options.release = 17 + it.options.release = 21 } // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task // if it is present. // If you remove this task, sources will not be generated. -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = "sources" +tasks.register('sourcesJar', Jar) { + dependsOn classes + archiveClassifier.set('sources') from sourceSets.main.allSource } @@ -78,6 +89,6 @@ publishing { // select the repositories you want to publish to repositories { // uncomment to publish to the local maven - // mavenLocal() + mavenLocal() } } diff --git a/gradle.properties b/gradle.properties index 2c2717d..435ba49 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,19 @@ -minecraft_version=1.20.4 -yarn_mappings=1.20.4+build.3 -loader_version=0.15.3 -fabric_api_version=0.92.0+1.20.4 +org.gradle.jvmargs=-Xmx1G +org.gradle.parallel=true + +minecraft_version=1.21.8 +yarn_mappings=1.21.8+build.1 +loader_version=0.17.2 +loom_version=1.11-SNAPSHOT -mod_version=1.3.8 +fabric_version=0.132.0+1.21.8 + +mod_version=1.8.0 maven_group=io.github.darkkronicle archives_base_name=AdvancedChatHUD -malilib_version = 0.17.0 -org.gradle.jvmargs=-Xmx1G -advancedchat_version=v1.5.10 +malilib_version=1.21.8-0.25.5-sakura.4 +konstruct_version=2.0.3-build1 # Uploading data curseforge_slug=advancedchathud @@ -26,4 +30,4 @@ project_logo=https://raw.githubusercontent.com/Prospector/images/master/modmenu- project_color=0x134bff changelog_hide_unimportant_commits=true changelog_max_commit_search=200 -discord_webhook_changelog_line_limit=10 \ No newline at end of file +discord_webhook_changelog_line_limit=10 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7c08e4f..d4081da 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists \ No newline at end of file +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index df3a6fe..965aff3 100755 --- a/gradlew +++ b/gradlew @@ -180,4 +180,4 @@ APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -exec "$JAVACMD" "$@" \ No newline at end of file +exec "$JAVACMD" "$@" diff --git a/src/main/java/io/github/darkkronicle/advancedchathud/config/HudConfigStorage.java b/src/main/java/io/github/darkkronicle/advancedchathud/config/HudConfigStorage.java index c5d5bac..03db527 100644 --- a/src/main/java/io/github/darkkronicle/advancedchathud/config/HudConfigStorage.java +++ b/src/main/java/io/github/darkkronicle/advancedchathud/config/HudConfigStorage.java @@ -306,7 +306,10 @@ public static void loadFromFile() { } ConfigStorage.readOptions( - root, General.NAME, (List>) General.OPTIONS); + root, + General.NAME, + (List>) (List) General.OPTIONS + ); int version = JsonUtils.getIntegerOrDefault(root, "configVersion", 0); } @@ -321,7 +324,10 @@ public static void saveFromFile() { JsonObject root = new JsonObject(); ConfigStorage.writeOptions( - root, General.NAME, (List>) General.OPTIONS); + root, + General.NAME, + (List>) (List) General.OPTIONS + ); root.add("maintab", tabJson.save(MAIN_TAB)); @@ -419,9 +425,9 @@ private static String translate(String key) { Visibility(String configString) { this.texture = - new Identifier( - AdvancedChatHud.MOD_ID, - "textures/gui/chatwindow/" + configString + ".png"); + Identifier.of( + AdvancedChatHud.MOD_ID, + "textures/gui/chatwindow/" + configString + ".png"); this.configString = configString; } 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 3f847e4..e930294 100644 --- a/src/main/java/io/github/darkkronicle/advancedchathud/gui/ChatWindow.java +++ b/src/main/java/io/github/darkkronicle/advancedchathud/gui/ChatWindow.java @@ -7,32 +7,41 @@ */ package io.github.darkkronicle.advancedchathud.gui; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + import com.google.gson.JsonObject; +import com.mojang.blaze3d.pipeline.RenderPipeline; import com.mojang.blaze3d.systems.RenderSystem; + import fi.dy.masa.malilib.render.RenderUtils; import fi.dy.masa.malilib.util.StringUtils; import io.github.darkkronicle.advancedchatcore.chat.ChatMessage; import io.github.darkkronicle.advancedchatcore.config.ConfigStorage; import io.github.darkkronicle.advancedchatcore.interfaces.IJsonSave; -import io.github.darkkronicle.advancedchatcore.util.*; +import io.github.darkkronicle.advancedchatcore.util.Color; +import io.github.darkkronicle.advancedchatcore.util.ColorUtil; +import io.github.darkkronicle.advancedchatcore.util.Colors; +import io.github.darkkronicle.advancedchatcore.util.EasingMethod; +import io.github.darkkronicle.advancedchatcore.util.LimitedInteger; +import io.github.darkkronicle.advancedchatcore.util.RawText; +import io.github.darkkronicle.advancedchatcore.util.TextBuilder; import io.github.darkkronicle.advancedchathud.AdvancedChatHud; import io.github.darkkronicle.advancedchathud.HudChatMessage; import io.github.darkkronicle.advancedchathud.HudChatMessageHolder; import io.github.darkkronicle.advancedchathud.config.HudConfigStorage; import io.github.darkkronicle.advancedchathud.tabs.AbstractChatTab; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - import io.github.darkkronicle.advancedchathud.util.ScissorUtil; import lombok.Getter; import lombok.Setter; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gl.RenderPipelines; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.sound.PositionedSoundInstance; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.render.RenderLayer; import net.minecraft.sound.SoundEvents; import net.minecraft.text.Style; import net.minecraft.text.Text; @@ -78,10 +87,10 @@ public class ChatWindow { @Getter private AbstractChatTab tab; private static final Identifier X_ICON = - new Identifier(AdvancedChatHud.MOD_ID, "textures/gui/chatwindow/x_icon.png"); + Identifier.of(AdvancedChatHud.MOD_ID, "textures/gui/chatwindow/x_icon.png"); private static final Identifier RESIZE_ICON = - new Identifier(AdvancedChatHud.MOD_ID, "textures/gui/chatwindow/resize_icon.png"); + Identifier.of(AdvancedChatHud.MOD_ID, "textures/gui/chatwindow/resize_icon.png"); public ChatWindow(AbstractChatTab tab) { this.client = MinecraftClient.getInstance(); @@ -312,6 +321,10 @@ public void render(DrawContext context, int ticks, boolean focused) { return; } + if (client.options.hudHidden) { + return; + } + int totalLines = getTotalLines(); boolean chatFocused = visibility == HudConfigStorage.Visibility.ALWAYS || focused; @@ -321,8 +334,8 @@ public void render(DrawContext context, int ticks, boolean focused) { scrolledHeight = totalHeight; } - context.getMatrices().push(); - context.getMatrices().scale((float) getScale(), (float) getScale(), 1); + context.getMatrices().pushMatrix(); + context.getMatrices().scale((float) getScale(), (float) getScale()); // TODO: See if this is right int lines = 0; int currentHeight = 0; @@ -475,55 +488,76 @@ public void render(DrawContext context, int ticks, boolean focused) { tab.getBorderColor().color()); // Close - RenderUtils.color(1, 1, 1, 1); - RenderUtils.bindTexture(X_ICON); + // RenderUtils.color(1, 1, 1, 1); // TODO: See if this was required + // RenderUtils.bindTexture(X_ICON); // TODO: See if this was required context.drawTexture( - X_ICON, - rightX - scaledBar + 1, - getActualY(newY - 1), - scaledBar - 2, - scaledBar - 2, - 0, - 0, - 32, - 32, - 32, - 32); + RenderPipelines.GUI_TEXTURED, + X_ICON, + rightX - scaledBar + 1, // x + getActualY(newY - 1), // y + 0, // u + 0, // v + scaledBar - 2, // width + scaledBar - 2, // height + 32, // regionWidth + 32, // regionHeight + 32, // textureWidth + 32 // textureHeight + ); // Resize - RenderUtils.color(1, 1, 1, 1); - RenderUtils.bindTexture(RESIZE_ICON); + // RenderUtils.color(1, 1, 1, 1); // TODO: See if this was required + // RenderUtils.bindTexture(RESIZE_ICON); // TODO: See if this was required context.drawTexture( - RESIZE_ICON, - rightX - scaledBar * 2 + 2, - getActualY(newY - 1), - scaledBar - 2, - scaledBar - 2, - 0, - 0, - 32, - 32, - 32, - 32); + RenderPipelines.GUI_TEXTURED, + RESIZE_ICON, + rightX - scaledBar * 2 + 2, // x + getActualY(newY - 1), // y + 0, // u + 0, // v + scaledBar - 2, // width + scaledBar - 2, // height + 32, // regionWidth + 32, // regionHeight + 32, // textureWidth + 32 // textureHeight + ); // Visibility - RenderUtils.bindTexture(visibility.getTexture()); + // RenderUtils.bindTexture(visibility.getTexture()); // TODO: See if this was required context.drawTexture( - visibility.getTexture(), - rightX - scaledBar * 3 + 3, - getActualY(newY - 1), - scaledBar - 2, - scaledBar - 2, - 0, - 0, - 32, - 32, - 32, - 32); + RenderPipelines.GUI_TEXTURED, + visibility.getTexture(), + rightX - scaledBar * 3 + 3, // x + getActualY(newY - 1), // y + 0, // u + 0, // v + scaledBar - 2, // regionWidth + scaledBar - 2, // regionHeight + 32, // textureWidth + 32, // textureHeight + 32, // regionWidth + 32 // regionHeight + ); double mouseX = client.mouse.getX() / 2; double mouseY = client.mouse.getY() / 2; - if (isMouseOverVisibility(mouseX, mouseY)) { + + if (isMouseOverClose(mouseX, mouseY)) { + context.drawCenteredTextWithShadow( + client.textRenderer, + "Close", + (int) (mouseX / getScale() + 4), + (int) (mouseY / getScale() - 16), + Colors.getInstance().getColorOrWhite("white").color()); + } else if (isMouseOverResize(mouseX, mouseY)) { + context.drawCenteredTextWithShadow( + client.textRenderer, + "Resize", + (int) (mouseX / getScale() + 4), + (int) (mouseY / getScale() - 16), + Colors.getInstance().getColorOrWhite("white").color()); + } else if (isMouseOverVisibility(mouseX, mouseY)) { context.drawCenteredTextWithShadow( client.textRenderer, visibility.getDisplayName(), @@ -555,7 +589,7 @@ public void render(DrawContext context, int ticks, boolean focused) { 10, Colors.getInstance().getColorOrWhite("white").color()); } - context.getMatrices().pop(); + context.getMatrices().popMatrix(); } private void drawLine( @@ -662,10 +696,10 @@ private void drawLine( && line.getParent().getOwner() != null && HudConfigStorage.General.CHAT_HEADS.config.getBooleanValue()) { // Allow head to be transparent - RenderUtils.setupBlend(); + // RenderUtils.setupBlend(); // TODO: See if this was required // Draw head - RenderSystem.setShaderColor(1, 1, 1, applied); - RenderSystem.setShaderTexture(0, line.getParent().getOwner().getTexture()); + // RenderSystem.setShaderColor(1, 1, 1, applied); // TODO: See if this was required + // RenderSystem.setShaderTexture(0, line.getParent().getOwner().getTexture()); // TODO: See if this was required int headX; if (renderRight) { headX = pRX + 2; @@ -674,13 +708,43 @@ private void drawLine( } int headY = getActualY(y); context.drawTexture( - line.getParent().getOwner().getTexture(), headX, headY, 8, 8, 8, 8, 8, 8, 64, 64); + RenderPipelines.GUI_TEXTURED, + line.getParent().getOwner().getTexture(), + headX, // x + headY, // y + 8, // u + 8, // v + 8, // width + 8, // height + 8, // regionWidth + 8, // regionHeight + 64, // textureWidth + 64 // textureHeight + ); context.drawTexture( - line.getParent().getOwner().getTexture(), headX, headY, 8, 8, 40, 8, 8, 8, 64, 64); - RenderSystem.setShaderColor(1, 1, 1, 1); + RenderPipelines.GUI_TEXTURED, + line.getParent().getOwner().getTexture(), + headX, // x + headY, // y + 40, // u + 8, // v + 8, // width + 8, // height + 8, // regionWidth + 8, // regionHeight + 64, // textureWidth + 64 // textureHeight + ); + + // RenderSystem.setShaderColor(1, 1, 1, 1); // TODO: See if this was required } context.drawTextWithShadow( - client.textRenderer, render.asOrderedText(), renderRight ? pRX - lineWidth : pLX, getActualY(y) + 1, text.color()); + client.textRenderer, + render.asOrderedText(), + renderRight ? pRX - lineWidth : pLX, + getActualY(y) + 1, + text.color() + ); } public Style getText(double mouseX, double mouseY) { @@ -846,6 +910,17 @@ public boolean onMouseClicked(double mouseX, double mouseY, int button) { return true; } + public boolean isMouseOverClose(double mouseX, double mouseY) { + int x = getConvertedX(); + int y = getConvertedY(); + int width = getConvertedWidth(); + int height = getConvertedHeight(); + return (isMouseOver(mouseX, mouseY) + && mouseX >= x + width - (getScaledBarHeight() * 1) + && mouseX <= x + width - (getScaledBarHeight() * 0) + && mouseY <= y - height); + } + public boolean isMouseOverResize(double mouseX, double mouseY) { int x = getConvertedX(); int y = getConvertedY(); @@ -853,7 +928,7 @@ public boolean isMouseOverResize(double mouseX, double mouseY) { int height = getConvertedHeight(); return (isMouseOver(mouseX, mouseY) && mouseX >= x + width - (getScaledBarHeight() * 2) - && mouseX <= x + width - (getScaledBarHeight()) + && mouseX <= x + width - (getScaledBarHeight() * 1) && mouseY <= y - height); } 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 f902740..1524dfb 100644 --- a/src/main/java/io/github/darkkronicle/advancedchathud/gui/HudSection.java +++ b/src/main/java/io/github/darkkronicle/advancedchathud/gui/HudSection.java @@ -26,6 +26,7 @@ import io.github.darkkronicle.advancedchathud.tabs.CustomChatTab; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; @@ -48,10 +49,10 @@ public class HudSection extends AdvancedChatScreenSection { private static final Identifier ADD_ICON = - new Identifier(AdvancedChatHud.MOD_ID, "textures/gui/chatwindow/add_window.png"); + Identifier.of(AdvancedChatHud.MOD_ID, "textures/gui/chatwindow/add_window.png"); private static final Identifier RESET_ICON = - new Identifier(AdvancedChatHud.MOD_ID, "textures/gui/chatwindow/reset_windows.png"); + Identifier.of(AdvancedChatHud.MOD_ID, "textures/gui/chatwindow/reset_windows.png"); private ContextMenu menu = null; @@ -110,7 +111,7 @@ public void initGui() { @Override public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) { if (menu != null) { - menu.render(mouseX, mouseY, true, context); + menu.render(context, mouseX, mouseY, true); } } @@ -121,7 +122,7 @@ public void createContextMenu(int mouseX, int mouseY) { TextBuilder data = new TextBuilder(); try { data.append( - message.getTime().format(DateTimeFormatter.ofPattern(ConfigStorage.General.TIME_FORMAT.config.getStringValue())), Style.EMPTY.withFormatting(Formatting.AQUA) + message.getTime().format(DateTimeFormatter.ofPattern(ConfigStorage.General.TIME_FORMAT.config.getStringValue())), Style.EMPTY.withFormatting(Formatting.AQUA) ); } catch (IllegalArgumentException e) { AdvancedChatHud.LOGGER.log(Level.WARN, "Can't format time for context menu!", e); @@ -139,6 +140,16 @@ public void createContextMenu(int mouseX, int mouseY) { InfoUtils.printActionbarMessage("advancedchathud.context.nothing"); }); } + if (message.getOwner() != null) { + String messageOwnerName = message.getOwner().getEntry().getProfile().getName(); + + actions.put( + Text.literal(StringUtils.translate("advancedchathud.context.messageowner").formatted(messageOwnerName)), + (x, y) -> { + getScreen().getChatField().setText("/msg %s ".formatted(messageOwnerName)); + } + ); + } actions.put(Text.literal(StringUtils.translate("advancedchathud.context.copy")), (x, y) -> { MinecraftClient.getInstance().keyboard.setClipboard(message.getOriginalText().getString()); InfoUtils.printActionbarMessage("advancedchathud.context.copied"); @@ -146,20 +157,61 @@ public void createContextMenu(int mouseX, int mouseY) { actions.put(Text.literal(StringUtils.translate("advancedchathud.context.delete")), (x, y) -> { HudChatMessageHolder.getInstance().removeChatMessage(message); }); - if (message.getOwner() != null) { - actions.put(Text.literal(StringUtils.translate("advancedchathud.context.messageowner")), (x, y) -> { - getScreen().getChatField().setText("/msg " + message.getOwner().getEntry().getProfile().getName() + " "); - }); - } } ChatWindow hovered = WindowManager.getInstance().getHovered(mouseX, mouseY); - actions.put(Text.literal(StringUtils.translate("advancedchathud.context.removeallwindows")), (x, y) -> WindowManager.getInstance().reset()); - actions.put(Text.literal(StringUtils.translate("advancedchathud.context.clearallmessages")), (x, y) -> WindowManager.getInstance().clear()); if (hovered != null) { + actions.put(Text.literal(StringUtils.translate("advancedchathud.context.minimalist")), (x, y) -> hovered.toggleMinimalist()); actions.put(Text.literal(StringUtils.translate("advancedchathud.context.duplicatewindow")), (x, y) -> WindowManager.getInstance().duplicateTab(hovered, x, y)); actions.put(Text.literal(StringUtils.translate("advancedchathud.context.configurewindow")), (x, y) -> WindowManager.getInstance().configureTab(getScreen(), hovered)); - actions.put(Text.literal(StringUtils.translate("advancedchathud.context.minimalist")), (x, y) -> hovered.toggleMinimalist()); } + actions.put( + Text.literal(StringUtils.translate("advancedchathud.context.clearallmessages")), + (x, y) -> { + LinkedHashMap cActions = new LinkedHashMap<>(); + cActions.put(Text.literal(StringUtils.translate("advancedchathud.context.confirm")), (x1, y1) -> {}); + cActions.put(Text.literal(StringUtils.translate("advancedchathud.context.yes")), (x1, y1) -> { + WindowManager.getInstance().clear(); + }); + cActions.put(Text.literal(StringUtils.translate("advancedchathud.context.cancel")), (x1, y1) -> { + menu = new ContextMenu(mouseX, mouseY, actions, () -> menu = null); + }); + + // Close the current menu + menu.getClose().run(); + + new Thread(() -> { + try { + Thread.sleep(50); + } catch (InterruptedException e) {} + + menu = new ContextMenu(x, y, cActions, () -> menu = null); + }).start(); + } + ); + actions.put( + Text.literal(StringUtils.translate("advancedchathud.context.removeallwindows")), + (x, y) -> { + LinkedHashMap cActions = new LinkedHashMap<>(); + cActions.put(Text.literal(StringUtils.translate("advancedchathud.context.confirm")), (x1, y1) -> {}); + cActions.put(Text.literal(StringUtils.translate("advancedchathud.context.yes")), (x1, y1) -> { + WindowManager.getInstance().reset(); + }); + cActions.put(Text.literal(StringUtils.translate("advancedchathud.context.cancel")), (x1, y1) -> { + menu = new ContextMenu(mouseX, mouseY, actions, () -> menu = null); + }); + + // Close the current menu + menu.getClose().run(); + + new Thread(() -> { + try { + Thread.sleep(50); + } catch (InterruptedException e) {} + + menu = new ContextMenu(x, y, cActions, () -> menu = null); + }).start(); + } + ); menu = new ContextMenu(mouseX, mouseY, actions, () -> menu = null); } 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 33c5c32..88f4a9a 100644 --- a/src/main/java/io/github/darkkronicle/advancedchathud/gui/TabButton.java +++ b/src/main/java/io/github/darkkronicle/advancedchathud/gui/TabButton.java @@ -18,7 +18,6 @@ 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; public class TabButton extends CleanButton { @@ -37,7 +36,7 @@ private TabButton(AbstractChatTab tab, int x, int y, int width, int height) { } @Override - public void render(int mouseX, int mouseY, boolean unused, DrawContext context) { + public void render(DrawContext context, int mouseX, int mouseY, boolean unused) { int relMX = mouseX - x; int relMY = mouseY - y; hovered = relMX >= 0 && relMX <= width && relMY >= 0 && relMY <= height; @@ -59,18 +58,13 @@ public void render(int mouseX, int mouseY, boolean unused, DrawContext context) color = new Color(color.red() / 2, color.green() / 2, color.blue() / 2, 100); } - RenderUtils.drawRect(x, y, width, height, color.color()); + RenderUtils.drawRect(context, x, y, width, height, color.color()); // TODO: See if this is correct + + drawStringWithShadow(context, x + PADDING, y + PADDING, selected ? WHITE : GRAY, displayString); - drawStringWithShadow( - 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( - x + width - ((UNREAD_WIDTH + PADDING) / 2) - 1, - y + PADDING, - RED, - unread, - context); + drawCenteredString(context, x + width - ((UNREAD_WIDTH + PADDING) / 2) - 1, y + PADDING, RED, unread); } } 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 a0be468..d22dc12 100644 --- a/src/main/java/io/github/darkkronicle/advancedchathud/mixin/MixinChatHud.java +++ b/src/main/java/io/github/darkkronicle/advancedchathud/mixin/MixinChatHud.java @@ -31,6 +31,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -47,6 +48,7 @@ public abstract class MixinChatHud implements IChatHud { @Shadow private int scrolledLines; @Shadow private boolean hasUnreadNewMessages; + @Unique private AbstractChatTab tab; @Shadow @@ -56,7 +58,7 @@ public abstract class MixinChatHud implements IChatHud { public abstract double getChatScale(); @Shadow - protected abstract boolean isChatFocused(); + public abstract boolean isChatFocused(); @Shadow public abstract void scroll(int amount); @@ -73,7 +75,7 @@ private void scroll(int amount, CallbackInfo ci) { } @Inject(at = @At("HEAD"), method = "render", cancellable = true) - private void render(DrawContext context, int delta, int mouseX, int mouseY, CallbackInfo ci) { + private void render(DrawContext context, int currentTick, int mouseX, int mouseY, boolean focused, CallbackInfo ci) { // Ignore rendering vanilla chat if disabled if (!HudConfigStorage.General.VANILLA_HUD.config.getBooleanValue()) { ci.cancel(); diff --git a/src/main/java/io/github/darkkronicle/advancedchathud/mixin/MixinInGameHud.java b/src/main/java/io/github/darkkronicle/advancedchathud/mixin/MixinInGameHud.java new file mode 100644 index 0000000..e41e151 --- /dev/null +++ b/src/main/java/io/github/darkkronicle/advancedchathud/mixin/MixinInGameHud.java @@ -0,0 +1,26 @@ +package io.github.darkkronicle.advancedchathud.mixin; + +import fi.dy.masa.malilib.event.RenderEventHandler; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.client.render.RenderTickCounter; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(value = InGameHud.class, priority = 1150) +public abstract class MixinInGameHud { + @Shadow @Final private MinecraftClient client; + + @Inject(method = "", at = @At("TAIL")) + private void onInit(CallbackInfo info) {} + + @Inject(method = "render", at = @At("TAIL")) + private void onGameOverlayPost(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { + ((RenderEventHandler) RenderEventHandler.getInstance()).onRenderGameOverlayPost(context, this.client, tickCounter.getTickProgress(false)); + } +} diff --git a/src/main/java/io/github/darkkronicle/advancedchathud/util/ScissorUtil.java b/src/main/java/io/github/darkkronicle/advancedchathud/util/ScissorUtil.java index 8074608..f17bb4a 100644 --- a/src/main/java/io/github/darkkronicle/advancedchathud/util/ScissorUtil.java +++ b/src/main/java/io/github/darkkronicle/advancedchathud/util/ScissorUtil.java @@ -1,6 +1,6 @@ package io.github.darkkronicle.advancedchathud.util; -import com.mojang.blaze3d.platform.GlStateManager; +import com.mojang.blaze3d.opengl.GlStateManager; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; diff --git a/src/main/resources/advancedchathud.mixins.json b/src/main/resources/advancedchathud.mixins.json index afe1e8e..902c5b8 100644 --- a/src/main/resources/advancedchathud.mixins.json +++ b/src/main/resources/advancedchathud.mixins.json @@ -1,14 +1,18 @@ { "required": true, "package": "io.github.darkkronicle.advancedchathud.mixin", - "compatibilityLevel": "JAVA_16", + "compatibilityLevel": "JAVA_21", "mixins": [ ], "client": [ + "MixinInGameHud", "MixinChatHud", "MixinMinecraftClient" ], + "reject": [ + "fi.dy.masa.malilib.mixin.MixinInGameHud" + ], "injectors": { "defaultRequire": 1 } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/advancedchathud/lang/en_us.json b/src/main/resources/assets/advancedchathud/lang/en_us.json index b67a47d..595480e 100644 --- a/src/main/resources/assets/advancedchathud/lang/en_us.json +++ b/src/main/resources/assets/advancedchathud/lang/en_us.json @@ -145,6 +145,11 @@ "advancedchathud.context.copied": "§aCopied", + "advancedchathud.context.confirm": "Are you sure?", + "advancedchathud.context.cancel": "Cancel", + "advancedchathud.context.yes": "Yes", + "advancedchathud.context.no": "No", + "advancedchathud.context.copy": "Copy", "advancedchathud.context.delete": "Delete", "advancedchathud.context.minimalist": "Toggle Minimalist", @@ -152,5 +157,5 @@ "advancedchathud.context.clearallmessages": "Clear All Messages", "advancedchathud.context.duplicatewindow": "Duplicate Window", "advancedchathud.context.configurewindow": "Configure Window", - "advancedchathud.context.messageowner": "Reply" -} \ No newline at end of file + "advancedchathud.context.messageowner": "Reply to %s" +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index c366f7d..c71a232 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -24,11 +24,11 @@ "advancedchathud.mixins.json" ], "depends": { - "fabricloader": ">=0.14.18", + "fabricloader": ">=0.16.3", "fabric": "*", - "minecraft": ">=1.20", - "malilib": ">=0.16.0", - "advancedchatcore": ">=1.5.10-1.19" + "minecraft": ">=1.21.4", + "malilib": ">=0.21.0", + "advancedchatcore": ">=1.7.0" }, "custom": { "acmodule": true,