diff --git a/.github/workflows/build-pull-request.yml b/.github/workflows/build-pull-request.yml index 4d8f56cf..081469bd 100644 --- a/.github/workflows/build-pull-request.yml +++ b/.github/workflows/build-pull-request.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/setup-java@v4 with: distribution: temurin - java-version: 21 + java-version: 25 - name: Set up Gradle uses: gradle/actions/setup-gradle@v4 diff --git a/build.gradle b/build.gradle index 8335a83d..0e0c3bc5 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version "${fabric_loom_version}" apply false + id 'net.fabricmc.fabric-loom' version "${fabric_loom_version}" apply false id 'net.neoforged.moddev' version "${neoforge_moddev_version}" apply false id 'com.modrinth.minotaur' version "${minotaur_plugin_version}" apply false id 'net.darkhax.curseforgegradle' version "${curseforgegradle_plugin_version}" apply false @@ -417,4 +417,3 @@ tasks.register('release') { println "" } } - diff --git a/common/build.gradle b/common/build.gradle index c9032477..87154a01 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' + id 'net.fabricmc.fabric-loom' } repositories { @@ -11,7 +11,6 @@ repositories { dependencies { minecraft "com.mojang:minecraft:${minecraft_version}" - mappings loom.officialMojangMappings() compileOnly "org.spongepowered:mixin:${spongepowered_version}" annotationProcessor "org.spongepowered:mixin:${spongepowered_version}:processor" diff --git a/common/src/main/java/net/pcal/fastback/common/mixins/FileFixerUpperMixin.java b/common/src/main/java/net/pcal/fastback/common/mixins/FileFixerUpperMixin.java new file mode 100644 index 00000000..ee967ae7 --- /dev/null +++ b/common/src/main/java/net/pcal/fastback/common/mixins/FileFixerUpperMixin.java @@ -0,0 +1,60 @@ +/* + * FastBack - Fast, incremental Minecraft backups powered by Git. + * Copyright (C) 2022 pcal.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; If not, see . + */ +package net.pcal.fastback.common.mixins; + +import net.minecraft.util.filefix.FileFixerUpper; +import net.minecraft.util.filefix.virtualfilesystem.CopyOnWriteFileSystem; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.PathMatcher; + +/** + * Prevents MC 26.1+'s CopyOnWriteFileSystem (used during world upgrade) from choking + * on read-only git object files inside the .git directory. + * + * @author pcal + * @since 0.31.2 + */ +@Mixin(FileFixerUpper.class) +public class FileFixerUpperMixin { + + @Redirect( + method = "applyFileFixersOnCow", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/util/filefix/virtualfilesystem/CopyOnWriteFileSystem;create(Ljava/lang/String;Ljava/nio/file/Path;Ljava/nio/file/Path;Ljava/nio/file/PathMatcher;)Lnet/minecraft/util/filefix/virtualfilesystem/CopyOnWriteFileSystem;", + remap = false + ), + remap = false + ) + private CopyOnWriteFileSystem fastback_skipGitDir( + String name, Path baseDir, Path tmpDir, PathMatcher original) throws IOException { + PathMatcher withGitSkip = path -> { + for (Path component : path) { + if (".git".equals(component.toString())) return true; + } + return original.matches(path); + }; + return CopyOnWriteFileSystem.create(name, baseDir, tmpDir, withGitSkip); + } +} + diff --git a/common/src/main/java/net/pcal/fastback/common/mixins/MessageScreenMixin.java b/common/src/main/java/net/pcal/fastback/common/mixins/MessageScreenMixin.java index 92636ae4..72f84b92 100644 --- a/common/src/main/java/net/pcal/fastback/common/mixins/MessageScreenMixin.java +++ b/common/src/main/java/net/pcal/fastback/common/mixins/MessageScreenMixin.java @@ -17,7 +17,7 @@ */ package net.pcal.fastback.common.mixins; -import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.client.gui.screens.GenericMessageScreen; import net.pcal.fastback.common.mod.Mod; import org.spongepowered.asm.mixin.Mixin; @@ -34,8 +34,8 @@ @Mixin(GenericMessageScreen.class) public class MessageScreenMixin { - @Inject(method = "renderBackground", at = @At("TAIL"), remap = false) - public void fastback_render(GuiGraphics context, int mouseX, int mouseY, float delta, CallbackInfo ci) { + @Inject(method = "extractBackground", at = @At("TAIL"), remap = false) + public void fastback_render(GuiGraphicsExtractor context, int mouseX, int mouseY, float delta, CallbackInfo ci) { Mod.mod().renderMessageScreen(context); } } diff --git a/common/src/main/java/net/pcal/fastback/common/mod/ClientHelper.java b/common/src/main/java/net/pcal/fastback/common/mod/ClientHelper.java index b79c7ab5..3780a355 100644 --- a/common/src/main/java/net/pcal/fastback/common/mod/ClientHelper.java +++ b/common/src/main/java/net/pcal/fastback/common/mod/ClientHelper.java @@ -19,7 +19,7 @@ package net.pcal.fastback.common.mod; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.client.gui.screens.GenericMessageScreen; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; @@ -82,11 +82,11 @@ public void setMessageScreenText(UserMessage userMessage) { } } - public void renderMessageScreen(GuiGraphics guiGraphics) { + public void renderMessageScreen(GuiGraphicsExtractor guiGraphics) { renderHud(guiGraphics); } - public void renderHud(GuiGraphics guiGraphics) { + public void renderHud(GuiGraphicsExtractor guiGraphics) { if (this.client == null) return; if (this.hudText == null) return; if (!this.client.options.showAutosaveIndicator().get()) return; @@ -95,6 +95,6 @@ public void renderHud(GuiGraphics guiGraphics) { syslog().debug("hud text timed out. somebody forgot to clean up"); return; } - guiGraphics.drawString(this.client.font, this.hudText, 2, 2, 0xFFFFFFFF); + guiGraphics.text(this.client.font, this.hudText, 2, 2, 0xFFFFFF, false); } } diff --git a/common/src/main/java/net/pcal/fastback/common/mod/Mod.java b/common/src/main/java/net/pcal/fastback/common/mod/Mod.java index 617d1453..1d12b904 100644 --- a/common/src/main/java/net/pcal/fastback/common/mod/Mod.java +++ b/common/src/main/java/net/pcal/fastback/common/mod/Mod.java @@ -18,7 +18,7 @@ package net.pcal.fastback.common.mod; -import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.commands.CommandSourceStack; import net.minecraft.server.MinecraftServer; import net.pcal.fastback.common.logging.UserMessage; @@ -87,7 +87,7 @@ static void initializeForClient(LoaderHelper loaderHelper, ClientHelper clientHe /** * Allows loaders to plugin HUD rendering. */ - void renderHud(GuiGraphics drawContext); + void renderHud(GuiGraphicsExtractor drawContext); // ====================================================================== // Mixin-facing methods @@ -108,7 +108,7 @@ static void initializeForClient(LoaderHelper loaderHelper, ClientHelper clientHe /** * Called from the shutdown message screen mixins to render additional text. */ - void renderMessageScreen(GuiGraphics drawContext); + void renderMessageScreen(GuiGraphicsExtractor drawContext); // ====================================================================== diff --git a/common/src/main/java/net/pcal/fastback/common/mod/ModImpl.java b/common/src/main/java/net/pcal/fastback/common/mod/ModImpl.java index 46a38e83..e71d3e83 100644 --- a/common/src/main/java/net/pcal/fastback/common/mod/ModImpl.java +++ b/common/src/main/java/net/pcal/fastback/common/mod/ModImpl.java @@ -17,7 +17,7 @@ */ package net.pcal.fastback.common.mod; -import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.commands.CommandSourceStack; import net.minecraft.server.MinecraftServer; import net.minecraft.world.level.storage.LevelStorageSource; @@ -239,7 +239,7 @@ public void autoSaveCompleted() { } @Override - public void renderMessageScreen(GuiGraphics drawContext) { + public void renderMessageScreen(GuiGraphicsExtractor drawContext) { if (this.clientHelper != null) { this.clientHelper.renderMessageScreen(drawContext); } else { @@ -248,7 +248,7 @@ public void renderMessageScreen(GuiGraphics drawContext) { } @Override - public void renderHud(GuiGraphics drawContext) { + public void renderHud(GuiGraphicsExtractor drawContext) { if (this.clientHelper != null) { this.clientHelper.renderHud(drawContext); } else { diff --git a/common/src/main/java/net/pcal/fastback/common/mod/UserMessageUtil.java b/common/src/main/java/net/pcal/fastback/common/mod/UserMessageUtil.java index cd6d3c68..65269992 100644 --- a/common/src/main/java/net/pcal/fastback/common/mod/UserMessageUtil.java +++ b/common/src/main/java/net/pcal/fastback/common/mod/UserMessageUtil.java @@ -40,7 +40,10 @@ public class UserMessageUtil { public static Component messageToText(final UserMessage m) { final MutableComponent out; if (m.localized() != null) { - out = Component.translatable(m.localized().key(), m.localized().params()); + out = Component.translatable( + m.localized().key(), + messageParamsToComponentArgs(m.localized().params()) + ); } else { out = Component.literal(m.raw()); } @@ -53,6 +56,20 @@ public static Component messageToText(final UserMessage m) { return out; } + private static Object[] messageParamsToComponentArgs(final Object[] params) { + if (params == null) return new Object[0]; + + final Object[] out = new Object[params.length]; + for (int i = 0; i < params.length; i++) { + final Object param = params[i]; + if (param instanceof Component) { + out[i] = param; + } else { + out[i] = String.valueOf(param); + } + } + return out; + } + private UserMessageUtil() {} } - diff --git a/common/src/main/resources/fastback.mixins.json b/common/src/main/resources/fastback.mixins.json index 882b6d41..4df19db4 100644 --- a/common/src/main/resources/fastback.mixins.json +++ b/common/src/main/resources/fastback.mixins.json @@ -2,8 +2,9 @@ "required": true, "minVersion": "0.8", "package": "net.pcal.fastback.common.mixins", - "compatibilityLevel": "JAVA_16", + "compatibilityLevel": "JAVA_25", "mixins": [ + "FileFixerUpperMixin", "MinecraftServerMixin", "ServerAccessors", "SessionAccessors" diff --git a/fabric/build.gradle b/fabric/build.gradle index 07eb27f1..7c49c956 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' + id 'net.fabricmc.fabric-loom' id 'com.modrinth.minotaur' id 'net.darkhax.curseforgegradle' } @@ -17,33 +17,32 @@ repositories { dependencies { minecraft "com.mojang:minecraft:${minecraft_version}" - mappings loom.officialMojangMappings() - modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}" - modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}" + implementation "net.fabricmc:fabric-loader:${fabric_loader_version}" + implementation "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}" - modImplementation("me.lucko:fabric-permissions-api:${fabric_permissions_version}") { transitive = false } + implementation("me.lucko:fabric-permissions-api:${fabric_permissions_version}") { transitive = false } include("me.lucko:fabric-permissions-api:${fabric_permissions_version}") { transitive = false } - modImplementation("xyz.nucleoid:server-translations-api:${server_translations_version}") + implementation("xyz.nucleoid:server-translations-api:${server_translations_version}") include("xyz.nucleoid:server-translations-api:${server_translations_version}") // jgit and dependencies - modImplementation("org.eclipse.jgit:org.eclipse.jgit:${jgit_version}") { transitive = false } + implementation("org.eclipse.jgit:org.eclipse.jgit:${jgit_version}") { transitive = false } include("org.eclipse.jgit:org.eclipse.jgit:${jgit_version}") { transitive = false } - modImplementation("com.googlecode.javaewah:JavaEWAH:${JavaEWAH_version}") { transitive = false } + implementation("com.googlecode.javaewah:JavaEWAH:${JavaEWAH_version}") { transitive = false } include("com.googlecode.javaewah:JavaEWAH:${JavaEWAH_version}") { transitive = false } - modImplementation("org.eclipse.jgit:org.eclipse.jgit.ssh.apache:${jgit_version}") { transitive = false } + implementation("org.eclipse.jgit:org.eclipse.jgit.ssh.apache:${jgit_version}") { transitive = false } include("org.eclipse.jgit:org.eclipse.jgit.ssh.apache:${jgit_version}") { transitive = false } - modImplementation("org.apache.sshd:sshd-core:${apache_sshd_version}") { transitive = false } + implementation("org.apache.sshd:sshd-core:${apache_sshd_version}") { transitive = false } include("org.apache.sshd:sshd-core:${apache_sshd_version}") { transitive = false } - modImplementation("org.apache.sshd:sshd-common:${apache_sshd_version}") { transitive = false } + implementation("org.apache.sshd:sshd-common:${apache_sshd_version}") { transitive = false } include("org.apache.sshd:sshd-common:${apache_sshd_version}") { transitive = false } - modImplementation("net.i2p.crypto:eddsa:${eddsa_version}") { transitive = false } + implementation("net.i2p.crypto:eddsa:${eddsa_version}") { transitive = false } include("net.i2p.crypto:eddsa:${eddsa_version}") { transitive = false } compileOnly project(':common') @@ -84,9 +83,6 @@ loom { runDir("run") } } - mixin { - defaultRefmapName = "fastback-refmap.json" - } mods { "fastback" { sourceSet sourceSets.main @@ -107,7 +103,7 @@ modrinth { versionNumber = mod_version versionName = "${mod_version} (fabric)" versionType = "release" - uploadFile = remapJar + uploadFile = jar changelog = "

