|
| 1 | +plugins { |
| 2 | + id 'idea' |
| 3 | + id 'java-library' |
| 4 | + id 'maven-publish' |
| 5 | + id 'net.neoforged.moddev' version '2.0.78' |
| 6 | +} |
| 7 | + |
| 8 | +tasks.named('wrapper', Wrapper).configure { |
| 9 | + // Define wrapper values here so as to not have to always do so when updating gradlew.properties. |
| 10 | + // Switching this to Wrapper.DistributionType.ALL will download the full gradle sources that comes with |
| 11 | + // documentation attached on cursor hover of gradle classes and methods. However, this comes with increased |
| 12 | + // file size for Gradle. If you do switch this to ALL, run the Gradle wrapper task twice afterwards. |
| 13 | + // (Verify by checking gradle/wrapper/gradle-wrapper.properties to see if distributionUrl now points to `-all`) |
| 14 | + distributionType = Wrapper.DistributionType.BIN |
| 15 | +} |
| 16 | + |
| 17 | +version = mod_version |
| 18 | + |
| 19 | +group = mod_group_id |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +base { |
| 24 | + archivesName = mod_id |
| 25 | +} |
| 26 | + |
| 27 | +// Mojang ships Java 21 to end users starting in 1.20.5, so mods should target Java 21. |
| 28 | +java.toolchain.languageVersion = JavaLanguageVersion.of(21) |
| 29 | + |
| 30 | + |
| 31 | +neoForge { |
| 32 | + // Specify the version of NeoForge to use. |
| 33 | + version = project.neo_version |
| 34 | + |
| 35 | + parchment { |
| 36 | + mappingsVersion = project.parchment_mappings_version |
| 37 | + minecraftVersion = project.parchment_minecraft_version |
| 38 | + } |
| 39 | + |
| 40 | + validateAccessTransformers = true |
| 41 | + |
| 42 | + // This line is optional. Access Transformers are automatically detected |
| 43 | + // accessTransformers = project.files('src/main/resources/META-INF/accesstransformer.cfg') |
| 44 | + |
| 45 | + // Default run configurations. |
| 46 | + // These can be tweaked, removed, or duplicated as needed. |
| 47 | + runs { |
| 48 | + client { |
| 49 | + client() |
| 50 | + |
| 51 | + // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. |
| 52 | + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id |
| 53 | + } |
| 54 | + |
| 55 | + server { |
| 56 | + server() |
| 57 | + programArgument '--nogui' |
| 58 | + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id |
| 59 | + } |
| 60 | + |
| 61 | + // This run config launches GameTestServer and runs all registered gametests, then exits. |
| 62 | + // By default, the server will crash when no gametests are provided. |
| 63 | + // The gametest system is also enabled by default for other run configs under the /test command. |
| 64 | + gameTestServer { |
| 65 | + type = "gameTestServer" |
| 66 | + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id |
| 67 | + } |
| 68 | + |
| 69 | + data { |
| 70 | + data() |
| 71 | + |
| 72 | + // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it |
| 73 | + // gameDirectory = project.file('run-data') |
| 74 | + |
| 75 | + // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. |
| 76 | + programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() |
| 77 | + } |
| 78 | + |
| 79 | + // applies to all the run configs above |
| 80 | + configureEach { |
| 81 | + // Recommended logging data for a userdev environment |
| 82 | + // The markers can be added/remove as needed separated by commas. |
| 83 | + // "SCAN": For mods scan. |
| 84 | + // "REGISTRIES": For firing of registry events. |
| 85 | + // "REGISTRYDUMP": For getting the contents of all registries. |
| 86 | + systemProperty 'forge.logging.markers', 'REGISTRIES' |
| 87 | + |
| 88 | + // Recommended logging level for the console |
| 89 | + // You can set various levels here. |
| 90 | + // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels |
| 91 | + logLevel = org.slf4j.event.Level.WARN |
| 92 | + |
| 93 | + |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + mods { |
| 98 | + // define mod <-> source bindings |
| 99 | + // these are used to tell the game which sources are for which mod |
| 100 | + // mostly optional in a single mod project |
| 101 | + // but multi mod projects should define one per mod |
| 102 | + "${mod_id}" { |
| 103 | + sourceSet(sourceSets.main) |
| 104 | + } |
| 105 | + } |
| 106 | +} |
| 107 | +// Include resources generated by data generators. |
| 108 | +sourceSets.main.resources { srcDir 'src/generated/resources' } |
| 109 | + |
| 110 | +// Sets up a dependency configuration called 'localRuntime'. |
| 111 | +// This configuration should be used instead of 'runtimeOnly' to declare |
| 112 | +// a dependency that will be present for runtime testing but that is |
| 113 | +// "optional", meaning it will not be pulled by dependents of this mod. |
| 114 | +configurations { |
| 115 | + runtimeClasspath.extendsFrom localRuntime |
| 116 | +} |
| 117 | + |
| 118 | +repositories { |
| 119 | + mavenLocal() |
| 120 | + |
| 121 | + maven { url = "https://maven.createmod.net" } // Create, Ponder, Flywheel |
| 122 | + maven { url = "https://mvn.devos.one/snapshots" } // Registrate |
| 123 | + //JEI |
| 124 | + |
| 125 | + maven { |
| 126 | + |
| 127 | + name = "Jared's maven" |
| 128 | + url = "https://maven.blamejared.com/" |
| 129 | + } |
| 130 | + maven { |
| 131 | + // location of a maven mirror for JEI files, as a fallback |
| 132 | + name = "ModMaven" |
| 133 | + url = "https://modmaven.dev" |
| 134 | + } |
| 135 | + |
| 136 | + maven { |
| 137 | + name = "Modrinth" |
| 138 | + url = "https://api.modrinth.com/maven" |
| 139 | + } |
| 140 | + |
| 141 | + //curios |
| 142 | + maven { |
| 143 | + url = "https://maven.theillusivec4.top/" |
| 144 | + } |
| 145 | + |
| 146 | + maven { url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" } // ForgeConfigAPIPort |
| 147 | + |
| 148 | +} |
| 149 | + |
| 150 | +dependencies { |
| 151 | + implementation("com.simibubi.create:create-${minecraft_version}:${create_version}:slim"){ transitive = false } |
| 152 | + implementation("net.createmod.ponder:Ponder-NeoForge-${minecraft_version}:${ponder_version}") |
| 153 | + compileOnly("dev.engine-room.flywheel:flywheel-neoforge-api-${minecraft_version}:${flywheel_version}") |
| 154 | + runtimeOnly("dev.engine-room.flywheel:flywheel-neoforge-${minecraft_version}:${flywheel_version}") |
| 155 | + implementation("com.tterrag.registrate:Registrate:${registrate_version}") |
| 156 | + |
| 157 | + // JEI |
| 158 | + compileOnly("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}") |
| 159 | + compileOnly("mezz.jei:jei-${minecraft_version}-neoforge-api:${jei_version}") |
| 160 | + runtimeOnly("mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}") |
| 161 | + |
| 162 | +} |
| 163 | + |
| 164 | +// This block of code expands all declared replace properties in the specified resource targets. |
| 165 | +// A missing property will result in an error. Properties are expanded using ${} Groovy notation. |
| 166 | +// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments. |
| 167 | +// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html |
| 168 | +tasks.withType(ProcessResources).configureEach { |
| 169 | + var replaceProperties = [ |
| 170 | + minecraft_version : minecraft_version, |
| 171 | + minecraft_version_range: minecraft_version_range, |
| 172 | + neo_version : neo_version, |
| 173 | + neo_version_range : neo_version_range, |
| 174 | + loader_version_range : loader_version_range, |
| 175 | + mod_id : mod_id, |
| 176 | + mod_name : mod_name, |
| 177 | + mod_license : mod_license, |
| 178 | + mod_version : mod_version, |
| 179 | + mod_authors : mod_authors, |
| 180 | + mod_description : mod_description |
| 181 | + ] |
| 182 | + inputs.properties replaceProperties |
| 183 | + |
| 184 | + filesMatching(['META-INF/neoforge.mods.toml']) { |
| 185 | + expand replaceProperties |
| 186 | + } |
| 187 | +} |
| 188 | + |
| 189 | +// Example configuration to allow publishing using the maven-publish plugin |
| 190 | +publishing { |
| 191 | + publications { |
| 192 | + register('mavenJava', MavenPublication) { |
| 193 | + from components.java |
| 194 | + } |
| 195 | + } |
| 196 | + repositories { |
| 197 | + maven { |
| 198 | + url "file://${project.projectDir}/repo" |
| 199 | + } |
| 200 | + } |
| 201 | +} |
| 202 | + |
| 203 | +tasks.withType(JavaCompile).configureEach { |
| 204 | + options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation |
| 205 | +} |
| 206 | + |
| 207 | +// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior. |
| 208 | +idea { |
| 209 | + module { |
| 210 | + downloadSources = true |
| 211 | + downloadJavadoc = true |
| 212 | + } |
| 213 | +} |
0 commit comments