tutorial:interface_injection
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| tutorial:interface_injection [2025/11/27 23:22] – Fix . to / earthcomputer | tutorial:interface_injection [2025/11/28 00:09] (current) – Emphasize that implementing an injected interface with mixin is no longer necessary earthcomputer | ||
|---|---|---|---|
| Line 33: | Line 33: | ||
| </ | </ | ||
| - | :!: The method body in the interface | + | :!: Even if the method body in the interface |
| - | + | ||
| - | ℹ️ It's highly recommended to add a dollar-character or underscore character with the mod name as the prefix or suffix of the method name, in order to avoid method name conflict with other mods. | + | |
| ===== Step 2: Implement the Interface with a Mixin ===== | ===== Step 2: Implement the Interface with a Mixin ===== | ||
| - | Now you need to implement this interface | + | The class tweaker step below on its own will be enough if you only want to implement the interface (for example, for marker interfaces, or where you have the whole implementation in default methods). However, |
| < | < | ||
| Line 51: | Line 49: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | ℹ️ If implementing the method with an interface, it's highly recommended to add a dollar-character or underscore character with the mod name as the prefix or suffix of the method name, in order to avoid method name conflict with other mods. | ||
| ===== Step 3: Inject the Interface in the class tweaker ===== | ===== Step 3: Inject the Interface in the class tweaker ===== | ||
| Line 65: | Line 65: | ||
| </ | </ | ||
| - | To make your interface injection visible to other mods depending on your mod (if you are writing a library mod), use '' | + | ℹ️ |
| ==== Generic interfaces ==== | ==== Generic interfaces ==== | ||
tutorial/interface_injection.txt · Last modified: 2025/11/28 00:09 by earthcomputer