${github_projectUrl}/releases/tag/${mod_version}

" gameVersions = [minecraft_version] loaders = ["fabric"] @@ -120,11 +116,11 @@ import net.darkhax.curseforgegradle.TaskPublishCurseForge tasks.register('publishCurseForge', TaskPublishCurseForge) { apiToken = System.getenv("CURSEFORGE_TOKEN") ?: 'CURSEFORGE_TOKEN NOT_SET' - def mainFile = upload(curseforge_projectId, remapJar) + def mainFile = upload(curseforge_projectId, jar) mainFile.releaseType = "release" mainFile.changelog = "${github_projectUrl}/releases/tag/${mod_version}" mainFile.changelogType = "markdown" mainFile.addGameVersion(minecraft_version) mainFile.addModLoader("Fabric") - dependsOn(remapJar) + dependsOn(jar) } diff --git a/fabric/src/main/java/net/pcal/fastback/fabric/FabricClientInitializer.java b/fabric/src/main/java/net/pcal/fastback/fabric/FabricClientInitializer.java index d11bd29f..e0983350 100644 --- a/fabric/src/main/java/net/pcal/fastback/fabric/FabricClientInitializer.java +++ b/fabric/src/main/java/net/pcal/fastback/fabric/FabricClientInitializer.java @@ -20,8 +20,9 @@ import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; -import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; +import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; +import net.minecraft.resources.Identifier; import net.pcal.fastback.common.mod.ClientHelper; import net.pcal.fastback.common.mod.Mod; @@ -33,14 +34,17 @@ */ public class FabricClientInitializer implements ClientModInitializer { + private static final String MOD_ID = "fastback"; + @Override public void onInitializeClient() { ClientLifecycleEvents.CLIENT_STARTED.register( minecraftClient -> { Mod.initializeForClient(new FabricLoaderHelper(), new ClientHelper(minecraftClient)); - HudRenderCallback.EVENT.register((guiGraphics,deltaTracker)->{ - Mod.mod().renderHud(guiGraphics); - }); + HudElementRegistry.addLast( + Identifier.fromNamespaceAndPath(MOD_ID, "hud"), + (guiGraphics, deltaTracker) -> Mod.mod().renderHud(guiGraphics) + ); } ); ServerLifecycleEvents.SERVER_STARTING.register( diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 3ffe3e6d..366d41b9 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -26,9 +26,10 @@ ], "depends": { "fabricloader": ">=${fabric_loader_version}", - "minecraft": ">=${minecraft_version}", - "java": ">=${java_version}" + "fabric-api": "*", + "fabric-permissions-api-v0": "*", + "minecraft": "26.1.x", + "java": ">=25" }, "conflicts": {} } - diff --git a/gradle.properties b/gradle.properties index b4c1d763..acf0f09b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ # # Mod # -mod_version = 0.31.2+1.21.11-prerelease +mod_version = 0.32.0+26.1.1-prerelease archives_base_name = fastback github_projectUrl = https://github.com/pcal43/fastback modrinth_projectId = ZHKrK8Rp @@ -10,21 +10,21 @@ curseforge_projectId = 667417 # # Minecraft # -minecraft_version=1.21.11 -java_version = 21 +minecraft_version=26.1.1 +java_version = 25 # # Fabric - https://fabricmc.net/develop # -fabric_loader_version=0.19.2 +fabric_loader_version=0.19.1 fabric_loom_version=1.16-SNAPSHOT -fabric_api_version=0.141.3+1.21.11 +fabric_api_version=0.145.4+26.1.1 # # NeoForge - https://neoforged.net/ # -neoforge_version = 21.11.42 -neoforge_moddev_version = 2.0.116 +neoforge_version = 26.1.1.15-beta +neoforge_moddev_version = 2.0.140 # # Dependencies @@ -37,7 +37,7 @@ curseforgegradle_plugin_version = 1.1.25 minotaur_plugin_version = 2.9.0 # https://mvnrepository.com/artifact/org.spongepowered/mixin -spongepowered_version = 0.8.7 +spongepowered_version = 0.8.5 # https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter/versions junit_version = 5.14.4 @@ -56,11 +56,11 @@ JavaEWAH_version = 1.2.3 eddsa_version = 0.3.0 # https://github.com/lucko/fabric-permissions-api/releases -fabric_permissions_version = 0.6.1 +fabric_permissions_version = 0.7.0 # https://github.com/NucleoidMC/Server-Translations/releases # https://maven.nucleoid.xyz/xyz/nucleoid/server-translations-api/ -server_translations_version = 2.5.2+1.21.9-pre3 +server_translations_version = 3.0.3+26.1 # # Build settings diff --git a/neoforge/src/main/java/net/pcal/fastback/neoforge/NeoForgeClientInitializer.java b/neoforge/src/main/java/net/pcal/fastback/neoforge/NeoForgeClientInitializer.java index 1099598a..409f80fe 100644 --- a/neoforge/src/main/java/net/pcal/fastback/neoforge/NeoForgeClientInitializer.java +++ b/neoforge/src/main/java/net/pcal/fastback/neoforge/NeoForgeClientInitializer.java @@ -55,4 +55,3 @@ static void init(IEventBus modEventBus) { mod().onWorldStop()); } } -