Skip to content

Commit

Permalink
Document the interface injection format
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyrobbrt committed Jul 5, 2024
1 parent 1720620 commit f166031
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,27 @@ During deobfuscation, the method parameter names are set to stable but automatic
To aid developers in understanding the decompiled code, and for better code generation when overriding decompiled
methods in mods, method parameter names are replaced with crowdsourced information from [Parchment](https://parchmentmc.org/).

### Interface Injection
JST supports injecting interfaces to transformed classes in a data-driven fashion, and creates **empty** stubs for the classes
to be able to still compile the modified code without access to the actual interface definitions.
This feature allows interfaces added at runtime using Mixins, Coremods, or other transformation mechanics to be visible at compile-time.

The format of the interface injection data file is quite straightforward:
```json5
{
"targetClassBinary": ["interfaceBinary"] // Can be a single interface, or an array of interfaces to implement
}
```
Where:
- `targetClassBinary` is the binary representation of the target class to inject the interfaces to (e.g. `net/minecraft/world/item/Item`, or `net/minecraft/world/item/Item$Properties`)
- `interfaceBinary` is the binary representation of an interface to inject (e.g. `com/example/examplemod/MyInjectedInterface`)

The interfaces can have generic parameter declarations. Assuming the target class `EntityType` has a `T` generic parameter,
we could implement `Supplier<T>` using `java/util/function/Supplier<T>`.

> [!NOTE]
> Generics are *copied verbatim*. If you need the generics to reference a class, please use its fully qualified name (e.g. `java/util/function/Supplier<java.util.concurrent.atomic.AtomicInteger>`).
## Usage

Note that this tool is not intended to be run by users directly. Rather it is integrated into
Expand Down

0 comments on commit f166031

Please sign in to comment.