Advertisement
nmotter

build.gradle

Nov 14th, 2024 (edited)
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.60 KB | None | 0 0
  1. buildscript {
  2. repositories {
  3. // These repositories are only for Gradle plugins, put any other repositories in the repository block further below
  4. maven { url = 'https://maven.minecraftforge.net' }
  5. mavenCentral()
  6. }
  7. dependencies {
  8. classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
  9. }
  10. }
  11. // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
  12. plugins {
  13. id 'eclipse'
  14. id 'maven-publish'
  15. }
  16. apply plugin: 'net.minecraftforge.gradle'
  17.  
  18.  
  19. version = '1.0'
  20. group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
  21. archivesBaseName = 'modid'
  22.  
  23. // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
  24. java.toolchain.languageVersion = JavaLanguageVersion.of(17)
  25.  
  26. println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
  27. minecraft {
  28. // The mappings can be changed at any time and must be in the following format.
  29. // Channel: Version:
  30. // official MCVersion Official field/method names from Mojang mapping files
  31. // parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
  32. //
  33. // You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
  34. // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
  35. //
  36. // Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
  37. // Additional setup is needed to use their mappings: https://github.com/ParchmentMC/Parchment/wiki/Getting-Started
  38. //
  39. // Use non-default mappings at your own risk. They may not always work.
  40. // Simply re-run your setup task after changing the mappings to update your workspace.
  41. mappings channel: 'official', version: '1.18.2'
  42.  
  43. // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.
  44.  
  45. // Default run configurations.
  46. // These can be tweaked, removed, or duplicated as needed.
  47. runs {
  48. client {
  49. workingDirectory project.file('run')
  50.  
  51. // Recommended logging data for a userdev environment
  52. // The markers can be added/remove as needed separated by commas.
  53. // "SCAN": For mods scan.
  54. // "REGISTRIES": For firing of registry events.
  55. // "REGISTRYDUMP": For getting the contents of all registries.
  56. property 'forge.logging.markers', 'REGISTRIES'
  57.  
  58. // Recommended logging level for the console
  59. // You can set various levels here.
  60. // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
  61. property 'forge.logging.console.level', 'debug'
  62.  
  63. // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
  64. property 'forge.enabledGameTestNamespaces', 'examplemod'
  65.  
  66. mods {
  67. examplemod {
  68. source sourceSets.main
  69. }
  70. }
  71.  
  72. //You have to set mixin propert if you want to run playerAnimator in development environment.
  73. property 'mixin.env.remapRefMap', 'true'
  74. property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
  75. }
  76.  
  77. server {
  78. workingDirectory project.file('run')
  79.  
  80. property 'forge.logging.markers', 'REGISTRIES'
  81.  
  82. property 'forge.logging.console.level', 'debug'
  83.  
  84. // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
  85. property 'forge.enabledGameTestNamespaces', 'examplemod'
  86.  
  87. mods {
  88. examplemod {
  89. source sourceSets.main
  90. }
  91. }
  92. //Add this to the server too.
  93. property 'mixin.env.remapRefMap', 'true'
  94. property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
  95. }
  96.  
  97. // This run config launches GameTestServer and runs all registered gametests, then exits.
  98. // By default, the server will crash when no gametests are provided.
  99. // The gametest system is also enabled by default for other run configs under the /test command.
  100. gameTestServer {
  101. workingDirectory project.file('run')
  102.  
  103. // Recommended logging data for a userdev environment
  104. // The markers can be added/remove as needed separated by commas.
  105. // "SCAN": For mods scan.
  106. // "REGISTRIES": For firing of registry events.
  107. // "REGISTRYDUMP": For getting the contents of all registries.
  108. property 'forge.logging.markers', 'REGISTRIES'
  109.  
  110. // Recommended logging level for the console
  111. // You can set various levels here.
  112. // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
  113. property 'forge.logging.console.level', 'debug'
  114.  
  115. // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
  116. property 'forge.enabledGameTestNamespaces', 'examplemod'
  117.  
  118. mods {
  119. examplemod {
  120. source sourceSets.main
  121. }
  122. }
  123. }
  124.  
  125. data {
  126. workingDirectory project.file('run')
  127.  
  128. property 'forge.logging.markers', 'REGISTRIES'
  129.  
  130. property 'forge.logging.console.level', 'debug'
  131.  
  132. // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
  133. args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
  134.  
  135. mods {
  136. examplemod {
  137. source sourceSets.main
  138. }
  139. }
  140. }
  141. }
  142. }
  143.  
  144. // Include resources generated by data generators.
  145. sourceSets.main.resources { srcDir 'src/generated/resources' }
  146.  
  147. repositories {
  148. // Put repositories for dependencies here
  149. // ForgeGradle automatically adds the Forge maven and Maven Central for you
  150.  
  151. // If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
  152. // flatDir {
  153. // dir 'libs'
  154. // }
  155. maven {
  156. url "https://cursemaven.com"
  157. content {
  158. includeGroup "curse.maven"
  159. }
  160. }
  161. maven {
  162. name "KosmX's maven"
  163. url 'https://maven.kosmx.dev/'
  164. }
  165. }
  166.  
  167. dependencies {
  168. // Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed
  169. // that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
  170. // The userdev artifact is a special name and will get all sorts of transformations applied to it.
  171. minecraft 'net.minecraftforge:forge:1.18.2-40.2.21'
  172.  
  173. // Real mod deobf dependency examples - these get remapped to your current mappings
  174. // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
  175. // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
  176. // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency
  177.  
  178. // Examples using mod jars from ./libs
  179. // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
  180.  
  181. // For more info...
  182. // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
  183. // http://www.gradle.org/docs/current/userguide/dependency_management.html
  184.  
  185. implementation fg.deobf("curse.maven:bendy-lib-623373:3930014")
  186. implementation fg.deobf("curse.maven:playeranimator-658587:4418152")
  187. implementation "curse.maven:geckoanimfix-959388:5018199"
  188. implementation fg.deobf("curse.maven:geckolib-388172:4181370")
  189. implementation fg.deobf("curse.maven:swem-582697:4870246")
  190. }
  191.  
  192. // Example for how to get properties into the manifest for reading at runtime.
  193. jar {
  194. manifest {
  195. attributes([
  196. "Specification-Title" : "examplemod",
  197. "Specification-Vendor" : "examplemodsareus",
  198. "Specification-Version" : "1", // We are version 1 of ourselves
  199. "Implementation-Title" : project.name,
  200. "Implementation-Version" : project.jar.archiveVersion,
  201. "Implementation-Vendor" : "examplemodsareus",
  202. "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  203. ])
  204. }
  205. }
  206.  
  207. // Example configuration to allow publishing using the maven-publish plugin
  208. // This is the preferred method to reobfuscate your jar file
  209. jar.finalizedBy('reobfJar')
  210. // However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
  211. // publish.dependsOn('reobfJar')
  212.  
  213. publishing {
  214. publications {
  215. mavenJava(MavenPublication) {
  216. artifact jar
  217. }
  218. }
  219. repositories {
  220. maven {
  221. url "file://${project.projectDir}/mcmodsrepo"
  222. }
  223. }
  224. }
  225.  
  226. tasks.withType(JavaCompile).configureEach {
  227. options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
  228. }
  229.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement