From 9702b96fbaba7f0b05def6f3f869288160080fd3 Mon Sep 17 00:00:00 2001 From: Vinrobot Date: Sun, 30 Jun 2024 01:03:10 +0200 Subject: [PATCH] Update for 1.21 --- .github/workflows/build.yml | 4 +-- build.gradle | 8 ++--- gradle.properties | 10 +++---- gradle/wrapper/gradle-wrapper.properties | 2 +- .../client/font/CustomFontStorage.java | 4 ++- .../mcemote/client/font/EmoteFontStorage.java | 2 +- .../mcemote/client/mixin/ChatHudMixin.java | 2 +- .../mcemote/client/widget/BaseScreen.java | 6 ++-- .../client/widget/ConfigurationScreen.java | 11 ++----- .../client/widget/CustomTextFieldWidget.java | 29 ------------------- src/main/resources/fabric.mod.json | 4 +-- 11 files changed, 25 insertions(+), 57 deletions(-) delete mode 100644 src/client/java/net/vinrobot/mcemote/client/widget/CustomTextFieldWidget.java diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 87f997c..626a8de 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: matrix: # Use these Java versions java: [ - 17, # Current Java LTS & minimum supported by Minecraft + 21, # Current Java LTS & minimum supported by Minecraft ] # and run on both Linux and Windows os: [ubuntu-22.04, windows-2022] @@ -35,7 +35,7 @@ jobs: - name: build run: ./gradlew build - name: capture build artifacts - if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS + if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS uses: actions/upload-artifact@v3 with: name: Artifacts diff --git a/build.gradle b/build.gradle index 3ae8411..e119426 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.2-SNAPSHOT' + id 'fabric-loom' version '1.7-SNAPSHOT' id 'maven-publish' } @@ -72,7 +72,7 @@ processResources { } tasks.withType(JavaCompile).configureEach { - it.options.release = 17 + it.options.release = 21 } java { @@ -81,8 +81,8 @@ java { // If you remove this line, sources will not be generated. withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } jar { diff --git a/gradle.properties b/gradle.properties index fd7b0c0..e53b5b2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,8 +3,8 @@ org.gradle.jvmargs=-Xmx1G org.gradle.parallel=true # Minecraft Properties -minecraft_version=1.20 -yarn_mappings=1.20+build.1 +minecraft_version=1.21 +yarn_mappings=1.21+build.7 # Mod Properties mod_version=1.1.1 @@ -13,10 +13,10 @@ archives_base_name=mcemote # Fabric Properties # check these on https://fabricmc.net/develop -fabric_loader_version=0.14.21 -fabric_api_version=0.83.0+1.20 +fabric_loader_version=0.15.11 +fabric_api_version=0.100.4+1.21 # Dependencies versions -modmenu_version=7.2.1 +modmenu_version=11.0.1 webpdecoderjn_version=1.4 httpcomponents_version=4.5.14 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 37aef8d..2617362 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/client/java/net/vinrobot/mcemote/client/font/CustomFontStorage.java b/src/client/java/net/vinrobot/mcemote/client/font/CustomFontStorage.java index 308c444..b0d9630 100644 --- a/src/client/java/net/vinrobot/mcemote/client/font/CustomFontStorage.java +++ b/src/client/java/net/vinrobot/mcemote/client/font/CustomFontStorage.java @@ -2,6 +2,7 @@ import net.minecraft.client.font.BuiltinEmptyGlyph; import net.minecraft.client.font.Font; +import net.minecraft.client.font.FontFilterType; import net.minecraft.client.font.FontStorage; import net.minecraft.client.font.Glyph; import net.minecraft.client.font.GlyphRenderer; @@ -10,6 +11,7 @@ import net.minecraft.util.Identifier; import java.util.List; +import java.util.Set; public abstract class CustomFontStorage extends FontStorage { public static final float GLYPH_HEIGHT = TextRenderer.ARABIC_SHAPING_LETTERS_SHAPE; @@ -37,7 +39,7 @@ protected TextureManager getTextureManager() { } @Override - public void setFonts(final List fonts) { + public void setFonts(List allFonts, Set activeFilters) { throw new UnsupportedOperationException(); } diff --git a/src/client/java/net/vinrobot/mcemote/client/font/EmoteFontStorage.java b/src/client/java/net/vinrobot/mcemote/client/font/EmoteFontStorage.java index 34d61a7..0af0ba3 100644 --- a/src/client/java/net/vinrobot/mcemote/client/font/EmoteFontStorage.java +++ b/src/client/java/net/vinrobot/mcemote/client/font/EmoteFontStorage.java @@ -20,7 +20,7 @@ import java.util.concurrent.TimeUnit; public class EmoteFontStorage extends CustomFontStorage { - public static final Identifier IDENTIFIER = new Identifier("mcemote.fonts", "emotes"); + public static final Identifier IDENTIFIER = Identifier.of("mcemote.fonts", "emotes"); private final EmotesManager emotesManager; private final Map> framesCache = new HashMap<>(); diff --git a/src/client/java/net/vinrobot/mcemote/client/mixin/ChatHudMixin.java b/src/client/java/net/vinrobot/mcemote/client/mixin/ChatHudMixin.java index d90c771..58cb760 100644 --- a/src/client/java/net/vinrobot/mcemote/client/mixin/ChatHudMixin.java +++ b/src/client/java/net/vinrobot/mcemote/client/mixin/ChatHudMixin.java @@ -13,7 +13,7 @@ @Mixin(ChatHud.class) @Environment(EnvType.CLIENT) public class ChatHudMixin { - @ModifyVariable(at = @At("HEAD"), method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;ILnet/minecraft/client/gui/hud/MessageIndicator;Z)V", ordinal = 0) + @ModifyVariable(at = @At("HEAD"), method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", ordinal = 0) private Text addMessage(Text message) { return EmoteParser.wrapText(message, MinecraftEmoteModClient.EMOTES_MANAGER); } diff --git a/src/client/java/net/vinrobot/mcemote/client/widget/BaseScreen.java b/src/client/java/net/vinrobot/mcemote/client/widget/BaseScreen.java index 45e8bfd..ea4591d 100644 --- a/src/client/java/net/vinrobot/mcemote/client/widget/BaseScreen.java +++ b/src/client/java/net/vinrobot/mcemote/client/widget/BaseScreen.java @@ -26,13 +26,13 @@ public void renderBackground(final DrawContext context, final int marginTop, fin // Background (Middle) context.setShaderColor(0.125F, 0.125F, 0.125F, 1.0F); - context.drawTexture(Screen.OPTIONS_BACKGROUND_TEXTURE, 0, marginTop, this.width, bottom, this.width, bottom - marginTop, 32, 32); + context.drawTexture(Screen.MENU_BACKGROUND_TEXTURE, 0, marginTop, this.width, bottom, this.width, bottom - marginTop, 32, 32); context.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); // Background (Top & Bottom), based on Screen.renderBackgroundTexture(DrawContext) context.setShaderColor(0.25F, 0.25F, 0.25F, 1.0F); - context.drawTexture(Screen.OPTIONS_BACKGROUND_TEXTURE, 0, 0, 0.0F, 0.0F, this.width, marginTop, 32, 32); - context.drawTexture(Screen.OPTIONS_BACKGROUND_TEXTURE, 0, bottom, 0.0F, bottom, this.width, this.height - bottom, 32, 32); + context.drawTexture(Screen.MENU_BACKGROUND_TEXTURE, 0, 0, 0.0F, 0.0F, this.width, marginTop, 32, 32); + context.drawTexture(Screen.MENU_BACKGROUND_TEXTURE, 0, bottom, 0.0F, bottom, this.width, this.height - bottom, 32, 32); context.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); // Gradients diff --git a/src/client/java/net/vinrobot/mcemote/client/widget/ConfigurationScreen.java b/src/client/java/net/vinrobot/mcemote/client/widget/ConfigurationScreen.java index 6973b0a..352f426 100644 --- a/src/client/java/net/vinrobot/mcemote/client/widget/ConfigurationScreen.java +++ b/src/client/java/net/vinrobot/mcemote/client/widget/ConfigurationScreen.java @@ -4,6 +4,7 @@ import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.screen.ScreenTexts; import net.minecraft.text.Text; import net.vinrobot.mcemote.config.Configuration; @@ -23,7 +24,7 @@ public class ConfigurationScreen extends BaseScreen { private final ConfigurationManager configManager; private ButtonWidget doneButton; - private CustomTextFieldWidget twitchIdField; + private TextFieldWidget twitchIdField; private SliderFieldWidget emoteScalingField; public ConfigurationScreen(final Screen parent, final ConfigurationManager configManager) { @@ -31,12 +32,6 @@ public ConfigurationScreen(final Screen parent, final ConfigurationManager confi this.configManager = configManager; } - @Override - public void tick() { - super.tick(); - this.twitchIdField.tick(); - } - @Override protected void init() { final int widgetWidth = 200; @@ -44,7 +39,7 @@ protected void init() { final int widgetX = (this.width - widgetWidth) / 2; final Configuration config = this.configManager.getConfig(); - this.twitchIdField = new CustomTextFieldWidget(this.textRenderer, widgetX, 75, widgetWidth, widgetHeight, TWITCH_ID_LABEL); + this.twitchIdField = new TextFieldWidget(this.textRenderer, widgetX, 75, widgetWidth, widgetHeight, TWITCH_ID_LABEL); this.twitchIdField.setMaxLength(32); this.twitchIdField.setText(config.twitchId().get()); this.twitchIdField.setChangedListener((value) -> this.validateInputs()); diff --git a/src/client/java/net/vinrobot/mcemote/client/widget/CustomTextFieldWidget.java b/src/client/java/net/vinrobot/mcemote/client/widget/CustomTextFieldWidget.java deleted file mode 100644 index 67bcec6..0000000 --- a/src/client/java/net/vinrobot/mcemote/client/widget/CustomTextFieldWidget.java +++ /dev/null @@ -1,29 +0,0 @@ -package net.vinrobot.mcemote.client.widget; - -import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.widget.TextFieldWidget; -import net.minecraft.text.Text; - -public class CustomTextFieldWidget extends TextFieldWidget { - private final Runnable tickMethod; - - public CustomTextFieldWidget(final TextRenderer textRenderer, final int x, final int y, final int width, final int height, final Text text) { - super(textRenderer, x, y, width, height, text); - this.tickMethod = getTickMethod(); - } - - public void tick() { - this.tickMethod.run(); - } - - private Runnable getTickMethod() { - try { - super.tick(); - return () -> super.tick(); - } catch (final NoSuchMethodError e) { - e.printStackTrace(); - return () -> { - }; - } - } -} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 8b1dd09..3fdfdb7 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -36,8 +36,8 @@ ], "depends": { "fabricloader": ">=0.14.21", - "minecraft": "~1.20", - "java": ">=17" + "minecraft": "~1.21", + "java": ">=21" }, "suggests": { "another-mod": "*"