Add constants to buildscript to allow easier setup
Refactor to create constants for common values to be replaced Signed-off-by: Walker Selby <git@walkerselby.com>
This commit is contained in:
parent
cc5c1a8d1c
commit
7e8fa83e5a
4 changed files with 51 additions and 26 deletions
10
README.md
10
README.md
|
@ -2,10 +2,14 @@
|
|||
|
||||
**For other templates, do check out the [other branches of this repository](https://github.com/romangraef/Forge1.8.9Template/branches/all)**
|
||||
|
||||
To get started, clone this repository and replace all references to `examplemod` or `com.example` with your own names.
|
||||
To get started, clone this repository.
|
||||
In `build.gradle.kts`, replace the values of `baseGroup` and `group` with your own names.
|
||||
In `settings.gradle.kts` change `rootProject.name` to your desired mod id.
|
||||
|
||||
The `com.example` package needs to be renamed to match the value of `baseGroup`.
|
||||
|
||||
If you don't want mixins (which allow for modifying vanilla code), then you can remove the references to mixins from
|
||||
the `build.gradle.kts`, delete the `mixins.examplemod.json` and the `com.example.mixin` package.
|
||||
the `build.gradle.kts` at the lines specified with comments and the `com.example.mixin` package.
|
||||
|
||||
This project uses [DevAuth](https://github.com/DJtheRedstoner/DevAuth) per default, so you can log in using your real
|
||||
minecraft account. If you don't need that, you can remove it from the buildscript.
|
||||
|
@ -15,7 +19,7 @@ from [here](https://adoptium.net/temurin/releases) (or use your own downloads).
|
|||
|
||||
When you import your project into IntelliJ, you need to set the gradle jvm to the Java 17 JDK in the gradle tab, and the
|
||||
Project SDK to the Java 1.8 JDK. Then click on the sync button in IntelliJ, and it should create a run task
|
||||
called `Minecraft Client`. If it doesn't then try relaunching your IntelliJ. **Warning for Mac users**: You might have to remove the `-XStartOnFirstThread` vm argument from your run configuration. In the future, that should be handled by the plugin, but for now you'll probably have to do that manually.
|
||||
called `Minecraft Client`. If it doesn't then try relaunching your IntelliJ. **Warning for Mac users**: You might have to remove the `-XStartOnFirstThread` vm argument from your run configuration. In the future, that should be handled by the plugin, but for now you'll probably have to do that manually.
|
||||
|
||||
To export your project, run the `gradle build` task, and give other people the
|
||||
file `build/libs/<modid>-<version>.jar`. Ignore the jars in the `build/badjars` folder. Those are intermediary jars that
|
||||
|
|
|
@ -6,8 +6,13 @@ plugins {
|
|||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||
}
|
||||
|
||||
group = "com.example.archloomtemplate"
|
||||
version = "1.0.0"
|
||||
//Constants:
|
||||
|
||||
val baseGroup: String by project
|
||||
val mcVersion: String by project
|
||||
val version: String by project
|
||||
val mixinGroup = "$baseGroup.mixin"
|
||||
val modid = rootProject.name
|
||||
|
||||
// Toolchains:
|
||||
java {
|
||||
|
@ -23,17 +28,17 @@ loom {
|
|||
property("mixin.debug", "true")
|
||||
property("asmhelper.verbose", "true")
|
||||
arg("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker")
|
||||
arg("--mixin", "mixins.examplemod.json")
|
||||
arg("--mixin", "mixins.$modid.json")
|
||||
}
|
||||
}
|
||||
forge {
|
||||
pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter())
|
||||
// If you don't want mixins, remove this lines
|
||||
mixinConfig("mixins.examplemod.json")
|
||||
mixinConfig("mixins.$modid.json")
|
||||
}
|
||||
// If you don't want mixins, remove these lines
|
||||
mixin {
|
||||
defaultRefmapName.set("mixins.examplemod.refmap.json")
|
||||
defaultRefmapName.set("mixins.$modid.refmap.json")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,17 +82,30 @@ tasks.withType(JavaCompile::class) {
|
|||
}
|
||||
|
||||
tasks.withType(Jar::class) {
|
||||
archiveBaseName.set("examplemod")
|
||||
archiveBaseName.set(modid)
|
||||
manifest.attributes.run {
|
||||
this["FMLCorePluginContainsFMLMod"] = "true"
|
||||
this["ForceLoadAsMod"] = "true"
|
||||
|
||||
// If you don't want mixins, remove these lines
|
||||
this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker"
|
||||
this["MixinConfigs"] = "mixins.examplemod.json"
|
||||
this["MixinConfigs"] = "mixins.$modid.json"
|
||||
}
|
||||
}
|
||||
|
||||
tasks.processResources {
|
||||
inputs.property("version", project.version)
|
||||
inputs.property("mcversion", mcVersion)
|
||||
inputs.property("modid", modid)
|
||||
inputs.property("mixinGroup", mixinGroup)
|
||||
|
||||
filesMatching(listOf("mcmod.info", "mixins.$modid.json")) {
|
||||
expand(inputs.properties)
|
||||
}
|
||||
|
||||
rename("(.+_at.cfg)", "META-INF/$1")
|
||||
}
|
||||
|
||||
|
||||
val remapJar by tasks.named<net.fabricmc.loom.task.RemapJarTask>("remapJar") {
|
||||
archiveClassifier.set("")
|
||||
|
@ -111,7 +129,7 @@ tasks.shadowJar {
|
|||
}
|
||||
|
||||
// If you want to include other dependencies and shadow them, you can relocate them in here
|
||||
fun relocate(name: String) = relocate(name, "com.examplemod.deps.$name")
|
||||
fun relocate(name: String) = relocate(name, "$baseGroup.deps.$name")
|
||||
}
|
||||
|
||||
tasks.assemble.get().dependsOn(tasks.remapJar)
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
loom.platform=forge
|
||||
org.gradle.jvmargs=-Xmx2g
|
||||
baseGroup = com.example
|
||||
mcVersion = 1.8.9
|
||||
version = 1.0.0
|
|
@ -1,18 +1,18 @@
|
|||
[
|
||||
{
|
||||
"modid": "examplemod",
|
||||
"name": "Xample Mod",
|
||||
"description": "A mod that is used as an example.",
|
||||
"version": "1.0.0",
|
||||
"mcversion": "1.8.9",
|
||||
"url": "https://github.com/romangraef/Forge1.8.9Template/",
|
||||
"updateUrl": "",
|
||||
"authorList": [
|
||||
"You"
|
||||
],
|
||||
"credits": "",
|
||||
"logoFile": "",
|
||||
"screenshots": [],
|
||||
"dependencies": []
|
||||
"modid": "${modid}",
|
||||
"name": "Xample Mod",
|
||||
"description": "A mod that is used as an example.",
|
||||
"version": "${version}",
|
||||
"mcversion": "1.8.9",
|
||||
"url": "https://github.com/romangraef/Forge1.8.9Template/",
|
||||
"updateUrl": "",
|
||||
"authorList": [
|
||||
"You"
|
||||
],
|
||||
"credits": "",
|
||||
"logoFile": "",
|
||||
"screenshots": [],
|
||||
"dependencies": []
|
||||
}
|
||||
]
|
||||
]
|
Loading…
Add table
Reference in a new issue