From 71d0fbcf21bad9434b14852ab24f4839ecfadef8 Mon Sep 17 00:00:00 2001 From: Stewart Borle Date: Wed, 20 Nov 2024 17:38:52 +0800 Subject: [PATCH] Reconfigure for NeoForge This configures the neoforge build, but does not address critical bugs that prevent the neoforge build from functioning. --- Makefile | 7 ++++- README.md | 2 +- build.gradle | 1 + common/build.gradle | 1 + etc/release.sh | 4 ++- gradle.properties | 5 ++++ neoforge/build.gradle | 16 +++++----- neoforge/gradle.properties | 2 +- .../mod/neoforge/ForgeClientProvider.java | 25 ++++++++-------- .../mod/neoforge/ForgeCommonProvider.java | 30 +++++++++---------- .../mod/neoforge/ForgeInitializer.java | 8 ++--- .../mod/neoforge/Slf4jSystemLogger.java | 2 +- .../pcal/fastback/mod/neoforge/SshHacks.java | 2 +- .../{mods.toml => neoforge.mods.toml} | 10 +++---- settings.gradle | 9 +++--- 15 files changed, 69 insertions(+), 55 deletions(-) rename neoforge/src/main/resources/META-INF/{mods.toml => neoforge.mods.toml} (77%) diff --git a/Makefile b/Makefile index 01f94485..801c16e3 100644 --- a/Makefile +++ b/Makefile @@ -2,13 +2,14 @@ .PHONY: clean clean: - rm -rf build common/build fabric/build forge/build + rm -rf build common/build fabric/build neoforge/build #forge/build .PHONY: jar jar: ./gradlew remapJar ls -1 fabric/build/libs + ls -1 neoforge/build/libs # ls -1 forge/build/libs test: @@ -39,14 +40,18 @@ deps: .PHONY: inst inst: # rm -f ~/minecraft/instances/1.20.1-forge-dev/.minecraft/mods/fastback* + rm -f ~/minecraft/instances/1.20.1-neoforge-dev/.minecraft/mods/fastback* rm -f ~/minecraft/instances/1.20.1-fabric-dev/.minecraft/mods/fasback* cp fabric/build/libs/fastback*-fabric.jar ~/minecraft/instances/1.20.1-fabric-dev/.minecraft/mods/ + cp neoforge/build/libs/fastback*-neoforge.jar ~/minecraft/instances/1.20.1-neoforge-dev/.minecraft/mods/ # cp forge/build/libs/fastback*-forge.jar ~/minecraft/instances/1.20.1-forge-dev/.minecraft/mods/ .PHONY: tvf tvf: + jar -tvf neoforge/build/libs/fastback*-neoforge.jar # jar -tvf forge/build/libs/fastback*-forge.jar .PHONY: tvfs tvfs: + jar -tvf neoforge/build/libs/fastback*-shadow.jar # jar -tvf forge/build/libs/fastback*-shadow.jar diff --git a/README.md b/README.md index c2f1a73d..45ba2934 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ of disk space. ## Features +* **Now with NeoForge support!** * Incrementally backup just the changed files * Faster, smaller backups than zipping * Back up locally @@ -31,7 +32,6 @@ of disk space. * Support for restoring remote snapshots * Better management of remote snapshots * UI for managing backups from the title screen -* ~~Forge support (maybe)~~ ## Acknowledgements diff --git a/build.gradle b/build.gradle index b992b1fd..ec7ac4b1 100644 --- a/build.gradle +++ b/build.gradle @@ -19,6 +19,7 @@ subprojects { maven { url 'https://maven.fabricmc.net/' } maven { url 'https://maven.nucleoid.xyz' } maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } + maven { url 'https://maven.neoforged.net/releases/' } } java { diff --git a/common/build.gradle b/common/build.gradle index 79f8757a..637840e5 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,6 +1,7 @@ architectury { common("fabric") + common("neoforge") // NOTE: Forge is no longer supported and the build has been disabled // See: https://github.com/pcal43/fastback/issues/333 //common("forge") diff --git a/etc/release.sh b/etc/release.sh index a66e8781..01efb8b8 100755 --- a/etc/release.sh +++ b/etc/release.sh @@ -50,6 +50,7 @@ fi # FABRIC_LIBS_DIR='fabric/build/libs' +NEOFORGE_LIBS_DIR='neoforge/build/libs' # NOTE: Forge is no longer supported and the build has been disabled # See: https://github.com/pcal43/fastback/issues/333 @@ -69,6 +70,7 @@ rm gradle.properties mv gradle.properties.temp gradle.properties rm -rf "${FABRIC_LIBS_DIR}" +rm -rf "${NEOFORGE_LIBS_DIR}" # NOTE: Forge is no longer supported and the build has been disabled # See: https://github.com/pcal43/fastback/issues/333 @@ -84,7 +86,7 @@ git push # Do github release # set -x -gh release create --generate-notes --title "${RELEASE_VERSION}" --notes "release ${RELEASE_VERSION}" ${RELEASE_VERSION} "${FABRIC_LIBS_DIR}"/* # "${FORGE_LIBS_DIR}"/* +gh release create --generate-notes --title "${RELEASE_VERSION}" --notes "release ${RELEASE_VERSION}" ${RELEASE_VERSION} "${FABRIC_LIBS_DIR}"/* "${NEOFORGE_LIBS_DIR}"/* # "${FORGE_LIBS_DIR}"/* set +x diff --git a/gradle.properties b/gradle.properties index 4836b4f5..c40eb9ea 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,6 +22,11 @@ fabric_version=0.106.1+1.21.3 # NOTE: Forge is no longer supported and the build has been disabled # See: https://github.com/pcal43/fastback/issues/333 +# NeoForge +# +# https://projects.neoforged.net/neoforged/neoforge +neo_version = 21.3.31-beta + # # common dependencies # diff --git a/neoforge/build.gradle b/neoforge/build.gradle index e7a6b8d9..91d65a84 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -6,7 +6,7 @@ plugins { architectury { platformSetupLoomIde() - forge() + neoForge() } shadowJar { @@ -20,20 +20,20 @@ configurations { shadowCommon compileClasspath.extendsFrom common runtimeClasspath.extendsFrom common - developmentForge.extendsFrom common + developmentNeoForge.extendsFrom common } archivesBaseName = "${project.archives_base_name}" -version = "${project.mod_version}-forge" +version = "${project.mod_version}-neoforge" group = project.maven_group dependencies { - forge("net.minecraftforge:forge:${project.forge_version}") { transitive false } + neoForge("net.neoforged:neoforge:${project.neo_version}") { transitive false } // note to self: implementation, NOT include. include does implicit jarjar common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } + shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive = false } // FIXME? I still don't understand if I need to declare all of these things as forgeRuntimeLibrary. It sort // of seems like I do. @@ -93,7 +93,7 @@ sourcesJar { processResources { inputs.property "version", project.version - filesMatching("META-INF/mods.toml") { + filesMatching("META-INF/neoforge.mods.toml") { expand "version": project.version } } @@ -108,7 +108,7 @@ modrinth { uploadFile = remapJar changelog = "

