Update to 1.20.2. Add a NeoForge project

This commit is contained in:
Jared 2023-11-11 01:19:46 -07:00
parent 493ecc96d2
commit ec156b6c83
14 changed files with 233 additions and 25 deletions

1
.gitignore vendored
View File

@ -21,3 +21,4 @@ build
# other
eclipse
run
runs

View File

@ -1,8 +1,7 @@
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT' apply(false)
id 'net.minecraftforge.gradle' version '[6.0,6.2)' apply(false)
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' apply(false)
id("org.spongepowered.mixin") version "0.7-SNAPSHOT" apply(false)
id 'org.spongepowered.mixin' version '0.7-SNAPSHOT' apply(false)
}
subprojects {
@ -71,7 +70,10 @@ subprojects {
"mod_author": mod_author,
"mod_id": mod_id,
"license": license,
"description": project.description
"description": project.description,
"neoforge_version": neoforge_version,
"neoforge_loader_version_range": neoforge_loader_version_range,
"credits": credits
]
filesMatching(['pack.mcmeta', 'fabric.mod.json', 'META-INF/mods.toml', '*.mixins.json']) {

View File

@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"id": "mod_id",
"id": "${mod_id}",
"version": "${version}",
"name": "${mod_name}",
"description": "${description}",
@ -26,7 +26,7 @@
"depends": {
"fabricloader": ">=0.14",
"fabric": "*",
"minecraft": "1.20",
"minecraft": "1.20.2",
"java": ">=17"
},
"suggests": {

View File

@ -1,7 +1,7 @@
plugins {
id 'idea'
id 'maven-publish'
id 'net.minecraftforge.gradle'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
id 'org.spongepowered.mixin'
}
base {

View File

@ -8,8 +8,8 @@ version = "${version}" #mandatory
displayName = "${mod_name}" #mandatory
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional (see https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/)
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional (displayed in the mod UI)
logoFile = "${mod_id}.png" #optional (needs to be in the root of your mod jar (root of your 'resources' folder))
credits = "Thanks for this example mod goes to Java" #optional
logoFile = "${mod_id}.png" #optional
credits = "${credits}" #optional
authors = "${mod_author}" #optional
description = '''${description}''' #mandatory (Supports multiline text)
[[dependencies.${mod_id}]] #optional

View File

@ -7,24 +7,27 @@ version=1.0.0
group=com.example.examplemod
# Common
minecraft_version=1.20
# Forge
forge_version=46.0.12
forge_loader_version_range=[46,)
forge_version_range=[46,)
minecraft_version_range=[1.20, 1.21)
# Fabric
fabric_version=0.83.0+1.20
fabric_loader_version=0.14.21
# Mod options
minecraft_version=1.20.2
mod_name=ExampleMod
mod_author=Jared
mod_id=examplemod
license=C0-1.0
credits=
description=The description of your mod. \nAccepts multilines.
minecraft_version_range=[1.20.2, 1.21)
# Fabric
fabric_version=0.90.7+1.20.2
fabric_loader_version=0.14.24
# Forge
forge_version=48.0.37
forge_loader_version_range=[48,)
forge_version_range=[48,)
# NeoForge
neoforge_version=20.2.47-beta
neoforge_loader_version_range=[1,)
# Gradle
org.gradle.jvmargs=-Xmx3G

78
neoforge/build.gradle Normal file
View File

@ -0,0 +1,78 @@
plugins {
id 'idea'
id 'maven-publish'
id 'net.neoforged.gradle.userdev' version '7.0.41'
id 'java-library'
}
base {
archivesName = "${mod_name}-neoforge-${minecraft_version}"
}
// Automatically enable neoforge AccessTransformers if the file exists
// This location is hardcoded in FML and can not be changed.
// https://github.com/neoforged/FancyModLoader/blob/a952595eaaddd571fbc53f43847680b00894e0c1/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ModFile.java#L118
if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) {
minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
}
runs {
configureEach {
modSource project.sourceSets.main
}
client {
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
server {
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
programArgument '--nogui'
}
gameTestServer {
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
data {
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
}
sourceSets.main.resources { srcDir 'src/generated/resources' }
dependencies {
implementation "net.neoforged:neoforge:${neoforge_version}"
compileOnly project(":common")
}
// NeoGradle compiles the game, but we don't want to add our common code to the game's code
TaskCollection.metaClass.excludingNeoTasks = { ->
delegate.matching { !it.name.startsWith("neo") }
}
tasks.withType(JavaCompile).excludingNeoTasks().configureEach {
source(project(":common").sourceSets.main.allSource)
}
tasks.withType(Javadoc).excludingNeoTasks().configureEach {
source(project(":common").sourceSets.main.allJava)
}
tasks.named("sourcesJar", Jar) {
from(project(":common").sourceSets.main.allSource)
}
tasks.withType(ProcessResources).excludingNeoTasks().configureEach {
from project(":common").sourceSets.main.resources
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId base.archivesName.get()
from components.java
}
}
repositories {
maven {
url "file://" + System.getenv("local_maven")
}
}
}

View File

@ -0,0 +1,20 @@
package com.example.examplemod;
import net.neoforged.fml.common.Mod;
@Mod(Constants.MOD_ID)
public class ExampleMod {
public ExampleMod() {
// This method is invoked by the NeoForge mod loader when it is ready
// to load your mod. You can access NeoForge and Common code in this
// project.
// Use NeoForge to bootstrap the Common mod.
Constants.LOG.info("Hello NeoForge world!");
CommonClass.init();
}
}

View File

@ -0,0 +1,20 @@
package com.example.examplemod.mixin;
import com.example.examplemod.Constants;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.TitleScreen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(TitleScreen.class)
public class MixinTitleScreen {
@Inject(at = @At("HEAD"), method = "init()V")
private void init(CallbackInfo info) {
Constants.LOG.info("This line is printed by an example mod mixin from NeoForge!");
Constants.LOG.info("MC Version: {}", Minecraft.getInstance().getVersionType());
}
}

View File

@ -0,0 +1,26 @@
package com.example.examplemod.platform;
import com.example.examplemod.platform.services.IPlatformHelper;
import net.neoforged.fml.ModList;
import net.neoforged.fml.loading.FMLLoader;
public class NeoForgePlatformHelper implements IPlatformHelper {
@Override
public String getPlatformName() {
return "NeoForge";
}
@Override
public boolean isModLoaded(String modId) {
return ModList.get().isLoaded(modId);
}
@Override
public boolean isDevelopmentEnvironment() {
return !FMLLoader.isProduction();
}
}

View File

@ -0,0 +1,36 @@
modLoader = "javafml" #mandatory
loaderVersion = "${neoforge_loader_version_range}" #mandatory
license = "${license}" # Review your options at https://choosealicense.com/.
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
[[mods]] #mandatory
modId = "${mod_id}" #mandatory
version = "${version}" #mandatory
displayName = "${mod_name}" #mandatory
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional (see https://docs.neoforged.net/docs/misc/updatechecker/)
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional (displayed in the mod UI)
logoFile="${mod_id}.png" #optional
credits="${credits}" #optional
authors = "${mod_author}" #optional
description = '''${description}''' #mandatory (Supports multiline text)
[[mixins]]
config = "examplemod.mixins.json"
[[mixins]]
config = "examplemod.neoforge.mixins.json"
[[dependencies.${ mod_id }]] #optional
modId = "neoforge" #mandatory
mandatory = true #mandatory
versionRange = "${neoforge_loader_version_range}" #mandatory
ordering = "NONE" # The order that this dependency should load in relation to your mod, required to be either 'BEFORE' or 'AFTER' if the dependency is not mandatory
side = "BOTH" # Side this dependency is applied on - 'BOTH', 'CLIENT' or 'SERVER'
[[dependencies.${ mod_id }]]
modId = "minecraft"
mandatory = true
versionRange = "${minecraft_version_range}"
ordering = "NONE"
side = "BOTH"
# Features are specific properties of the game environment, that you may want to declare you require. This example declares
# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't
# stop your mod loading on the server for example.
#[features.${mod_id}]
#openGLVersion="[3.2,)"

View File

@ -0,0 +1 @@
com.example.examplemod.platform.NeoForgePlatformHelper

View File

@ -0,0 +1,16 @@
{
"required": true,
"minVersion": "0.8",
"package": "com.example.examplemod.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [
"MixinTitleScreen"
],
"server": [
],
"injectors": {
"defaultRequire": 1
}
}

View File

@ -1,14 +1,18 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven {
name = 'Forge'
url = 'https://maven.minecraftforge.net/'
}
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'NeoForge'
url = 'https://maven.neoforged.net/releases/'
}
maven {
name = 'Forge'
url = 'https://maven.minecraftforge.net/'
}
maven {
name = 'Sponge Snapshots'
url = 'https://repo.spongepowered.org/repository/maven-public/'
@ -25,3 +29,4 @@ rootProject.name = 'MultiLoader-Template'
include("common")
include("fabric")
include("forge")
include("neoforge")