Skip to content

Commit

Permalink
Reconfigure for NeoForge
Browse files Browse the repository at this point in the history
This configures the neoforge build, but does not address critical bugs that prevent the neoforge build from functioning.
  • Loading branch information
stewi1014 committed Nov 20, 2024
1 parent a01ae15 commit 71d0fbc
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 55 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
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
1 change: 1 addition & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
4 changes: 3 additions & 1 deletion etc/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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


Expand Down
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
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"
9 changes: 5 additions & 4 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit 71d0fbc

Please sign in to comment.