2 Commits

Author SHA1 Message Date
03166c25dd [BUG] Fix example mod not being able to compile - #1 2024-10-17 18:55:35 +02:00
40ba1ba66a [CHORE] Update for 1.21 2024-06-15 22:28:20 +02:00
11 changed files with 26 additions and 34 deletions

View File

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

View File

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

View File

@@ -41,7 +41,7 @@ processResources {
from project(":Common").sourceSets.main.resources from project(":Common").sourceSets.main.resources
def buildProps = project.properties.clone() def buildProps = project.properties.clone()
filesMatching("META-INF/mods.toml") { filesMatching("META-INF/neoforge.mods.toml") {
expand buildProps expand buildProps
} }
} }

View File

@@ -15,6 +15,6 @@ public class ExampleModForge {
} }
private void onItemTooltip(ItemTooltipEvent event) { private void onItemTooltip(ItemTooltipEvent event) {
ExampleModCommon.onItemTooltip(event.getItemStack(), event.getFlags(), event.getToolTip()); ExampleModCommon.onItemTooltip(event.getItemStack(), event.getContext(), event.getFlags(), event.getToolTip());
} }
} }

View File

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

View File

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

View File

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

View File

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

Binary file not shown.

View File

@@ -40,7 +40,7 @@ This project is powered by [Unimined](https://github.com/unimined/unimined), and
9) `description` -> Your mod description 9) `description` -> Your mod description
11) `versionRange` -> `[neoforgeVersionCode,)` and `[1.20.2,)` (Replace with the minecraft versions your mod supports) 11) `versionRange` -> `[neoforgeVersionCode,)` and `[1.20.2,)` (Replace with the minecraft versions your mod supports)
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. 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.
7) Replace the contents of `LICENSE` with your mod license 7) Replace the contents of `LICENSE` with your mod license
8) Replace the contents of `readme.md` with your mod readme 8) Replace the contents of `readme.md` with your mod readme

View File

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