diff --git a/build.gradle b/build.gradle index b6bf78b..cc752ba 100644 --- a/build.gradle +++ b/build.gradle @@ -1,18 +1,22 @@ plugins { - id 'fabric-loom' version "${loom_version}" + id 'net.fabricmc.fabric-loom' version "${loom_version}" id 'maven-publish' - id 'io.freefair.lombok' version '8.10' + id 'io.freefair.lombok' version '9.5.0' } java { toolchain { - languageVersion = JavaLanguageVersion.of(21) + languageVersion = JavaLanguageVersion.of(25) } } base { archivesName = project.archives_base_name } +lombok { + version = project.lombok_version +} + version = "${project.minecraft_version}-${project.mod_version}" group = project.maven_group @@ -22,7 +26,9 @@ if (file("extra.properties").exists()) { } repositories { + mavenLocal() mavenCentral() + maven { url 'https://api.modrinth.com/maven' } mavenLocal() // only used to build the mod locally maven { url 'https://masa.dy.fi/maven' } maven { url 'https://jitpack.io' } @@ -42,11 +48,10 @@ repositories { dependencies { implementation 'org.projectlombok:lombok:1.18.28' 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 files("../malilib-fabric-1.21.11-0.27.8.jar") - modImplementation files("../AdvancedChatCore-1.21.11-1.5.17-alpha.1.jar") + implementation "net.fabricmc:fabric-loader:${project.loader_version}" + implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" + implementation "maven.modrinth:malilib:${project.malilib_version}" + implementation "com.arematics:advancedchatcore:${project.advancedchat_version}" } processResources { @@ -59,7 +64,8 @@ processResources { tasks.withType(JavaCompile).configureEach { it.options.encoding = "UTF-8" - it.options.release = 21 + it.options.release = 25 + it.options.compilerArgs << "-Xmaxerrs" << "10000" } java { @@ -73,11 +79,11 @@ jar { publishing { publications { mavenJava(MavenPublication) { - artifact(remapJar) { - builtBy remapJar + artifact(jar) { + builtBy jar } artifact(sourcesJar) { - builtBy remapSourcesJar + builtBy sourcesJar } } } diff --git a/gradle.properties b/gradle.properties index 2f7790b..34cf472 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,16 +1,18 @@ org.gradle.jvmargs=-Xmx1G # https://fabricmc.net/develop -minecraft_version=1.21.11 -yarn_mappings=1.21.11+build.4 -loader_version=0.17.3 -loom_version=1.15.5 -fabric_api_version=0.136.0+1.21.11 +minecraft_version=26.2 +loader_version=0.19.3 +loom_version=1.17.+ +fabric_api_version=0.156.0+26.2 -mod_version=1.6.0 +mod_version=1.7.2-alpha.1 maven_group=com.arematics archives_base_name=AdvancedChatLog -advancedchat_version=1.21.11-1.6.0 +advancedchat_version=26.2-1.7.2-alpha.1 # https://jitpack.io/#sakura-ryoko/malilib -malilib_version=0.27.8 \ No newline at end of file +malilib_version=0.29.3 +# 1.18.42+ is required for JDK 25 +lombok_version=1.18.46 +modmenu_version=20.0.1 diff --git a/gradle/gradle-daemon-jvm.properties b/gradle/gradle-daemon-jvm.properties new file mode 100644 index 0000000..e3ced56 --- /dev/null +++ b/gradle/gradle-daemon-jvm.properties @@ -0,0 +1,3 @@ +#This file is generated by updateDaemonJvm +#Minecraft 26.2 requires the Gradle daemon itself to run on Java 25. +toolchainVersion=25 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 63e0e83..52ad5e7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index 55e39a6..6369cb4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,3 +8,8 @@ pluginManagement { mavenCentral() } } + +// Lets Gradle download a JDK 25 toolchain automatically, so no system JDK 25 is required. +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0' +} diff --git a/src/main/java/io/github/darkkronicle/advancedchatlog/AdvancedChatLog.java b/src/main/java/io/github/darkkronicle/advancedchatlog/AdvancedChatLog.java index 9bdfff7..f1f2bba 100644 --- a/src/main/java/io/github/darkkronicle/advancedchatlog/AdvancedChatLog.java +++ b/src/main/java/io/github/darkkronicle/advancedchatlog/AdvancedChatLog.java @@ -12,7 +12,7 @@ import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.text.Text; +import net.minecraft.network.chat.Component; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.LoggerContext; @@ -74,7 +74,7 @@ private static void setupLogger() { loggerContext.updateLoggers(); } - public static void logChatMessage(Text text) { + public static void logChatMessage(Component text) { if (ChatLogData.isLoading()) { return; } diff --git a/src/main/java/io/github/darkkronicle/advancedchatlog/ChatLogData.java b/src/main/java/io/github/darkkronicle/advancedchatlog/ChatLogData.java index 4b3b806..6febea6 100644 --- a/src/main/java/io/github/darkkronicle/advancedchatlog/ChatLogData.java +++ b/src/main/java/io/github/darkkronicle/advancedchatlog/ChatLogData.java @@ -23,8 +23,8 @@ import lombok.Getter; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.Screen; @Environment(EnvType.CLIENT) public class ChatLogData implements IChatMessageProcessor { @@ -45,7 +45,7 @@ private void add(ChatMessage message) { LogChatMessage log = new LogChatMessage(message); messages.add(0, log); AdvancedChatLog.logChatMessage(message.getOriginalText()); - Screen screen = MinecraftClient.getInstance().currentScreen; + Screen screen = Minecraft.getInstance().gui.screen(); if (screen instanceof ChatLogScreen) { ((ChatLogScreen) screen).add(log); } @@ -63,7 +63,7 @@ public void onMessageUpdate(ChatMessage message, UpdateType type) { if (type != UpdateType.NEW) { return; } - int width = MinecraftClient.getInstance().getWindow().getScaledWidth() - 20; + int width = Minecraft.getInstance().getWindow().getGuiScaledWidth() - 20; add(message.shallowClone(width)); while (messages.size() > ChatLogConfigStorage.General.STORED_LINES.config.getIntegerValue()) { diff --git a/src/main/java/io/github/darkkronicle/advancedchatlog/config/ChatLogConfigStorage.java b/src/main/java/io/github/darkkronicle/advancedchatlog/config/ChatLogConfigStorage.java index 7f6ae66..21c004c 100644 --- a/src/main/java/io/github/darkkronicle/advancedchatlog/config/ChatLogConfigStorage.java +++ b/src/main/java/io/github/darkkronicle/advancedchatlog/config/ChatLogConfigStorage.java @@ -18,7 +18,7 @@ import fi.dy.masa.malilib.hotkeys.KeyAction; import fi.dy.masa.malilib.hotkeys.KeybindSettings; import fi.dy.masa.malilib.util.FileUtils; -import fi.dy.masa.malilib.util.JsonUtils; +import fi.dy.masa.malilib.util.data.json.JsonUtils; import fi.dy.masa.malilib.util.StringUtils; import io.github.darkkronicle.advancedchatcore.config.ConfigStorage; import io.github.darkkronicle.advancedchatcore.config.SaveableConfig; @@ -206,16 +206,16 @@ public static void saveFromFile() { @Override public void load() { LogUtils.getLogger().info("[AdvancedChatLog] Loading..."); - long time = Util.getMeasuringTimeMs(); + long time = Util.getMillis(); loadFromFile(); - LogUtils.getLogger().info("[AdvancedChatLog] Load completed in {}ms", Util.getMeasuringTimeMs() - time); + LogUtils.getLogger().info("[AdvancedChatLog] Load completed in {}ms", Util.getMillis() - time); } @Override public void save() { LogUtils.getLogger().info("[AdvancedChatLog] Saving..."); - long time = Util.getMeasuringTimeMs(); + long time = Util.getMillis(); saveFromFile(); - LogUtils.getLogger().info("[AdvancedChatLog] Save completed in {}ms", Util.getMeasuringTimeMs() - time); + LogUtils.getLogger().info("[AdvancedChatLog] Save completed in {}ms", Util.getMillis() - time); } } diff --git a/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ChatLogScreen.java b/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ChatLogScreen.java index 3f2b8a2..ea767ad 100644 --- a/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ChatLogScreen.java +++ b/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ChatLogScreen.java @@ -33,13 +33,14 @@ import java.util.regex.PatternSyntaxException; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.Click; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.text.Style; -import net.minecraft.text.Text; -import net.minecraft.text.TextColor; -import net.minecraft.util.Formatting; +import net.minecraft.client.Minecraft; +import net.minecraft.client.input.MouseButtonEvent; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.network.chat.HoverEvent; +import net.minecraft.network.chat.Style; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextColor; +import net.minecraft.ChatFormatting; import net.minecraft.util.Util; import org.apache.logging.log4j.Level; @@ -74,14 +75,14 @@ public ChatLogScreen() { public void add(LogChatMessage message) { add(message.getMessage()); if (currentScroll > 0) { - currentScroll += message.getMessage().getLineCount() * (client.textRenderer.fontHeight + 2); + currentScroll += message.getMessage().getLineCount() * (minecraft.font.lineHeight + 2); } } public void add(ChatMessage message) { try { if (SearchUtils.isMatch( - message.getDisplayText().getString(), search.getText(), findType)) { + message.getDisplayText().getString(), search.getValue(), findType)) { for (int i = 0; i < message.getLineCount(); i++) { renderLines.add(0, message.getLines().get(i)); } @@ -95,13 +96,13 @@ public void add(ChatMessage message) { public void initGui() { super.initGui(); setLines(ChatLogData.getInstance().getMessages()); - int width = client.getWindow().getScaledWidth(); - int height = client.getWindow().getScaledHeight(); - search = new GuiTextFieldGeneric((width / 2) - 70, 6, 141, 20, textRenderer); + int width = minecraft.getWindow().getGuiScaledWidth(); + int height = minecraft.getWindow().getGuiScaledHeight(); + search = new GuiTextFieldGeneric((width / 2) - 70, 6, 141, 20, font); addTextField( search, (textField -> { - searchText(textField.getText()); + searchText(textField.getValue()); return true; }) ); @@ -115,19 +116,19 @@ public void initGui() { findType = findType.cycle(false); } button.setDisplayString(findType.getDisplayName()); - searchText(search.getText()); + searchText(search.getValue()); })); send = new TextFieldRunnable( 2, height - 15, width - 4, 12, - textRenderer, + font, (textFieldRunnable -> { - if (client.player != null) { - client.player.sendMessage(Text.of(textFieldRunnable.getText()), false); + if (minecraft.player != null) { + minecraft.player.sendSystemMessage(Component.literal(textFieldRunnable.getValue())); } - textFieldRunnable.setText(""); + textFieldRunnable.setValue(""); }) ); addTextField(send, null); @@ -135,7 +136,7 @@ public void initGui() { } @Override - public boolean onMouseClicked(Click click, boolean doubled) { + public boolean onMouseClicked(MouseButtonEvent click, boolean doubled) { if (super.onMouseClicked(click, doubled)) { return true; } @@ -146,24 +147,24 @@ public boolean onMouseClicked(Click click, boolean doubled) { if (menu != null && menu.onMouseClicked(click, doubled)) { return true; } - if (click.hasShift()) { + if (click.hasShiftDown()) { relativeScroll((int) click.y()); return true; } Style style = getHoverStyle(click.x(), click.y()); if (style != null && style.getClickEvent() != null) { - ScreenInvoker.advancedchatlog$handleClickEvent(style.getClickEvent(), client, this); + ScreenInvoker.advancedchatlog$handleClickEvent(style.getClickEvent(), minecraft, this); return true; } return false; } @Override - public boolean mouseDragged(Click click, double deltaX, double deltaY) { + public boolean mouseDragged(MouseButtonEvent click, double deltaX, double deltaY) { if (super.mouseDragged(click, deltaX, deltaY)) { return true; } - if (click.hasShift()) { + if (click.hasShiftDown()) { relativeScroll((int) click.y()); return true; } @@ -172,13 +173,13 @@ public boolean mouseDragged(Click click, double deltaX, double deltaY) { public void relativeScroll(int y) { // Scroll click - int height = client.getWindow().getScaledHeight() - 100; + int height = minecraft.getWindow().getGuiScaledHeight() - 100; y -= 40; float percent = 1 - Math.max(0, Math.min((float) y / height, 1)); - int newPix = (int) (percent * (renderLines.size() * (textRenderer.fontHeight + 2))); + int newPix = (int) (percent * (renderLines.size() * (font.lineHeight + 2))); scrollEnd = newPix; scrollStart = newPix; - lastScrollTime = Util.getMeasuringTimeMs(); + lastScrollTime = Util.getMillis(); } @@ -196,10 +197,10 @@ private void searchText(String contents) { } } catch (PatternSyntaxException e) { sorted.clear(); - Text text = Text.literal( - StringUtils.translate("advancedchatlog.message.regexerror")).fillStyle( - Style.EMPTY.withColor(TextColor.fromFormatting(Formatting.RED))); - text.getSiblings().add(Text.literal(" " + e.getDescription()).fillStyle(Style.EMPTY.withColor(Colors.getInstance().getColorOrWhite("gray").color()))); + Component text = Component.literal( + StringUtils.translate("advancedchatlog.message.regexerror")).withStyle( + Style.EMPTY.withColor(TextColor.fromLegacyFormat(ChatFormatting.RED))); + text.getSiblings().add(Component.literal(" " + e.getDescription()).withStyle(Style.EMPTY.withColor(Colors.getInstance().getColorOrWhite("gray").color()))); ChatMessage message = ChatMessage.builder().displayText(text).originalText(text).build(); sorted.add(new LogChatMessage(message)); break; @@ -212,9 +213,9 @@ private void setLines(List messages) { // Don't want jank messages = new ArrayList<>(messages); if (messages.isEmpty()) { - Text text = Text.literal( + Component text = Component.literal( StringUtils.translate("advancedchatlog.message.none") - ).fillStyle(Style.EMPTY.withColor(TextColor.fromFormatting(Formatting.RED))); + ).withStyle(Style.EMPTY.withColor(TextColor.fromLegacyFormat(ChatFormatting.RED))); messages.add(new LogChatMessage(ChatMessage.builder().displayText(text).originalText(text).build())); } renderLines = new ArrayList<>(); @@ -227,14 +228,14 @@ private void setLines(List messages) { } private void updateScroll() { - long time = Util.getMeasuringTimeMs(); + long time = Util.getMillis(); // Starting scroll + percent completed currentScroll = scrollStart + ( (scrollEnd - scrollStart) * (1 - ((ConfigStorage.Easing) ChatLogConfigStorage.General.SCROLL_TYPE.config.getOptionListValue()).apply( 1 - ((float) time - lastScrollTime) / ChatLogConfigStorage.General.SCROLL_TIME.config.getIntegerValue() )) ); - int fontHeight = (textRenderer.fontHeight + 2); + int lineHeight = (font.lineHeight + 2); if (currentScroll < 0) { // Make sure we can still see at least one line currentScroll = 0; @@ -258,18 +259,18 @@ public boolean onMouseScrolled(double mouseX, double mouseY, double horizontalAm // Update the scroll variables scrollEnd = currentScroll + verticalAmount * 10 * ChatLogConfigStorage.General.SCROLL_MULTIPLIER.config.getDoubleValue(); scrollStart = currentScroll; - lastScrollTime = Util.getMeasuringTimeMs(); + lastScrollTime = Util.getMillis(); return true; } @Override - public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) { - super.render(context, mouseX, mouseY, partialTicks); + public void extractRenderState(GuiGraphicsExtractor context, int mouseX, int mouseY, float partialTicks) { + super.extractRenderState(context, mouseX, mouseY, partialTicks); updateScroll(); - int height = client.getWindow().getScaledHeight(); - int width = client.getWindow().getScaledWidth(); - int lineHeight = textRenderer.fontHeight + 2; + int height = minecraft.getWindow().getGuiScaledHeight(); + int width = minecraft.getWindow().getGuiScaledWidth(); + int lineHeight = font.lineHeight + 2; // 60 px top, 40 px bottom int lines = (int) Math.ceil((float) (height - 70 - lineHeight) / (lineHeight)); @@ -280,7 +281,7 @@ public void render(DrawContext context, int mouseX, int mouseY, float partialTic int y = -1 * ((int) currentScroll % lineHeight); // Scissor to keep boundaries for the half scroll - double scale = client.getWindow().getScaleFactor(); + double scale = minecraft.getWindow().getGuiScale(); context.enableScissor( 0, (int) (40 * scale), (int) (width * scale), (int) ((height - 70) * scale)); @@ -289,8 +290,8 @@ public void render(DrawContext context, int mouseX, int mouseY, float partialTic break; } ChatMessage.AdvancedChatLine line = renderLines.get(i); - context.drawTextWithShadow( - textRenderer, + context.text( + font, line.getText(), 10, height - y - 40 - fontHeight, @@ -298,51 +299,66 @@ public void render(DrawContext context, int mouseX, int mouseY, float partialTic y += lineHeight; } context.disableScissor(); - context.drawCenteredTextWithShadow( - textRenderer, + context.centeredText( + font, (scrollLine + 1) + "/" + renderLines.size(), width / 2, height - 28, Colors.getInstance().getColorOrWhite("white").color() ); - context.drawHoverEvent(textRenderer, getHoverStyle(mouseX, mouseY), mouseX, mouseY); + renderHoverText(context, getHoverStyle(mouseX, mouseY), mouseX, mouseY); if (menu != null) { menu.render(GuiContext.fromGuiGraphics(context), mouseX, mouseY, true); } } + /** + * 26.2 removed GuiGraphics#renderComponentHoverEffect in favour of the text-collector + * pipeline. Only SHOW_TEXT hovers were ever meaningful here, so draw those directly + * as a tooltip instead. + */ + private void renderHoverText( + GuiGraphicsExtractor context, Style style, int mouseX, int mouseY) { + if (style == null) { + return; + } + if (style.getHoverEvent() instanceof HoverEvent.ShowText showText) { + context.setTooltipForNextFrame(font, showText.value(), mouseX, mouseY); + } + } + public void createContextMenu(int mouseX, int mouseY) { - LinkedHashMap actions = new LinkedHashMap<>(); + LinkedHashMap actions = new LinkedHashMap<>(); message = getMessage(mouseX, mouseY); if (message != null) { - Text data = Text.empty(); + Component data = Component.empty(); try { data.getSiblings().add( - Text.literal( + Component.literal( message.getMessage().getTime().format(DateTimeFormatter.ofPattern(ConfigStorage.General.TIME_FORMAT.config.getStringValue())) - ).fillStyle(Style.EMPTY.withFormatting(Formatting.AQUA)) + ).withStyle(Style.EMPTY.applyFormat(ChatFormatting.AQUA)) ); } catch (IllegalArgumentException e) { AdvancedChatLog.LOGGER.log(Level.WARN, "Can't format time for context menu!", e); } if (message.getMessage().getOwner() != null) { - data.getSiblings().add(Text.literal(" - ").fillStyle(Style.EMPTY.withFormatting(Formatting.GRAY))); - if (message.getMessage().getOwner().getEntry().getDisplayName() != null) { - data.getSiblings().add(message.getMessage().getOwner().getEntry().getDisplayName()); + data.getSiblings().add(Component.literal(" - ").withStyle(Style.EMPTY.applyFormat(ChatFormatting.GRAY))); + if (message.getMessage().getOwner().getEntry().getTabListDisplayName() != null) { + data.getSiblings().add(message.getMessage().getOwner().getEntry().getTabListDisplayName()); } else { - data.getSiblings().add(Text.literal(message.getMessage().getOwner().getEntry().getProfile().name())); + data.getSiblings().add(Component.literal(message.getMessage().getOwner().getEntry().getProfile().name())); } } if (!data.getString().isBlank()) { actions.put(data, (x, y) -> { }); } - actions.put(Text.literal(StringUtils.translate("advancedchatlog.context.copy")), (x, y) -> { - MinecraftClient.getInstance().keyboard.setClipboard(message.getMessage().getOriginalText().getString()); + actions.put(Component.literal(StringUtils.translate("advancedchatlog.context.copy")), (x, y) -> { + Minecraft.getInstance().keyboardHandler.setClipboard(message.getMessage().getOriginalText().getString()); InfoUtils.printActionbarMessage("advancedchatlog.context.copied"); }); } - actions.put(Text.literal(StringUtils.translate("advancedchatlog.context.clearallmessages")), (x, y) -> { + actions.put(Component.literal(StringUtils.translate("advancedchatlog.context.clearallmessages")), (x, y) -> { ChatLogData.getInstance().clear(); setLines(ChatLogData.getInstance().getMessages()); }); @@ -350,7 +366,7 @@ public void createContextMenu(int mouseX, int mouseY) { } public Style getHoverStyle(double mouseX, double mouseY) { - int lineHeight = textRenderer.fontHeight + 2; + int lineHeight = font.lineHeight + 2; int lines = (int) Math.ceil((float) (height - 70 - lineHeight) / (lineHeight)); // Current line scrolled @@ -358,7 +374,7 @@ public Style getHoverStyle(double mouseX, double mouseY) { // Offset y for scrolling. Used for partially obstructed lines. int y = -1 * ((int) currentScroll % lineHeight); - int height = client.getWindow().getScaledHeight(); + int height = minecraft.getWindow().getGuiScaledHeight(); // Change the perspective of mouseY from where the text started. mouseY = height - mouseY - 40; mouseX = mouseX - 10; @@ -376,7 +392,7 @@ public Style getHoverStyle(double mouseX, double mouseY) { return null; } - private Style getStyleAt(Text text, int x) { + private Style getStyleAt(Component text, int x) { final float[] width = {0}; final Style[] found = {null}; text.visit( @@ -384,7 +400,7 @@ private Style getStyleAt(Text text, int x) { int[] codePoints = string.codePoints().toArray(); for (int codePoint : codePoints) { float glyphWidth = - this.client.textRenderer.getWidth( + this.minecraft.font.width( String.valueOf(Character.toChars(codePoint))); if (x < width[0] + glyphWidth) { found[0] = style; @@ -398,7 +414,7 @@ private Style getStyleAt(Text text, int x) { return found[0]; } public LogChatMessage getMessage(double mouseX, double mouseY) { - int lineHeight = textRenderer.fontHeight + 2; + int lineHeight = font.lineHeight + 2; int lines = (int) Math.ceil((float) (height - 70 - lineHeight) / (lineHeight)); // Current line scrolled @@ -406,7 +422,7 @@ public LogChatMessage getMessage(double mouseX, double mouseY) { // Offset y for scrolling. Used for partially obstructed lines. int y = -1 * ((int) currentScroll % lineHeight); - int height = client.getWindow().getScaledHeight(); + int height = minecraft.getWindow().getGuiScaledHeight(); // Change the perspective of mouseY from where the text started. mouseY = height - mouseY - 40; diff --git a/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ChatLogScreenSection.java b/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ChatLogScreenSection.java index 525a527..c5d6850 100644 --- a/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ChatLogScreenSection.java +++ b/src/main/java/io/github/darkkronicle/advancedchatlog/gui/ChatLogScreenSection.java @@ -18,14 +18,14 @@ import io.github.darkkronicle.advancedchatlog.AdvancedChatLog; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.util.Identifier; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphicsExtractor; +import net.minecraft.resources.Identifier; @Environment(EnvType.CLIENT) public class ChatLogScreenSection extends AdvancedChatScreenSection { - private final static Identifier LOG_ICON = Identifier.of(AdvancedChatLog.MOD_ID, "textures/gui/log.png"); + private final static Identifier LOG_ICON = Identifier.fromNamespaceAndPath(AdvancedChatLog.MOD_ID, "textures/gui/log.png"); public ChatLogScreenSection(AdvancedChatScreen screen) { super(screen); @@ -42,7 +42,7 @@ public void initGui() { } @Override - public void render(DrawContext context, int mouseX, int mouseY, float delta) { + public void extractRenderState(GuiGraphicsExtractor context, int mouseX, int mouseY, float delta) { } } diff --git a/src/main/java/io/github/darkkronicle/advancedchatlog/gui/TextFieldRunnable.java b/src/main/java/io/github/darkkronicle/advancedchatlog/gui/TextFieldRunnable.java index 3f2b63d..ba0fb9b 100644 --- a/src/main/java/io/github/darkkronicle/advancedchatlog/gui/TextFieldRunnable.java +++ b/src/main/java/io/github/darkkronicle/advancedchatlog/gui/TextFieldRunnable.java @@ -9,8 +9,8 @@ import fi.dy.masa.malilib.gui.GuiTextFieldGeneric; import java.util.function.Consumer; -import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.input.KeyInput; +import net.minecraft.client.gui.Font; +import net.minecraft.client.input.KeyEvent; import org.lwjgl.glfw.GLFW; public class TextFieldRunnable extends GuiTextFieldGeneric { @@ -22,14 +22,14 @@ public TextFieldRunnable( int y, int width, int height, - TextRenderer textRenderer, + Font textRenderer, Consumer onApply) { super(x, y, width, height, textRenderer); this.onApply = onApply; } @Override - public boolean keyPressed(KeyInput input) { + public boolean keyPressed(KeyEvent input) { if (super.keyPressed(input)) { return true; } diff --git a/src/main/java/io/github/darkkronicle/advancedchatlog/mixin/ScreenInvoker.java b/src/main/java/io/github/darkkronicle/advancedchatlog/mixin/ScreenInvoker.java index 1a58caa..7c077c4 100644 --- a/src/main/java/io/github/darkkronicle/advancedchatlog/mixin/ScreenInvoker.java +++ b/src/main/java/io/github/darkkronicle/advancedchatlog/mixin/ScreenInvoker.java @@ -1,17 +1,17 @@ package io.github.darkkronicle.advancedchatlog.mixin; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.text.ClickEvent; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.network.chat.ClickEvent; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(Screen.class) public interface ScreenInvoker { - @Invoker("handleClickEvent") + @Invoker("defaultHandleClickEvent") static void advancedchatlog$handleClickEvent( - ClickEvent clickEvent, MinecraftClient client, Screen screen) { + ClickEvent clickEvent, Minecraft client, Screen screen) { throw new AssertionError(); } } \ No newline at end of file diff --git a/src/main/java/io/github/darkkronicle/advancedchatlog/util/LogChatMessageSerializer.java b/src/main/java/io/github/darkkronicle/advancedchatlog/util/LogChatMessageSerializer.java index 6f2037d..c657508 100644 --- a/src/main/java/io/github/darkkronicle/advancedchatlog/util/LogChatMessageSerializer.java +++ b/src/main/java/io/github/darkkronicle/advancedchatlog/util/LogChatMessageSerializer.java @@ -21,10 +21,10 @@ import java.time.format.DateTimeFormatter; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.registry.DynamicRegistryManager; -import net.minecraft.text.Style; -import net.minecraft.text.Text; -import net.minecraft.text.TextCodecs; +import net.minecraft.core.RegistryAccess; +import net.minecraft.network.chat.Style; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.ComponentSerialization; import net.minecraft.util.StrictJsonParser; @Environment(EnvType.CLIENT) @@ -43,11 +43,11 @@ private Style cleanStyle(Style style) { return style; } - private Text transfer(Text text) { + private Component transfer(Component text) { // Using the built in serializer LiteralText is required - Text base = Text.empty(); - for (Text t : text.getSiblings()) { - Text newT = Text.literal(t.getString()).fillStyle(cleanStyle(t.getStyle())); + Component base = Component.empty(); + for (Component t : text.getSiblings()) { + Component newT = Component.literal(t.getString()).withStyle(cleanStyle(t.getStyle())); base.getSiblings().add(newT); } return base; @@ -60,11 +60,11 @@ private Style forceCleanStyle(Style style) { return style; } - private Text forceTransfer(Text text) { + private Component forceTransfer(Component text) { // Using the built in serializer LiteralText is required - Text base = Text.empty(); - for (Text t : text.getSiblings()) { - Text newT = Text.literal(t.getString()).fillStyle(forceCleanStyle(t.getStyle())); + Component base = Component.empty(); + for (Component t : text.getSiblings()) { + Component newT = Component.literal(t.getString()).withStyle(forceCleanStyle(t.getStyle())); base.getSiblings().add(newT); } return base; @@ -75,11 +75,11 @@ public LogChatMessage load(JsonObject obj) { LocalDateTime dateTime = LocalDateTime.from(formatter.parse(obj.get("time").getAsString())); LocalDate date = dateTime.toLocalDate(); LocalTime time = dateTime.toLocalTime(); - Text display = TextCodecs.CODEC.parse( - DynamicRegistryManager.EMPTY.getOps(JsonOps.INSTANCE), + Component display = ComponentSerialization.CODEC.parse( + RegistryAccess.EMPTY.createSerializationContext(JsonOps.INSTANCE), obj.get("display")).resultOrPartial((string2) -> {}).orElse(null); - Text original = TextCodecs.CODEC.parse( - DynamicRegistryManager.EMPTY.getOps(JsonOps.INSTANCE), + Component original = ComponentSerialization.CODEC.parse( + RegistryAccess.EMPTY.createSerializationContext(JsonOps.INSTANCE), obj.get("original")).resultOrPartial((string2) -> {}).orElse(null); int stacks = obj.get("stacks").getAsByte(); ChatMessage message = @@ -99,11 +99,11 @@ public JsonObject save(LogChatMessage message) { try { json.addProperty("time", formatter.format(dateTime)); json.addProperty("stacks", chat.getStacks()); - json.add("display", TextCodecs.CODEC.encodeStart( - DynamicRegistryManager.EMPTY.getOps(JsonOps.INSTANCE), + json.add("display", ComponentSerialization.CODEC.encodeStart( + RegistryAccess.EMPTY.createSerializationContext(JsonOps.INSTANCE), transfer(chat.getDisplayText())).getOrThrow()); - json.add("original", TextCodecs.CODEC.encodeStart( - DynamicRegistryManager.EMPTY.getOps(JsonOps.INSTANCE), + json.add("original", ComponentSerialization.CODEC.encodeStart( + RegistryAccess.EMPTY.createSerializationContext(JsonOps.INSTANCE), transfer(chat.getOriginalText())).getOrThrow()); } catch (JsonParseException e) { try { @@ -114,11 +114,11 @@ public JsonObject save(LogChatMessage message) { json = new JsonObject(); json.addProperty("time", formatter.format(dateTime)); json.addProperty("stacks", chat.getStacks()); - json.add("display", TextCodecs.CODEC.encodeStart( - DynamicRegistryManager.EMPTY.getOps(JsonOps.INSTANCE), + json.add("display", ComponentSerialization.CODEC.encodeStart( + RegistryAccess.EMPTY.createSerializationContext(JsonOps.INSTANCE), forceTransfer(chat.getDisplayText())).getOrThrow()); - json.add("original", TextCodecs.CODEC.encodeStart( - DynamicRegistryManager.EMPTY.getOps(JsonOps.INSTANCE), + json.add("original", ComponentSerialization.CODEC.encodeStart( + RegistryAccess.EMPTY.createSerializationContext(JsonOps.INSTANCE), forceTransfer(chat.getOriginalText())).getOrThrow()); } catch (Exception e2) { AdvancedChatLog.LOGGER.warn("[AdvancedChatLog] Save Error 2", e2); diff --git a/src/main/resources/advancedchatlog.mixins.json b/src/main/resources/advancedchatlog.mixins.json index e85fc82..fbc0a68 100644 --- a/src/main/resources/advancedchatlog.mixins.json +++ b/src/main/resources/advancedchatlog.mixins.json @@ -1,7 +1,7 @@ { "required": true, "package": "io.github.darkkronicle.advancedchatlog.mixin", - "compatibilityLevel": "JAVA_21", + "compatibilityLevel": "JAVA_25", "mixins": [], "client": [ "ScreenInvoker" diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 740eb12..70f7abb 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -25,11 +25,11 @@ "advancedchatlog.mixins.json" ], "depends": { - "fabricloader": ">=0.15.11", - "fabric": "*", - "minecraft": "1.21.11", - "malilib": ">=0.27.8", - "advancedchatcore": ">=1.21.11-1.5.17-alpha.1" + "fabricloader": ">=0.19.3", + "fabric-api": "*", + "minecraft": ">=26.2", + "malilib": ">=0.29.0", + "advancedchatcore": ">=1.7.0" }, "custom": { "acmodule": true,