Advertisement
NovaMachina

NeoForge 1.20.2 build.gradle

Oct 31st, 2023 (edited)
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 6.21 KB | None | 0 0
  1. plugins {
  2.     id 'java-library'
  3.     id 'eclipse'
  4.     id 'idea'
  5.     id 'maven-publish'
  6.     id 'net.neoforged.gradle.userdev' version '7.0.5'
  7. }
  8.  
  9. version = mod_version
  10. group = mod_group_id
  11.  
  12. repositories {
  13.     mavenLocal()
  14. }
  15.  
  16. base {
  17.     archivesName = mod_id
  18. }
  19.  
  20. // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
  21. java.toolchain.languageVersion = JavaLanguageVersion.of(17)
  22.  
  23. //minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
  24. //minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager
  25.  
  26. // Default run configurations.
  27. // These can be tweaked, removed, or duplicated as needed.
  28. runs {
  29.     // applies to all the run configs below
  30.     configureEach {
  31.         // Recommended logging data for a userdev environment
  32.         // The markers can be added/remove as needed separated by commas.
  33.         // "SCAN": For mods scan.
  34.         // "REGISTRIES": For firing of registry events.
  35.         // "REGISTRYDUMP": For getting the contents of all registries.
  36.         systemProperty 'forge.logging.markers', 'REGISTRIES'
  37.  
  38.         // Recommended logging level for the console
  39.         // You can set various levels here.
  40.         // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
  41.         systemProperty 'forge.logging.console.level', 'debug'
  42.  
  43.         modSource project.sourceSets.main
  44.     }
  45.  
  46.     client {
  47.         // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
  48.         systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
  49.     }
  50.  
  51.     server {
  52.         systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
  53.         programArgument '--nogui'
  54.     }
  55.  
  56.     // This run config launches GameTestServer and runs all registered gametests, then exits.
  57.     // By default, the server will crash when no gametests are provided.
  58.     // The gametest system is also enabled by default for other run configs under the /test command.
  59.     gameTestServer {
  60.         systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
  61.     }
  62.  
  63.     data {
  64.         // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
  65.         // workingDirectory project.file('run-data')
  66.  
  67.         // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
  68.         programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
  69.     }
  70. }
  71.  
  72. // Include resources generated by data generators.
  73. sourceSets.main.resources { srcDir 'src/generated/resources' }
  74.  
  75.  
  76. dependencies {
  77.     // Specify the version of Minecraft to use.
  78.     // Depending on the plugin applied there are several options. We will assume you applied the userdev plugin as shown above.
  79.     // The group for userdev is net.neoforged, the module name is neoforge, and the version is the same as the neoforge version.
  80.     // You can however also use the vanilla plugin (net.neoforged.gradle.vanilla) to use a version of Minecraft without the neoforge loader.
  81.     // And its provides the option to then use net.minecraft as the group, and one of; client, server or joined as the module name, plus the game version as version.
  82.     // For all intends and purposes: You can treat this dependency as if it is a normal library you would use.
  83.     implementation "net.neoforged:neoforge:${neo_version}"
  84.  
  85.     // Example mod dependency with JEI
  86.     // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
  87.     // compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
  88.     // compileOnly "mezz.jei:jei-${mc_version}-forge-api:${jei_version}"
  89.     // runtimeOnly "mezz.jei:jei-${mc_version}-forge:${jei_version}"
  90.  
  91.     // Example mod dependency using a mod jar from ./libs with a flat dir repository
  92.     // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
  93.     // The group id is ignored when searching -- in this case, it is "blank"
  94.     // implementation "blank:coolmod-${mc_version}:${coolmod_version}"
  95.  
  96.     // Example mod dependency using a file as dependency
  97.     // implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar")
  98.  
  99.     // Example project dependency using a sister or child project:
  100.     // implementation project(":myproject")
  101.  
  102.     // For more info:
  103.     // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
  104.     // http://www.gradle.org/docs/current/userguide/dependency_management.html
  105. }
  106.  
  107. // This block of code expands all declared replace properties in the specified resource targets.
  108. // A missing property will result in an error. Properties are expanded using ${} Groovy notation.
  109. // When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
  110. // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
  111. tasks.withType(ProcessResources).configureEach {
  112.     var replaceProperties = [
  113.             minecraft_version   : minecraft_version, minecraft_version_range: minecraft_version_range,
  114.             neo_version         : neo_version, neo_version_range: neo_version_range,
  115.             loader_version_range: loader_version_range,
  116.             mod_id              : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
  117.             mod_authors         : mod_authors, mod_description: mod_description, pack_format_number: pack_format_number,
  118.     ]
  119.     inputs.properties replaceProperties
  120.  
  121.     filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
  122.         expand replaceProperties + [project: project]
  123.     }
  124. }
  125.  
  126. // Example configuration to allow publishing using the maven-publish plugin
  127. publishing {
  128.     publications {
  129.         register('mavenJava', MavenPublication) {
  130.             from components.java
  131.         }
  132.     }
  133.     repositories {
  134.         maven {
  135.             url "file://${project.projectDir}/repo"
  136.         }
  137.     }
  138. }
  139.  
  140. tasks.withType(JavaCompile).configureEach {
  141.     options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
  142. }
  143.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement