Dye
Dye is a Forge library that lets other mods use the JVM INVOKEDYNAMIC bytecode instruction without writing the low-level bytecode by hand.
What it does
Dye exposes the INVOKEDYNAMIC opcode of the Java Virtual Machine to mod developers. The first time an occurrence of the opcode runs, it is bound to a permanent CallSite, and the bootstrap method that produces that CallSite is written in plain Java. Lambdas in compiled bytecode are one example of how the opcode is used.
A transform service provided by the mod replaces ordinary method calls with calls to methods carrying a special annotation. The annotation's value names a custom bootstrap method, so a modder can attach INVOKEDYNAMIC behavior to annotated methods. The library is Forge-only and is published for 1.17 – 1.20.1, with 12 release versions covered and 0.1.2 for 1.20.1 as the latest file. Either side can run it, and neither needs it, and the code is released under the Apache License 2.0.
The mod is aimed at Forge mod authors who need dynamic call sites in their own code. Players and server owners do not need to configure it. More detail on use is in the GitHub repository, which also hosts the source code and the issue tracker.
Key features
INVOKEDYNAMIC access
Exposes the JVM INVOKEDYNAMIC opcode to modders through a ModLauncher service.
Bootstrap-based call sites
Each call site is created once by a bootstrap method written in plain Java and then reused.
Annotation-driven transform
A transform service rewrites calls to methods marked with a special annotation.
Custom bootstrap per annotation
The annotation value selects the bootstrap method, so each annotated method can use its own behavior.
Compatibility
Latest build for each game version and loader.
1.20.x2 of 2 versions with builds
1.19.x5 of 5 versions with builds
1.18.x3 of 3 versions with builds
1.17.x2 of 2 versions with builds
Only full game releases are shown. This mod publishes no snapshot builds.
Use cases
Lambda-style code generation
Mod code can emit INVOKEDYNAMIC instructions the way compiled lambdas do, with the call site set up by Java code.
Annotated dynamic calls
Methods marked with the library's annotation are rerouted through a chosen bootstrap method at load time.
Who it’s for: Forge mod developers who want to generate or reroute bytecode with INVOKEDYNAMIC. The library is a development tool and gives players no items, blocks or screens of their own.
Questions
Does Dye need to be installed on the server?
Which loader and versions does Dye support?
Where is the source code and how is the library used?
In the catalog
Dye is one of 3,514 Library mods on ModsFinder, and one of 1,576 Library mods for Forge. 34,764 mods support Minecraft 1.20.1.
More from noeppi-noeppi
Similar mods
What the author says
A library / modlauncher service that exposes the jvm INVOKEDYNAMIC opcode to modders. For more information on how to use it as a modder, see the GitHub. The Java Virtual Machine (JVM) has an opcode called INVOKEDYNAMIC. Each individual occurrence of that opcode in bytecode is permanently bound to a CallSite object…
Official listing
- Modrinth page
- modrinth.com/mod/dye
- Owner
- noeppi-noeppi
- Published
- 2022-08-22
- Updated on Modrinth
- 2022-08-22
- Facts verified
- 2026-10-15
