Renderer
An easy-to-use rendering library specifically designed for the modern Fabric version.
Installation
To install this library, you can use the Jitpack service. Add the Jitpack repository to the appropriate block of your project as indicated on the official website, and then include the following line in the dependencies section of the build.gradle file:
include modImplementation("com.github.0x3C50:Renderer:master-SNAPSHOT")
This approach will use the latest commit as the build target while caching it on each access. If a specific version is required, you can specify the short commit hash (for example, d2cc995ff4) instead of master-SNAPSHOT.
Usage
The library comes with comprehensive javadoc documentation that covers almost all aspects of usage. Additional examples and explanations are available in the wiki.
Two Types of Renderers
The library offers two main tools: Renderer2d for working with 2D graphics on the interface and Renderer3d for 3D rendering in the game world.
Event System
The built-in event system allows tracking various rendering stages, such as interface rendering or world rendering. Details about available events and their usage can be found in the wiki.
Code Examples
Additional implementation examples are available in the RendererClient class.
class Listener {
void main() {
Events.manager.registerSubscribers(this);
}
@MessageSubscription
void onWorldRendered(RenderEvent.World world) {
// Filled square at coordinates (0, 0, 0):
Renderer3d.renderFilled(world.getMatrixStack(), Color.RED, Vec3d.ZERO, new Vec3d(1, 1, 1));
// Square outline at coordinates (0, 0, 0):
Renderer3d.renderOutline(world.getMatrixStack(), Color.RED, Vec3d.ZERO, new Vec3d(1, 1, 1));
}
@MessageSubscription
void onHudRendered(RenderEvent.Hud hud) {
// Rounded square in the area (50, 50 -> 100, 100), corner radius 5 pixels, 10 samples
Renderer2d.renderRoundedQuad(RendererUtil.getEmptyMatrixStack(), Color.WHITE, 50, 50, 100, 100, 5, 10);
}
}