MrGise

Untitled

Aug 6th, 2025
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.31 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. args '--uuid', 'c3f4e025-5e04-4ea4-87b1-c35092bb7909'
  87. args '--username=MrGise'
  88. // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
  89. property 'forge.enabledGameTestNamespaces', mod_id
  90. }
  91.  
  92. server {
  93. property 'forge.enabledGameTestNamespaces', mod_id
  94. args '--nogui'
  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. property 'forge.enabledGameTestNamespaces', mod_id
  102. }
  103.  
  104. data {
  105. // example of overriding the workingDirectory set in configureEach above
  106. workingDirectory project.file('run-data')
  107.  
  108. // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
  109. args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
  110. }
  111. }
  112. }
  113.  
  114. // Include resources generated by data generators.
  115. sourceSets.main.resources { srcDir 'src/generated/resources' }
  116.  
  117. repositories {
  118. exclusiveContent {
  119. forRepository {
  120. maven {
  121. name = "Modrinth"
  122. url = "https://api.modrinth.com/maven"
  123. }
  124. }
  125. forRepositories(fg.repository)
  126. filter {
  127. includeGroup "maven.modrinth"
  128. }
  129. }
  130. // Put repositories for dependencies here
  131. // ForgeGradle automatically adds the Forge maven and Maven Central for you
  132.  
  133. // If you have mod jar dependencies in ./libs, you can declare them as a repository like so.
  134. // See https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver
  135. // flatDir {
  136. // dir 'libs'
  137. // }
  138. flatDir {
  139. dirs 'libs'
  140. }
  141. }
  142.  
  143. dependencies {
  144. // Specify the version of Minecraft to use.
  145. // Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
  146. // The "userdev" classifier will be requested and setup by ForgeGradle.
  147. // If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
  148. // then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
  149. minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
  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. implementation fg.debof("maven.modrinth:create:create-1.20.1-6.0.6")
  158.  
  159. // Example mod dependency using a mod jar from ./libs with a flat dir repository
  160. // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
  161. // The group id is ignored when searching -- in this case, it is "blank"
  162. // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
  163.  
  164. // For more info:
  165. // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
  166. // http://www.gradle.org/docs/current/userguide/dependency_management.html
  167.  
  168. }
  169.  
  170. // This block of code expands all declared replace properties in the specified resource targets.
  171. // A missing property will result in an error. Properties are expanded using ${} Groovy notation.
  172. // When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
  173. // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
  174. tasks.named('processResources', ProcessResources).configure {
  175. var replaceProperties = [
  176. minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
  177. forge_version: forge_version, forge_version_range: forge_version_range,
  178. loader_version_range: loader_version_range,
  179. mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
  180. mod_authors: mod_authors, mod_description: mod_description,
  181. ]
  182. inputs.properties replaceProperties
  183.  
  184. filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
  185. expand replaceProperties + [project: project]
  186. }
  187. }
  188.  
  189. // Example for how to get properties into the manifest for reading at runtime.
  190. tasks.named('jar', Jar).configure {
  191. manifest {
  192. attributes([
  193. 'Specification-Title' : mod_id,
  194. 'Specification-Vendor' : mod_authors,
  195. 'Specification-Version' : '1', // We are version 1 of ourselves
  196. 'Implementation-Title' : project.name,
  197. 'Implementation-Version' : project.jar.archiveVersion,
  198. 'Implementation-Vendor' : mod_authors,
  199. 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  200. ])
  201. }
  202.  
  203. // This is the preferred method to reobfuscate your jar file
  204. finalizedBy 'reobfJar'
  205. }
  206.  
  207. // 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:
  208. // tasks.named('publish').configure {
  209. // dependsOn 'reobfJar'
  210. // }
  211.  
  212. // Example configuration to allow publishing using the maven-publish plugin
  213. publishing {
  214. publications {
  215. register('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.  
Add Comment
Please, Sign In to add comment