26 lines
1.2 KiB
Markdown
26 lines
1.2 KiB
Markdown
# TestSelfRemapper
|
|
|
|
example mod that (ab)uses mixin to remap/patch itself at runtime
|
|
|
|
heavily based on https://github.com/wagyourtail/TestMultiModloader,
|
|
but also rewritten to not use bytebuddy
|
|
|
|
# how it works
|
|
- the entire thing is one class (in the `boot` source set, named `Transformer`)
|
|
- all the classes go through the mixin `IExtension`
|
|
- only classes with mixins targeting them will go through it though, so
|
|
inside the mixin (`IMixinConfigPlugin`), we reflect back to get the map
|
|
of class → mixin classes, and add the classes we want to patch to it
|
|
(see `getTransformedClasses()`)
|
|
- this unfortunately doesn't work for mixins though (and we still want to patch those)
|
|
- so what we (sadly) have to do is replace the global mixin service with a custom one
|
|
that wraps the original one, but replaces the `IClassBytecodeProvider` with ours, so
|
|
we can add the patched mixins to (see `getTransformedMixins()`)
|
|
- it also loads the patches and manages applying them when given a `ClassNode`
|
|
- the patches are built inside `buildSrc` in the `MergedJar` task
|
|
|
|
# how to use
|
|
good luck lol
|
|
|
|
but you'll need https://github.com/prcraft-minecraft/class-diff in your mavenLocal
|
|
because it never got released anywhere |