[FEAT] Fabric/NeoForge Template

This commit is contained in:
2023-11-08 22:28:44 +02:00
parent 4f23720734
commit b3114640a2
12 changed files with 36 additions and 30 deletions

56
NeoForge/build.gradle Normal file
View File

@@ -0,0 +1,56 @@
// Adjust the output jar name here
archivesBaseName = "${mod_name}-NeoForge-${minecraft_version}"
dependencies {
// Add your dependencies here
// Do not edit or remove
implementation project(":Common")
}
// Maven Publishing. Remove if not needed
publishing {
publications {
mavenJava(MavenPublication) {
artifactId base.archivesName.get()
from components.java
}
}
repositories {
// Add your maven repository here
maven {
url "file://" + System.getenv("local_maven")
}
}
}
/**
* ===============================================================================
* = DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING =
* ===============================================================================
*/
unimined.minecraft {
neoForged {
loader neoforge_version
mixinConfig("${mod_id}.mixins.json", "${mod_id}-neoforge.mixins.json")
// TODO Remove when NeoGradle is fixed
forgeTransformer.binpatchFile = rootProject.projectDir.toPath().resolve("output.lzma")
}
}
processResources {
from project(":Common").sourceSets.main.resources
def buildProps = project.properties.clone()
filesMatching("META-INF/mods.toml") {
expand buildProps
}
}
compileTestJava.enabled = false
tasks.withType(JavaCompile).configureEach {
source(project(":Common").sourceSets.main.allSource)
}

View File

@@ -0,0 +1,20 @@
package com.author.examplemod;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.entity.player.ItemTooltipEvent;
@Mod(ModConstants.MOD_ID)
public class ExampleModForge {
public ExampleModForge(IEventBus modEventBus) {
ModConstants.LOGGER.info("Hello Forge!");
ExampleModCommon.initialize();
NeoForge.EVENT_BUS.addListener(this::onItemTooltip);
}
private void onItemTooltip(ItemTooltipEvent event) {
ExampleModCommon.onItemTooltip(event.getItemStack(), event.getFlags(), event.getToolTip());
}
}

View File

@@ -0,0 +1,18 @@
package com.author.examplemod.mixin.client;
import com.author.examplemod.ModConstants;
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 ExampleForgeMixin {
@Inject(at = @At("HEAD"), method = "init()V")
private void init(CallbackInfo ci) {
ModConstants.LOGGER.info("This line is printed by a mixin from Forge!");
}
}

View File

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

View File

@@ -0,0 +1,35 @@
modLoader="javafml"
loaderVersion="[1,)"
license="MIT"
issueTrackerURL="https://github.com/minecraftforge/"
[[mods]]
modId="${mod_id}"
version="${version}"
displayName="${mod_name}"
#updateJSONURL="https://change.me.example.invalid/updates.json"
displayURL="https://minecraftforge.net"
logoFile="assets/examplemod/icon.png"
credits="Thanks for this example mod goes to Java"
authors="${mod_author}"
description='''
This is a long form description of the mod. You can write whatever you want here
Have some lorem ipsum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mollis lacinia magna. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed sagittis luctus odio eu tempus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque volutpat ligula eget lacus auctor sagittis. In hac habitasse platea dictumst. Nunc gravida elit vitae sem vehicula efficitur. Donec mattis ipsum et arcu lobortis, eleifend sagittis sem rutrum. Cras pharetra quam eget posuere fermentum. Sed id tincidunt justo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
'''
[[dependencies.${mod_id}]]
modId="neoforge"
mandatory=true
versionRange="[20.2,)"
ordering="NONE"
side="BOTH"
[[dependencies.${mod_id}]]
modId="minecraft"
mandatory=true
versionRange="[1.20.2,1.21)"
ordering="NONE"
side="BOTH"

View File

@@ -0,0 +1 @@
com.author.examplemod.services.ForgePlatformHelper

View File

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