Skip to content

Commit

Permalink
Reconfigure for NeoForge
Browse files Browse the repository at this point in the history
Attempts to resolve pcal43#333, but does not fix critical bugs preventing fastback from function on NeoForge.
  • Loading branch information
stewi1014 committed Nov 19, 2024
1 parent 11c6b0f commit 39389c7
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 62 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

.PHONY: clean
clean:
rm -rf build common/build fabric/build forge/build
rm -rf build common/build fabric/build neoforge/build


.PHONY: jar
jar:
./gradlew remapJar
ls -1 fabric/build/libs
ls -1 forge/build/libs
ls -1 neoforge/build/libs

test:
./gradlew test
Expand Down Expand Up @@ -41,11 +41,11 @@ inst:
rm -f ~/minecraft/instances/1.20.1-forge-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 forge/build/libs/fastback*-forge.jar ~/minecraft/instances/1.20.1-forge-dev/.minecraft/mods/
cp forge/build/libs/fastback*-neoforge.jar ~/minecraft/instances/1.20.1-neoforge-dev/.minecraft/mods/

.PHONY: tvf
tvf:
jar -tvf forge/build/libs/fastback*-forge.jar
jar -tvf forge/build/libs/fastback*-neoforge.jar

.PHONY: tvfs
tvfs:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

architectury {
common("fabric")
// NOTE: Forge is no longer supported and the build has been disabled
// See: https://github.com/pcal43/fastback/issues/333
//common("forge")
common("neoforge")
}

dependencies {
Expand Down
4 changes: 2 additions & 2 deletions etc/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fi
#

FABRIC_LIBS_DIR='fabric/build/libs'
FORGE_LIBS_DIR='forge/build/libs'
FORGE_LIBS_DIR='neoforge/build/libs'

CURRENT_VERSION=$(sed -rn 's/^mod_version.*=[ ]*([^\n]+)$/\1/p' gradle.properties)
echo "Current version is '$CURRENT_VERSION'"
Expand Down Expand Up @@ -78,7 +78,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}"/* "${FORGE_LIBS_DIR}"/*
set +x


Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ loader_version=0.16.4
fabric_version=0.106.1+1.21.3

#
# Forge
# NeoForge
#
# https://files.minecraftforge.net/net/minecraftforge/forge/
forge_version = 1.21.3-53.0.19
# https://projects.neoforged.net/neoforged/neoforge
neo_version = 21.3.31-beta

#
# common dependencies
Expand Down
16 changes: 8 additions & 8 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

architectury {
platformSetupLoomIde()
forge()
neoForge()
}

shadowJar {
Expand All @@ -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.
Expand Down Expand Up @@ -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
}
}
Expand All @@ -108,7 +108,7 @@ modrinth {
uploadFile = remapJar
changelog = "<p><a href='https://github.com/pcal43/fastback/releases/tag/${project.mod_version}'>https://github.com/pcal43/fastback/releases/tag/${project.mod_version}</a></p>"
gameVersions = ["${project.minecraft_version}"]
loaders = ["forge"]
loaders = ["neoforge"]
dependencies {}
}

Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion neoforge/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
loom.platform=forge
loom.platform=neoforge
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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");
}

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package net.pcal.fastback.mod.forge;
package net.pcal.fastback.mod.neoforge;

import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.client.gui.GuiGraphics;
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;
Expand Down Expand Up @@ -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);
}


Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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?");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.pcal.fastback.mod.forge;
package net.pcal.fastback.mod.neoforge;

import org.eclipse.jgit.transport.SshSessionFactory;

Expand Down
Original file line number Diff line number Diff line change
@@ -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 = '''
Expand All @@ -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"
6 changes: 5 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ pluginManagement {
name = "Forge"
url = "https://maven.minecraftforge.net/"
}
maven {
name = 'NeoForged'
url = 'https://maven.neoforged.net/releases'
}
}
}

rootProject.name = "fastback"

include(":common")
include(":fabric")
include(":forge")
include(":neoforge")

0 comments on commit 39389c7

Please sign in to comment.