https://github.com/pcal43/fastback/releases/tag/${project.mod_version}

" gameVersions = ["${project.minecraft_version}"] - loaders = ["forge"] + loaders = ["neoforge"] dependencies {} } @@ -124,7 +124,7 @@ curseforge { changelogType = "markdown" mod_version = "${project.version}" addGameVersion((String) project.minecraft_version) - addGameVersion "Forge" + addGameVersion "NeoForge" mainArtifact(remapJar) afterEvaluate { uploadTask.dependsOn("remapJar") diff --git a/neoforge/gradle.properties b/neoforge/gradle.properties index 82425854..7da18ea6 100644 --- a/neoforge/gradle.properties +++ b/neoforge/gradle.properties @@ -1 +1 @@ -loom.platform=forge +loom.platform=neoforge diff --git a/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/ForgeClientProvider.java b/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/ForgeClientProvider.java index 5c9bed33..bc9d8410 100644 --- a/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/ForgeClientProvider.java +++ b/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/ForgeClientProvider.java @@ -1,11 +1,11 @@ -package net.pcal.fastback.mod.forge; - -import net.minecraftforge.client.event.CustomizeGuiOverlayEvent; -import net.minecraftforge.client.event.ScreenEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +package net.pcal.fastback.mod.neoforge; + +import net.neoforged.neoforge.client.event.CustomizeGuiOverlayEvent; +import net.neoforged.neoforge.client.event.ScreenEvent; +import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; +import net.neoforged.fml.ModLoadingContext; import net.pcal.fastback.logging.UserMessage; import static java.util.Objects.requireNonNull; @@ -39,10 +39,10 @@ final class ForgeClientProvider extends ForgeCommonProvider { private final Minecraft client; public ForgeClientProvider() { - final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); + final IEventBus modEventBus = ModLoadingContext.get().getActiveContainer().getEventBus(); modEventBus.addListener(this::onClientStartupEvent); - MinecraftForge.EVENT_BUS.addListener(this::onGuiOverlayEvent); - MinecraftForge.EVENT_BUS.addListener(this::onScreenRenderEvent); + NeoForge.EVENT_BUS.addListener(this::onGuiOverlayEvent); + NeoForge.EVENT_BUS.addListener(this::onScreenRenderEvent); this.client = requireNonNull(Minecraft.getInstance(), "MinecraftClient.getInstance() returned null"); } @@ -91,7 +91,8 @@ public void setMessageScreenText(UserMessage userMessage) { final Component text = messageToText(userMessage); this.hudText = text; final Screen screen = client.screen; - if (screen != null) screen.title = text; + // TODO; fix this + //if (screen != null) screen.title = text; } @Override diff --git a/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/ForgeCommonProvider.java b/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/ForgeCommonProvider.java index ba4921d0..57ef6a02 100644 --- a/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/ForgeCommonProvider.java +++ b/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/ForgeCommonProvider.java @@ -1,4 +1,4 @@ -package net.pcal.fastback.mod.forge; +package net.pcal.fastback.mod.neoforge; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.builder.LiteralArgumentBuilder; @@ -6,14 +6,14 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.level.storage.LevelStorageSource; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.RegisterCommandsEvent; -import net.minecraftforge.event.server.ServerStartedEvent; -import net.minecraftforge.event.server.ServerStoppingEvent; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraft.world.level.storage.LevelResource; +import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.neoforge.event.RegisterCommandsEvent; +import net.neoforged.neoforge.event.server.ServerStartedEvent; +import net.neoforged.neoforge.event.server.ServerStoppingEvent; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.event.lifecycle.FMLDedicatedServerSetupEvent; +import net.neoforged.fml.ModLoadingContext; import net.pcal.fastback.logging.SystemLogger; import net.pcal.fastback.logging.UserMessage; import net.pcal.fastback.mod.LifecycleListener; @@ -44,11 +44,11 @@ class ForgeCommonProvider implements MinecraftProvider { private boolean isWorldSaveEnabled; ForgeCommonProvider() { - final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); + final IEventBus modEventBus = ModLoadingContext.get().getActiveContainer().getEventBus(); modEventBus.addListener(this::onDedicatedServerStartupEvent); - MinecraftForge.EVENT_BUS.addListener(this::onServerStartupEvent); - MinecraftForge.EVENT_BUS.addListener(this::onServerStoppingEvent); - MinecraftForge.EVENT_BUS.addListener(this::onRegisterCommandEvent); + NeoForge.EVENT_BUS.addListener(this::onServerStartupEvent); + NeoForge.EVENT_BUS.addListener(this::onServerStoppingEvent); + NeoForge.EVENT_BUS.addListener(this::onRegisterCommandEvent); } @@ -145,9 +145,7 @@ void onAutoSaveComplete() { @Override public Path getWorldDirectory() { if (this.logicalServer == null) throw new IllegalStateException("minecraftServer is null"); - final LevelStorageSource.LevelStorageAccess session = logicalServer.storageSource; - Path out = session.getWorldDir().toAbsolutePath().normalize(); - return out; + return logicalServer.getWorldPath(LevelResource.ROOT).toAbsolutePath().normalize(); } @Override diff --git a/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/ForgeInitializer.java b/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/ForgeInitializer.java index 40f18e54..df89eaac 100644 --- a/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/ForgeInitializer.java +++ b/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/ForgeInitializer.java @@ -1,7 +1,7 @@ -package net.pcal.fastback.mod.forge; +package net.pcal.fastback.mod.neoforge; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.loading.FMLEnvironment; +import net.neoforged.fml.common.Mod; +import net.neoforged.fml.loading.FMLEnvironment; import java.lang.reflect.InvocationTargetException; @@ -18,7 +18,7 @@ public ForgeInitializer() { new ForgeCommonProvider(); } else if (FMLEnvironment.dist.isClient()) { // Forge yells at us if we touch any client classes in a server. So, - Class.forName("net.pcal.fastback.mod.forge.ForgeClientProvider").getConstructor().newInstance(); + Class.forName("net.pcal.fastback.mod.neoforge.ForgeClientProvider").getConstructor().newInstance(); } else { throw new IllegalStateException("where am i? server or client?"); } diff --git a/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/Slf4jSystemLogger.java b/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/Slf4jSystemLogger.java index 0212a6fe..b1831a40 100644 --- a/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/Slf4jSystemLogger.java +++ b/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/Slf4jSystemLogger.java @@ -1,4 +1,4 @@ -package net.pcal.fastback.mod.forge; +package net.pcal.fastback.mod.neoforge; import net.pcal.fastback.logging.SystemLogger; import org.slf4j.Logger; diff --git a/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/SshHacks.java b/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/SshHacks.java index fcc95fc0..11b082b6 100644 --- a/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/SshHacks.java +++ b/neoforge/src/main/java/net/pcal/fastback/mod/neoforge/SshHacks.java @@ -1,4 +1,4 @@ -package net.pcal.fastback.mod.forge; +package net.pcal.fastback.mod.neoforge; import org.eclipse.jgit.transport.SshSessionFactory; diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml similarity index 77% rename from neoforge/src/main/resources/META-INF/mods.toml rename to neoforge/src/main/resources/META-INF/neoforge.mods.toml index 7280224b..a4d329af 100644 --- a/neoforge/src/main/resources/META-INF/mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -1,11 +1,11 @@ modLoader = "javafml" -loaderVersion = "[49,)" +loaderVersion = "[5,)" issueTrackerURL = "https://github.com/pcal43/fastback" license = "GPL2" [[mods]] modId = "fastback" -version = "0.17.4+1.20.6-prerelease" +version = "0.19.2+1.21.3-prerelease" displayName = "Fast Backups" authors = "pcal" description = ''' @@ -15,15 +15,15 @@ https://pcal43.github.io/fastback/ logoFile = "fastback-icon.png" [[dependencies.fastback]] -modId = "forge" +modId = "neoforge" mandatory = true -versionRange = "[49,)" +versionRange = "[21.3.29-beta,)" ordering = "NONE" side = "CLIENT" [[dependencies.fastback]] modId = "minecraft" mandatory = true -versionRange = "1.20.6" +versionRange = "1.21.3" ordering = "NONE" side = "CLIENT" diff --git a/settings.gradle b/settings.gradle index d103e060..689bdd52 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,12 +11,12 @@ pluginManagement { } //mavenCentral() gradlePluginPortal() + maven { + name = 'NeoForged' + url = 'https://maven.neoforged.net/releases' + } // NOTE: Forge is no longer supported and the build has been disabled // See: https://github.com/pcal43/fastback/issues/333 - // maven { - // name = 'NeoForged' - // url = 'https://maven.neoforged.net/releases' - //} // architectury-loom still demands this for some reason maven { name = "Forge" @@ -29,6 +29,7 @@ rootProject.name = "fastback" include(":common") include(":fabric") +include(":neoforge") // NOTE: Forge is no longer supported and the build has been disabled // See: https://github.com/pcal43/fastback/issues/333