Skip to content

Commit

Permalink
Merge pull request #674 from RakambdaOrg/nf
Browse files Browse the repository at this point in the history
Add NeoForge support
  • Loading branch information
Rakambda authored Apr 30, 2024
2 parents 4b16f2a + 1397f33 commit 4e0e516
Show file tree
Hide file tree
Showing 40 changed files with 2,015 additions and 8 deletions.
50 changes: 50 additions & 0 deletions .github/ISSUE_TEMPLATE/2_forge-bug-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Forge bug report
description: Create a report to help us improve the Forge version
labels: ["modloader: Neoforge", "type: 🐛 bug"]
assignees:
- Rakambda
body:
- type: textarea
id: describing
attributes:
label: Describe the bug
description: Describe what happens and what you expected instead
validations:
required: true
- type: input
id: mc-version
attributes:
label: Minecraft version
placeholder: 1.16.5
validations:
required: true
- type: input
id: neoforge-version
attributes:
label: NeoForge version
placeholder: 20.6.0
validations:
required: true
- type: input
id: mod-version
attributes:
label: Mod version
placeholder: 2.10.0
validations:
required: true
- type: textarea
id: config
attributes:
label: Configuration
description: Please copy the content of the configuration file `fallingtree.json`
render: json
validations:
required: true
- type: textarea
id: logs
attributes:
label: Relevant log output
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
render: shell
validations:
required: false
23 changes: 16 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ tasks.register('buildJar', Jar) {
if (project.includeForge.toBoolean()) {
dependsOn(":forge:build")
}
if (project.includeNeoForge.toBoolean()) {
dependsOn(":neoforge:build")
}

duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from {
Expand All @@ -109,6 +112,11 @@ tasks.register('buildJar', Jar) {
zipTree("forge/build/libs/forge-${project.version}.jar")
}
}
if (project.includeNeoForge.toBoolean()) {
from {
zipTree("neoforge/build/libs/neoforge-${project.version}.jar")
}
}

manifest {
attributes([
Expand Down Expand Up @@ -154,6 +162,9 @@ curseforge {
if (project.includeForge.toBoolean()) {
addGameVersion("Forge")
}
if (project.includeNeoForge.toBoolean()) {
addGameVersion("NeoForge")
}
changelog = getFTChangelog() ?: "No changelog provided"
releaseType = relType
mainArtifact(jar) {
Expand All @@ -166,9 +177,7 @@ curseforge {
optionalDependency("cloth-config")
}

if (project.includeForge.toBoolean()) {
optionalDependency("cloth-config")
}
optionalDependency("cloth-config")
}
}
options {
Expand All @@ -195,6 +204,9 @@ modrinth {
if (project.includeForge.toBoolean()) {
loaders.add("forge")
}
if (project.includeNeoForge.toBoolean()) {
loaders.add("neoforge")
}
versionType.set(relType)
changelog.set(getFTChangelog() ?: "No changelog provided")
syncBodyFrom.set(rootProject.file("README.md").getText())
Expand All @@ -204,12 +216,9 @@ modrinth {
if (project.includeFabric.toBoolean()) {
optional.project("P7dR8mSH") //Fabric-api / It's actually required
optional.project("mOgUt4GM") //Modmenu
optional.project("9s6osm5g") //Cloth config
}

if (project.includeForge.toBoolean()) {
optional.project("9s6osm5g") //Cloth config
}
optional.project("9s6osm5g") //Cloth config
}

afterEvaluate {
Expand Down
2 changes: 1 addition & 1 deletion forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ minecraft {
data {
taskName "runFTForgeData"
workingDirectory project.file("./run/data")
args '--mod', 'fallingtree', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
args '--mod', 'fallingtree', '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
}
}
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ modId=fallingtree
modName=FallingTree
includeFabric=true
includeForge=false
includeNeoForge=true
# Repository
repoUser=Rakambda
repoName=FallingTree
Expand Down
4 changes: 4 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ minecraftVersion = "1.20.6"
fabric-loader-version = "0.15.10"
fabric-api-version = "0.97.8+1.20.6"
forge-version = "1.20.4-49.0.3"
neoforge-version = "20.6.7-beta"

# Mod dependencies
modmenu-version = "10.0.0-beta.1"
Expand All @@ -22,6 +23,7 @@ curse-version = "1.4.0"
modrinth-version = "2.8.7"
names-version = "0.51.0"
git-version-plugin-version = "3.0.0"
neoforge-plugin-version = "7.0.109"

[libraries]
lombok = { group = "org.projectlombok", name = "lombok", version.ref = "lombok-version" }
Expand All @@ -32,6 +34,7 @@ minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft
fabric-loader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fabric-loader-version" }
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabric-api-version" }
forge = { group = "net.minecraftforge", name = "forge", version.ref = "forge-version" }
neoforge = { group = "net.neoforged", name = "neoforge", version.ref = "neoforge-version" }
modmenu = { group = "com.terraformersmc", name = "modmenu", version.ref = "modmenu-version" }
clothConfigFabric = { group = "me.shedaniel.cloth", name = "cloth-config-fabric", version.ref = "clothConfigVersion" }
clothConfigForge = { group = "me.shedaniel.cloth", name = "cloth-config-forge", version.ref = "clothConfigVersion" }
Expand All @@ -45,4 +48,5 @@ modrinth = { id = "com.modrinth.minotaur", version.ref = "modrinth-version"}
names = { id = "com.github.ben-manes.versions", version.ref = "names-version" }
loom = { id = "fabric-loom", version.ref = "fabric-loom-version" }
forge = { id = "net.minecraftforge.gradle", version.ref = "forge-plugin-version" }
neoforge = { id = "net.neoforged.gradle.userdev", version.ref = "neoforge-plugin-version" }
gitVersion = { id = "com.palantir.git-version", version.ref = "git-version-plugin-version" }
4 changes: 4 additions & 0 deletions neoforge/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# gradle
.gradle/
build/
run/
66 changes: 66 additions & 0 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
plugins {
id("java-library")
alias(libs.plugins.neoforge)
}

runs {
configureEach {
systemProperty "forge.logging.markers", "REGISTRIES"
systemProperty "forge.logging.console.level", "error"
}

client {
// name "runFTNeoForgeClient"
workingDirectory.set(project.file("./run/client"))
}

server {
// taskName "runFTNeoForgeServer"
workingDirectory.set(project.file("./run/server"))
programArgument "--nogui"
}

gameTestServer {
// taskName "runFTNeoForgeTestServer"
workingDirectory.set(project.file("./run/test"))
systemProperty "forge.enabledGameTestNamespaces", "fallingtree"
}

data {
// taskName "runFTNeoForgeData"
workingDirectory.set(project.file("./run/data"))
programArguments.addAll '--mod', 'fallingtree', '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
}

minecraft {
mappings {
channel = official()
version.put "minecraft", libs.versions.minecraftVersion.get()
}

accessTransformers.file('src/main/resources/META-INF/neoforge.accesstransformer.cfg')
}

sourceSets.main.resources { srcDir 'src/generated/resources' }

dependencies {
implementation(libs.neoforge)
implementation(project(":common"))

implementation("me.shedaniel.cloth:cloth-config-neoforge:${libs.versions.clothConfigVersion.get()}")
}

ext {
minecraftVersion = libs.versions.minecraftVersion.get()
}

processResources {
duplicatesStrategy = DuplicatesStrategy.INCLUDE

from "src/main/resources", "../common/src/main/resources"

filesMatching(["META-INF/neoforge.mods.toml"]) {
expand project.properties
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package fr.rakambda.fallingtree.neoforge;

import fr.rakambda.fallingtree.common.FallingTreeCommon;
import fr.rakambda.fallingtree.neoforge.client.cloth.ClothConfigHook;
import fr.rakambda.fallingtree.neoforge.common.FallingTreeCommonsImpl;
import lombok.Getter;
import lombok.extern.log4j.Log4j2;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.ModList;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.common.NeoForge;
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.InvocationTargetException;

@Log4j2
@Mod(FallingTree.MOD_ID)
public class FallingTree{
public static final String MOD_ID = "fallingtree";
@Getter
private static FallingTreeCommonsImpl mod;

public FallingTree(@NotNull IEventBus modEventBus, @NotNull ModContainer modContainer){
mod = new FallingTreeCommonsImpl(modEventBus);

if(ModList.get().isLoaded("cloth_config")){
try{
Class.forName("fr.rakambda.fallingtree.neoforge.client.cloth.ClothConfigHook")
.asSubclass(ClothConfigHook.class)
.getConstructor(FallingTreeCommon.class)
.newInstance(mod)
.load(modContainer);
}
catch(ClassNotFoundException | IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e){
log.error("Failed to hook into ClothConfig", e);
}
}

mod.registerEnchant();
mod.registerForge(NeoForge.EVENT_BUS);
}
}
Loading

0 comments on commit 4e0e516

Please sign in to comment.