Guest User

Untitled

a guest
Nov 13th, 2023
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.24 KB | None | 0 0
  1. plugins {
  2. id 'eclipse'
  3. id 'idea'
  4. id 'maven-publish'
  5. id 'net.minecraftforge.gradle' version '[6.0,6.2)'
  6. id 'org.parchmentmc.librarian.forgegradle' version '1.+'
  7.  
  8. }
  9.  
  10. version = mod_version
  11. group = mod_group_id
  12.  
  13. base {
  14. archivesName = mod_id
  15. }
  16.  
  17. // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
  18. java.toolchain.languageVersion = JavaLanguageVersion.of(17)
  19.  
  20. println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
  21. minecraft {
  22. // The mappings can be changed at any time and must be in the following format.
  23. // Channel: Version:
  24. // official MCVersion Official field/method names from Mojang mapping files
  25. // parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
  26. //
  27. // You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
  28. // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
  29. //
  30. // Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
  31. // Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started
  32. //
  33. // Use non-default mappings at your own risk. They may not always work.
  34. // Simply re-run your setup task after changing the mappings to update your workspace.
  35. mappings channel: mapping_channel, version: mapping_version
  36.  
  37. // When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
  38. // In most cases, it is not necessary to enable.
  39. // enableEclipsePrepareRuns = true
  40. // enableIdeaPrepareRuns = true
  41.  
  42. // This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
  43. // It is REQUIRED to be set to true for this template to function.
  44. // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
  45. copyIdeResources = true
  46.  
  47. // When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
  48. // The folder name can be set on a run configuration using the "folderName" property.
  49. // By default, the folder name of a run configuration is the name of the Gradle project containing it.
  50. // generateRunFolders = true
  51.  
  52. // This property enables access transformers for use in development.
  53. // They will be applied to the Minecraft artifact.
  54. // The access transformer file can be anywhere in the project.
  55. // However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
  56. // This default location is a best practice to automatically put the file in the right place in the final jar.
  57. // See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
  58. // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
  59.  
  60. // Default run configurations.
  61. // These can be tweaked, removed, or duplicated as needed.
  62. runs {
  63. // applies to all the run configs below
  64. configureEach {
  65. workingDirectory project.file('run')
  66.  
  67. // Recommended logging data for a userdev environment
  68. // The markers can be added/remove as needed separated by commas.
  69. // "SCAN": For mods scan.
  70. // "REGISTRIES": For firing of registry events.
  71. // "REGISTRYDUMP": For getting the contents of all registries.
  72. property 'forge.logging.markers', 'REGISTRIES'
  73.  
  74. // Recommended logging level for the console
  75. // You can set various levels here.
  76. // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
  77. property 'forge.logging.console.level', 'debug'
  78.  
  79. mods {
  80. "${mod_id}" {
  81. source sourceSets.main
  82. }
  83. }
  84. }
  85.  
  86. client {
  87. // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
  88. property 'forge.enabledGameTestNamespaces', mod_id
  89. }
  90.  
  91. server {
  92. property 'forge.enabledGameTestNamespaces', mod_id
  93. args '--nogui'
  94. }
  95.  
  96. // This run config launches GameTestServer and runs all registered gametests, then exits.
  97. // By default, the server will crash when no gametests are provided.
  98. // The gametest system is also enabled by default for other run configs under the /test command.
  99. gameTestServer {
  100. property 'forge.enabledGameTestNamespaces', mod_id
  101. }
  102.  
  103. data {
  104. // example of overriding the workingDirectory set in configureEach above
  105. workingDirectory project.file('run-data')
  106.  
  107. // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
  108. args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
  109. }
  110. }
  111. }
  112.  
  113. // Include resources generated by data generators.
  114. sourceSets.main.resources { srcDir 'src/generated/resources' }
  115.  
  116. repositories {
  117.  
  118.  
  119. maven {
  120. url "https://cursemaven.com"
  121. content {
  122. includeGroup "curse.maven"
  123. }
  124.  
  125. }
  126. // Put repositories for dependencies here
  127. // ForgeGradle automatically adds the Forge maven and Maven Central for you
  128.  
  129. // If you have mod jar dependencies in ./libs, you can declare them as a repository like so.
  130.  
  131. // flatDir {
  132. // dir 'libs'
  133. // }
  134. }
  135.  
  136. dependencies {
  137. // Specify the version of Minecraft to use.
  138. // Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
  139. // The "userdev" classifier will be requested and setup by ForgeGradle.
  140. // If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
  141. // then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
  142. minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
  143. implementation fg.deobf("curse.maven:identity-391390:4625253")
  144. implementation fg.deobf("curse.maven:architectury-api-419699:4663010")
  145.  
  146. implementation(fg.deobf("curse.maven:alexs-mobs-426558:4745999"))
  147. implementation fg.deobf("curse.maven:alexs-caves-924854:4852042")
  148. implementation fg.deobf("curse.maven:citadel-331936:4848887")
  149. implementation fg.deobf("curse.maven:ctm-267602:2642375")
  150.  
  151. // Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
  152. // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
  153. // compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}")
  154. // compileOnly fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}")
  155. // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}")
  156.  
  157. // Example mod dependency using a mod jar from ./libs with a flat dir repository
  158. // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
  159. // The group id is ignored when searching -- in this case, it is "blank"
  160. // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
  161.  
  162. // For more info:
  163. // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
  164. // http://www.gradle.org/docs/current/userguide/dependency_management.html
  165. }
  166.  
  167. // This block of code expands all declared replace properties in the specified resource targets.
  168. // A missing property will result in an error. Properties are expanded using ${} Groovy notation.
  169. // When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
  170. // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
  171. tasks.named('processResources', ProcessResources).configure {
  172. var replaceProperties = [
  173. minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
  174. forge_version: forge_version, forge_version_range: forge_version_range,
  175. loader_version_range: loader_version_range,
  176. mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
  177. mod_authors: mod_authors, mod_description: mod_description,
  178. ]
  179. inputs.properties replaceProperties
  180.  
  181. filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
  182. expand replaceProperties + [project: project]
  183. }
  184. }
  185.  
  186. // Example for how to get properties into the manifest for reading at runtime.
  187. tasks.named('jar', Jar).configure {
  188. manifest {
  189. attributes([
  190. 'Specification-Title' : mod_id,
  191. 'Specification-Vendor' : mod_authors,
  192. 'Specification-Version' : '1', // We are version 1 of ourselves
  193. 'Implementation-Title' : project.name,
  194. 'Implementation-Version' : project.jar.archiveVersion,
  195. 'Implementation-Vendor' : mod_authors,
  196. 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  197. ])
  198. }
  199.  
  200. // This is the preferred method to reobfuscate your jar file
  201. finalizedBy 'reobfJar'
  202. }
  203.  
  204. // 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:
  205. // tasks.named('publish').configure {
  206. // dependsOn 'reobfJar'
  207. // }
  208.  
  209. // Example configuration to allow publishing using the maven-publish plugin
  210. publishing {
  211. publications {
  212. register('mavenJava', MavenPublication) {
  213. artifact jar
  214. }
  215. }
  216. repositories {
  217. maven {
  218. url "file://${project.projectDir}/mcmodsrepo"
  219. }
  220. }
  221. }
  222.  
  223. tasks.withType(JavaCompile).configureEach {
  224. options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
  225. }
  226.  
Add Comment
Please, Sign In to add comment