Files
UniMixins/docs/developer-usage.md
T

79 lines
3.9 KiB
Markdown
Raw Normal View History

2023-02-06 19:06:37 +01:00
# Developer usage
2023-02-08 21:47:22 +01:00
To migrate a build script to UniMixins, merge the following into your build script.
2023-02-06 19:06:37 +01:00
2023-02-08 21:47:22 +01:00
> If using old Gradle, replace each occurrence of `implementation` with `compile`, and ignore the `annotationProcessor` line (in old Gradle, `compile` dependencies are automatically put on the annotation processor classpath).
2023-02-06 19:06:37 +01:00
```gradle
2023-02-06 19:38:24 +01:00
repositories {
maven {
url 'https://jitpack.io'
}
}
2023-02-06 19:06:37 +01:00
def unimixinsVersion = "insert version here"
2023-02-08 21:47:22 +01:00
dependencies {
2023-02-16 05:13:24 +01:00
annotationProcessor("com.github.LegacyModdingMC.UniMixins:_unimixins-all-1.7.10:$unimixinsVersion:dev")
implementation("com.github.LegacyModdingMC.UniMixins:_unimixins-all-1.7.10:$unimixinsVersion:dev")
2023-02-06 19:06:37 +01:00
}
// Exclude conflicting transitive dependencies.
2023-02-08 21:47:22 +01:00
// Only needed if you depend on a mod that depends on one of these.
2023-02-06 19:06:37 +01:00
// This may need to be at the end of the build script.
configurations.compile.dependencies.each {
if (it instanceof ExternalModuleDependency) {
it.exclude module: "SpongeMixins"
it.exclude module: "SpongePoweredMixin"
2023-02-08 21:47:22 +01:00
it.exclude module: "00gasstation-mc1.7.10"
2023-02-06 19:06:37 +01:00
it.exclude module: "gtnhmixins"
}
}
```
2023-02-08 21:47:22 +01:00
You can also depend on modules individually:
2023-02-06 19:06:37 +01:00
```gradle
2023-02-08 21:47:22 +01:00
dependencies {
2023-02-16 05:13:24 +01:00
// One of these (note: this module doesn't have dev jars)
implementation("com.github.LegacyModdingMC.UniMixins:_unimixins-mixin-1.7.10:$unimixinsVersion+unimix.0.11.5-mixin.0.8.5")
//implementation("com.github.LegacyModdingMC.UniMixins:_unimixins-mixin-1.7.10:$unimixinsVersion+spongepowered.0.8.5")
//implementation("com.github.LegacyModdingMC.UniMixins:_unimixins-mixin-1.7.10:$unimixinsVersion+fabric.0.11.4-mixin.0.8.5")
//implementation("com.github.LegacyModdingMC.UniMixins:_unimixins-mixin-1.7.10:$unimixinsVersion+gasmix.0.8.5-gasstation_7")
//implementation("com.github.LegacyModdingMC.UniMixins:_unimixins-mixin-1.7.10:$unimixinsVersion+gtnh.0.8.5-GTNH-2")
2023-02-06 19:37:05 +01:00
2023-02-08 21:47:22 +01:00
// You don't need all the modules, only the ones your mod requires.
2023-02-16 05:13:24 +01:00
implementation("com.github.LegacyModdingMC.UniMixins:_unimixins-compat-1.7.10:$unimixinsVersion:dev")
implementation("com.github.LegacyModdingMC.UniMixins:_unimixins-spongemixins-1.7.10:$unimixinsVersion+gtnh.2.0.1:dev")
2023-02-16 05:13:24 +01:00
implementation("com.github.LegacyModdingMC.UniMixins:_unimixins-mixinbooterlegacy-1.7.10:$unimixinsVersion+1.2.0:dev")
implementation("com.github.LegacyModdingMC.UniMixins:_unimixins-gasstation-1.7.10:$unimixinsVersion+0.5.1:dev")
implementation("com.github.LegacyModdingMC.UniMixins:_unimixins-mixinextras-1.7.10:$unimixinsVersion+0.1.1:dev")
implementation("com.github.LegacyModdingMC.UniMixins:_unimixins-gtnhmixins-1.7.10:$unimixinsVersion+2.1.9:dev")
implementation("com.github.LegacyModdingMC.UniMixins:_unimixins-mixingasm-1.7.10:$unimixinsVersion+0.2.2:dev")
2023-02-08 21:47:22 +01:00
// Needed if not using UniMix or GTNH's Mixin fork
2023-02-16 05:13:24 +01:00
//implementation("com.github.LegacyModdingMC.UniMixins:_unimixins-devcompat-1.7.10:$unimixinsVersion:dev")
2023-02-09 03:02:06 +01:00
}
2023-02-08 21:47:22 +01:00
```
2023-02-06 19:06:37 +01:00
2023-02-08 21:47:22 +01:00
## Pitfalls
2023-02-06 19:06:37 +01:00
2023-02-08 21:47:22 +01:00
### Shaded ASM package name
2023-02-06 19:06:37 +01:00
2023-02-08 21:47:22 +01:00
Mods which depend on MixinBooterLegacy or GTNHMixins use the MixinBooterLegacy-style shaded ASM package name (`org.spongepowered.libraries.org.objectweb.asm`), whereas UniMix uses the legacy name (`org.spongepowered.asm.lib`). You will have to switch to the latter to make your mod compile.
```patch
-import org.spongepowered.libraries.org.objectweb.asm.tree.ClassNode;
+import org.spongepowered.asm.lib.tree.ClassNode;
```
### `--mods` hack
Some build scripts use the `--mods` program argument to add a duplicate of the mod in order to work around Mixin [preventing mixin mods on the class path from getting loaded as Forge mods.](https://github.com/SpongePowered/Mixin/issues/207) In UniMix and GTNH's Mixin fork, this issue was fixed, so this workaround should be removed since it only causes problems.
```patch
- arguments += [
- "--mods=../build/libs/$archivesBaseName-${version}.jar"
- ]
2023-02-06 19:37:05 +01:00
```