// build.gradle for The Cursed Creaking Mod (for NeoForge 1.21)
// Basic project setup
plugins {
id 'java'
// 'net.neoforged.moddev' is applied here. Its version is managed in settings.gradle.
id 'net.neoforged.moddev'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}
group = 'net.yourcompany.cursedcreaking'
version = '1.0.0'
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
// NeoForge/ModDev configuration (Corrected from 'minecraft' to 'neoforge')
minecraft { // THIS IS THE CORRECT BLOCK NAME for NeoForge 1.21+
version = "1.21-21.0.0-beta" // NeoForge version for Minecraft 1.21
// mappings channel: "official", version: "1.21" // Mappings are typically set by the plugin itself or a separate block like 'parchment'
runs {
client {
client() // Configures a client run
workingDirectory project.file('run')
property 'neoforge.logging.console.level', 'debug'
}
server {
server() // Configures a server run
workingDirectory project.file('run_server')
property 'neoforge.logging.console.level', 'debug'
args '--nogui'
}
data { // Data generation run configuration
data() // Configures a data generation run
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
programArguments.addAll '--mod', 'cursedcreaking', '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
systemProperty 'neoforge.logging.console.level', 'debug'
}
}
}
// Repositories where Gradle can find necessary libraries
repositories {
mavenCentral() // Standard Maven repository
maven {
url "https://maven.neoforged.net/releases" // NeoForge's official Maven repository for core libraries
}
maven {
url "https://repo.spongepowered.org/maven" // Maven repository for the mixin library
}
}
// Define external dependencies for your mod
dependencies {
// This is the core NeoForge dependency, essential for modding Minecraft
// This version must match the 'neoforge.version' in the 'neoforge' block above.
implementation "net.neoforged:neoforge:${neoforge.version}"
// Dependency for IOUtils used in CursedCreakingModel.java
implementation 'org.apache.commons:commons-io:1.3.2'
}
// Configure the ShadowJar plugin for creating a fat JAR (if needed for dependencies)
shadowJar {
archiveClassifier.set('dev') // Classifier for the development JAR
}
// Ensure that the 'jar' task creates a distributable JAR
jar {
manifest {
attributes([
"Specification-Title": project.name,
"Specification-Vendor": "Your Company",
"Specification-Version": "1",
"Implementation-Title": project.name,
"Implementation-Version": version,
"Implementation-Vendor": "Your Company",
"FMLModType": "GAMELIBRARY",
"NeoForge-Mod-Container": "net.yourcompany.cursedcreaking.CursedCreakingMod"
])
}
}
// Tasks to build the mod and prepare for launch
tasks.jar.finalizedBy('reobfJar')
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
shows this error
* Could not find method minecraft() for arguments [build_5kr751j262vwv8ie8i5iazhjg$_run_closure1@47eb072b] on root project 'the_cursed_creaking' of type org.gradle.api.Project