1 Commits
1.21 ... 1.20

Author SHA1 Message Date
4f234fc059 [CHANGE] Have mods.toml use values from gradle.properties 2023-11-08 22:31:08 +02:00
15 changed files with 66 additions and 59 deletions

View File

@@ -3,7 +3,7 @@ package com.author.examplemod;
import com.author.examplemod.platform.IPlatformHelper;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.Item;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.TooltipFlag;
@@ -20,9 +20,14 @@ public class ExampleModCommon {
// This method serves as a hook to modify item tooltips. The vanilla game
// has no mechanism to load tooltip listeners so this must be registered
// by a mod loader like Forge or Fabric.
public static void onItemTooltip(ItemStack stack, Item.TooltipContext context, TooltipFlag flag, List<Component> tooltip) {
public static void onItemTooltip(ItemStack stack, TooltipFlag context, List<Component> tooltip) {
if (!stack.isEmpty()) {
tooltip.add(Component.literal("Hey you!"));
final FoodProperties food = stack.getItem().getFoodProperties();
if (food != null) {
tooltip.add(Component.literal("Nutrition: " + food.getNutrition()));
tooltip.add(Component.literal("Saturation: " + food.getSaturationModifier()));
}
}
}

View File

@@ -26,7 +26,7 @@
"depends": {
"fabricloader": ">=0.14",
"fabric": "*",
"minecraft": ">=1.21",
"java": ">=21"
"minecraft": "1.20.x",
"java": ">=17"
}
}

View File

@@ -1,5 +1,5 @@
// Adjust the output jar name here
archivesBaseName = "${mod_name}-NeoForge-${minecraft_version}"
archivesBaseName = "${mod_name}-Forge-${minecraft_version}"
dependencies {
// Add your dependencies here
@@ -31,9 +31,9 @@ publishing {
*/
unimined.minecraft {
neoForged {
loader neoforge_version
mixinConfig("${mod_id}.mixins.json", "${mod_id}-neoforge.mixins.json")
minecraftForge {
loader forge_version
mixinConfig("${mod_id}.mixins.json", "${mod_id}-forge.mixins.json")
}
}
@@ -41,7 +41,7 @@ processResources {
from project(":Common").sourceSets.main.resources
def buildProps = project.properties.clone()
filesMatching("META-INF/neoforge.mods.toml") {
filesMatching("META-INF/mods.toml") {
expand buildProps
}
}

View File

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

View File

@@ -1,8 +1,8 @@
package com.author.examplemod.services;
import com.author.examplemod.platform.IPlatformHelper;
import net.neoforged.fml.ModList;
import net.neoforged.fml.loading.FMLLoader;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.loading.FMLLoader;
public class ForgePlatformHelper implements IPlatformHelper {

View File

@@ -1,14 +1,14 @@
modLoader="javafml"
loaderVersion="[1,)"
loaderVersion="[48,)"
license="MIT"
issueTrackerURL="https://github.com/neoforged/"
issueTrackerURL="https://github.com/minecraftforge/"
[[mods]]
modId="${mod_id}"
version="${version}"
displayName="${mod_name}"
#updateJSONURL="https://change.me.example.invalid/updates.json"
displayURL="https://neoforged.net"
displayURL="https://minecraftforge.net"
logoFile="assets/examplemod/icon.png"
credits="Thanks for this example mod goes to Java"
authors="${mod_author}"
@@ -21,15 +21,15 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mollis lacinia magn
'''
[[dependencies.${mod_id}]]
modId="neoforge"
type="required"
versionRange="[21.0.0-beta,)"
modId="forge"
mandatory=true
versionRange="[48,)"
ordering="NONE"
side="BOTH"
[[dependencies.${mod_id}]]
modId="minecraft"
type="required"
versionRange="[1.21,1.21.1)"
mandatory=true
versionRange="[1.20.2,)"
ordering="NONE"
side="BOTH"

View File

@@ -1,20 +0,0 @@
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.getContext(), event.getFlags(), event.getToolTip());
}
}

View File

@@ -1,6 +1,6 @@
plugins {
id 'java'
id "xyz.wagyourtail.unimined" version "1.2.9" apply false
id "xyz.wagyourtail.unimined" version "1.1.0-SNAPSHOT" apply false
}
// Edit in gradle.properties
@@ -15,8 +15,8 @@ subprojects {
group = rootProject.group
version = rootProject.version
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
// Add your maven repositories here
repositories {
@@ -73,10 +73,10 @@ subprojects {
tasks.withType(JavaCompile).configureEach {
it.options.encoding = 'UTF-8'
it.options.release = 21
it.options.release = 17
}
tasks.withType(GenerateModuleMetadata).configureEach {
tasks.withType(GenerateModuleMetadata) {
enabled = false
}

View File

@@ -10,14 +10,14 @@ mod_id=examplemod
mod_name=ExampleMod
# Shared
minecraft_version=1.21
minecraft_version=1.20.2
# Fabric
fabric_loader=0.15.11
fabric_api=0.102.0+1.21
fabric_loader=0.14.24
fabric_api=0.90.7+1.20.2
# NeoForge
neoforge_version=167
# Forge
forge_version=48.0.34
# Gradle Options
org.gradle.jvmargs=-Xmx3G

View File

@@ -1,6 +1,6 @@
#Sun Nov 05 19:31:04 SAST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -20,7 +20,7 @@ This project is powered by [Unimined](https://github.com/unimined/unimined), and
4) `minecraft_version` -> The minecraft version your project targets
5) `fabric_loader` -> The fabric loader version to use. Find this [here](https://fabricmc.net/develop/)
6) `fabric_api` -> The Fabric API for your minecraft version. Find this [here](https://fabricmc.net/develop/)
7) `neoforge_version` -> The NeoForge version for your Minecraft version to use. For example: `39-beta`
7) `forge_version` -> The Forge version for your Minecraft version to use
4) Open up `fabric.mod.json` from the Fabric module, and replace the following values:
1) `description` -> Describe what your mod does
@@ -31,16 +31,16 @@ This project is powered by [Unimined](https://github.com/unimined/unimined), and
6) `minecraft` -> The minecraft version(s) your mod supports
7) If you do not plan on using mixins, remove the `mixins` section
5) Open up `mods.toml` from the NeoForge module and replace the following values:
1) `loaderVersion` -> The neoforge version code
5) Open up `mods.toml` from the Forge module and replace the following values:
1) `loaderVersion` -> The forge version code
2) `license` -> Your mod license
3) `issueTrackerURL` -> Your GitHub repository of the mod
6) `displayURL` -> Your Modrinth/Curseforge/GitHub page of the mod
7) `logoFile` -> Your mod icon
9) `description` -> Your mod description
11) `versionRange` -> `[neoforgeVersionCode,)` and `[1.20.2,)` (Replace with the minecraft versions your mod supports)
11) `versionRange` -> `[forgeVersionCode,)` and `[1.20.2,)` (Replace with the minecraft versions your mod supports)
6) If your default JVM/JDK is not Java 21 you will encounter an error when opening the project. This error is fixed by going to File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JVM and changing the value to a valid Java 21 JVM. You will also need to set the Project SDK to Java 21. This can be done by going to File > Project Structure > Project SDK. Once both have been set open the Gradle tab in IDEA and click the refresh button to reload the project.
6) If your default JVM/JDK is not Java 17 you will encounter an error when opening the project. This error is fixed by going to File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JVMand changing the value to a valid Java 17 JVM. You will also need to set the Project SDK to Java 17. This can be done by going to File > Project Structure > Project SDK. Once both have been set open the Gradle tab in IDEA and click the refresh button to reload the project.
7) Replace the contents of `LICENSE` with your mod license
8) Replace the contents of `readme.md` with your mod readme
@@ -48,9 +48,9 @@ This project is powered by [Unimined](https://github.com/unimined/unimined), and
### Development Guide
When using this template the majority of your mod is developed in the Common project. The Common project is compiled against the vanilla game and is used to hold code that is shared between the different loader-specific versions of your mod. The Common project has no knowledge or access to ModLoader specific code, apis, or concepts. Code that requires something from a specific loader must be done through the project that is specific to that loader, such as the NeoForge or Fabric project.
When using this template the majority of your mod is developed in the Common project. The Common project is compiled against the vanilla game and is used to hold code that is shared between the different loader-specific versions of your mod. The Common project has no knowledge or access to ModLoader specific code, apis, or concepts. Code that requires something from a specific loader must be done through the project that is specific to that loader, such as the Forge or Fabric project.
Loader specific projects such as the NeoForge and Fabric project are used to load the Common project into the game. These projects also define code that is specific to that loader. Loader specific projects can access all of the code in the Common project. It is important to remember that the Common project can not access code from loader specific projects.
Loader specific projects such as the Forge and Fabric project are used to load the Common project into the game. These projects also define code that is specific to that loader. Loader specific projects can access all of the code in the Common project. It is important to remember that the Common project can not access code from loader specific projects.
***

View File

@@ -13,4 +13,7 @@ pluginManagement {
}
rootProject.name = 'fdd-xplat'
include('Common', 'Fabric', 'NeoForge')
include 'Common'
include 'Fabric'
include 'Forge'