Guest User

Untitled

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