Lillero ASM patches via Minecraft Forge's ModLauncher https://docs.zaaarf.foo/lillero-loader/
Find a file
2023-02-20 18:08:30 +01:00
gradle/wrapper initial commit - separed from lll lib 2023-02-07 03:29:02 +01:00
src/main fix: no need to apply patches only once 2023-02-15 22:29:56 +01:00
.editorconfig initial commit - separed from lll lib 2023-02-07 03:29:02 +01:00
.gitignore initial commit - separed from lll lib 2023-02-07 03:29:02 +01:00
build.gradle fix: patch only once, bump dependancy 2023-02-08 00:08:13 +01:00
gradlew fix: executable gradlew 2023-02-07 13:12:04 +01:00
gradlew.bat initial commit - separed from lll lib 2023-02-07 03:29:02 +01:00
README.md doc: made json instructions less janky 2023-02-20 18:08:30 +01:00

Lillero-loader

"don't do coremods"

Lillero-loader is a ModLauncher plugin applying bare ASM patches to our beloved block game.

Why

Up to Minecraft 1.12, patching the game's code wasn't such a complicated ordeal for a Forge modder: it was as simple as writing a "CoreMod" (even though in the more recent versions the Forge forums have been rather unkind to anyone dabbling in such things, from which comes our motto).

Forge would then load your mod when Minecraft itself was loading, allowing the developer to look up classes and patch them. Unfortunately, in 1.13+ the Forge team heavily reworked their code, making it impossible - as far as we can tell - to make CoreMods the same way we always did.

With IFMLLoadingPlugin gone, Forge and Mixin are now using ModLauncher to modify the game's code. Refusing to give up our right to torture ourselves by writing bytecode, we set out to find a new way to do ASM patching.

We found it, and decided to share it with you, to spare you the pain of reading all that undocumented code.

How

ModLauncher works by using Java services: mods seeking to use it, such as Forge, Mixin and ourselves, implement one of their service interfaces and register themselves as such.

Depending on what kind of service you registered as, your mod will be called at a specific time of loading. In our case, we are a ILaunchPluginService: we are loaded just before game classes are loaded in memory, and are fed their bytecode for patching.

This plugin only recognises patches written using IInjector from the Lillero library. More details on the project's page.

I know what I'm doing, tell me how the magic works

LilleroLoader implements the ILaunchPluginService interface and three of its methods. These methods are called in three phases*.

  • addResources(): will be called first for each external mod that was found, providing an absolute path to the JAR. LilleroLoader will try to load IInjector services from each of these JARs, saving them for later.
  • handlesClass(): will be called for each game class ModLauncher discovered. LilleroLoader will mark each of the classes the various IInjector asked for.
  • processClassWithFlags(): will be called for each marked game class, allowing to apply modifications to it.

*Technically, handlesClass() and processClassWithFlags() are called one after the other for each class loaded, but it's easier to understand if you disregard that.

Installation

Right now the only way to include this loader in your Minecraft instance is to modify the launch profile adding it to the loaded classes.

MultiMC / PolyMC / PrismLauncher

Select and edit your target instance and go into the "Version" tab. Click "Add empty", put "Lillero" as name and "ftbsc.lll" as uid. A new library will appear. Select it, press "Edit", and your text editor of choice will open. Replace the contents with:

{
    "formatVersion": 1,
    "libraries": [
    {
        "downloads": {
            "artifact": {
                "sha1": "7d94cad0cc7e787fe9a2197e60058bd67b74f471",
                "size": 13076,
                "url": "https://maven.fantabos.co/ftbsc/lll/0.1.2/lll-0.1.2.jar"
            }
        },
        "name": "ftbsc:lll:0.1.2"
    },
    {
        "downloads": {
            "artifact": {
                "sha1": "a11968731cb3400535bde46b387b8e7f9375bb5b",
                "size": 4779,
                "url": "https://maven.fantabos.co/ftbsc/lll/loader/0.1.2/loader-0.1.2.jar"
            }
        },
        "name": "ftbsc.lll:loader:0.1.2"
    }
    ],
    "name": "Lillero",
    "uid": "ftbsc.lll",
    "version": "1"
}

Vanilla launcher

Not documented yet, but should be possible by messing in a similar way with the version json files.