Skip to content
On this page

Common

KattonClientRenderApi

top.katton.apicommon/src/main/kotlin/top/katton/api/KattonClientRenderApi.kt
Screen-space render callback context.

HudRenderContext

CommonData Class
kotlin
data class HudRenderContext( val graphics: GuiGraphics, val tickDelta: Float )

Screen-space render callback context.

Contains the graphics context and timing information for HUD rendering.

Properties

PropertyDescription
graphicsThe runtime GUI graphics object from Minecraft (GuiGraphics)
tickDeltaThe partial tick time for smooth animations

WorldRenderContext

CommonData Class
kotlin
data class WorldRenderContext( val viewMatrix: Any, val projectionMatrix: Any, val camera: Camera?, val tickDelta: Float )

World-space render callback context.

Contains matrix and camera information for 3D world rendering.

Properties

PropertyDescription
viewMatrixThe current view transformation matrix
projectionMatrixThe current projection matrix
cameraThe current camera instance (may be null)
tickDeltaThe partial tick time for smooth animations

HudRenderLayer

CommonEnum Class
kotlin
enum class HudRenderLayer

Ordering bucket for HUD render callbacks.

Renderers are processed in order: BACKGROUND -> NORMAL -> FOREGROUND

WorldRenderLayer

CommonEnum Class
kotlin
enum class WorldRenderLayer

Ordering bucket for world render callbacks.

Renderers are processed in order: EARLY -> NORMAL -> LATE

registerHudRenderer

CommonFunction
kotlin
fun registerHudRenderer(id: String, render: (HudRenderContext) -> Unit)

Register (or replace) a HUD renderer by [id].

The renderer will be called each frame during HUD rendering. Uses NORMAL layer with priority 0.

Parameters

ParameterDescription
idUnique identifier for this renderer
renderThe render callback receiving HudRenderContext

registerHudRenderer

CommonFunction
kotlin
fun registerHudRenderer(id: String, layer: HudRenderLayer, priority: Int = 0, render: (HudRenderContext) -> Unit)

Register (or replace) a HUD renderer by [id], with [layer] and [priority].

Lower priority values are rendered earlier within the same layer. Layers are rendered in order: BACKGROUND -> NORMAL -> FOREGROUND

Parameters

ParameterDescription
idUnique identifier for this renderer
layerThe render layer determining draw order
priorityPriority within the layer (lower = earlier)
renderThe render callback receiving HudRenderContext

unregisterHudRenderer

CommonFunction
kotlin
fun unregisterHudRenderer(id: String): Boolean

Remove a HUD renderer by [id].

Parameters

ParameterDescription
idThe identifier of the renderer to remove

Returns

true if the renderer was found and removed, false otherwise

registerWorldRenderer

CommonFunction
kotlin
fun registerWorldRenderer(id: String, render: (WorldRenderContext) -> Unit)

Register (or replace) a world-space renderer by [id].

The renderer will be called each frame during world rendering. Uses NORMAL layer with priority 0.

Parameters

ParameterDescription
idUnique identifier for this renderer
renderThe render callback receiving WorldRenderContext

registerWorldRenderer

CommonFunction
kotlin
fun registerWorldRenderer(id: String, layer: WorldRenderLayer, priority: Int = 0, render: (WorldRenderContext) -> Unit)

Register (or replace) a world renderer by [id], with [layer] and [priority].

Lower priority values are rendered earlier within the same layer. Layers are rendered in order: EARLY -> NORMAL -> LATE

Parameters

ParameterDescription
idUnique identifier for this renderer
layerThe render layer determining draw order
priorityPriority within the layer (lower = earlier)
renderThe render callback receiving WorldRenderContext

unregisterWorldRenderer

CommonFunction
kotlin
fun unregisterWorldRenderer(id: String): Boolean

Remove a world-space renderer by [id].

Parameters

ParameterDescription
idThe identifier of the renderer to remove

Returns

true if the renderer was found and removed, false otherwise

clearClientRenderers

CommonFunction
kotlin
fun clearClientRenderers()

Clears all client render callbacks (both HUD and world renderers).

Useful for cleanup during script reload or when resetting state.

dispatchHudRender

CommonFunction
kotlin
@JvmName("dispatchHudRender")
@JvmName("dispatchHudRender") fun dispatchHudRender(graphics: GuiGraphics, tickDelta: Float)

Internal dispatcher: called by platform render hooks to invoke all HUD renderers.

Parameters

ParameterDescription
graphicsThe GUI graphics context
tickDeltaThe partial tick time

dispatchWorldRender

CommonFunction
kotlin
@JvmName("dispatchWorldRender")
@JvmName("dispatchWorldRender") fun dispatchWorldRender(viewMatrix: Any, projectionMatrix: Any, camera: Camera?, tickDelta: Float)

Internal dispatcher: called by platform render hooks to invoke all world renderers.

Parameters

ParameterDescription
viewMatrixThe view transformation matrix
projectionMatrixThe projection matrix
cameraThe camera instance
tickDeltaThe partial tick time

drawHudText

CommonFunction
kotlin
fun drawHudText(ctx: HudRenderContext, message: Any?, x: Int, y: Int, color: Int = 0xFFFFFF, shadow: Boolean = true)

Draws text on HUD using current [HudRenderContext].

Parameters

ParameterDescription
ctxThe HUD render context
messageThe text to draw (will be converted to Component if not already)
xThe X position in screen coordinates
yThe Y position in screen coordinates
colorThe text color in ARGB format (default: white)
shadowWhether to draw a drop shadow (default: true)

Returns

true if drawing succeeded, false otherwise

fillHudRect

CommonFunction
kotlin
fun fillHudRect(ctx: HudRenderContext, x1: Int, y1: Int, x2: Int, y2: Int, color: Int)

Draws a solid rectangle on HUD using current [HudRenderContext].

Parameters

ParameterDescription
ctxThe HUD render context
x1The left edge X coordinate
y1The top edge Y coordinate
x2The right edge X coordinate
y2The bottom edge Y coordinate
colorThe fill color in ARGB format

Returns

true if drawing succeeded, false otherwise

drawHudTexture

CommonFunction
kotlin
fun drawHudTexture(ctx: HudRenderContext, texture: String, x: Int, y: Int, width: Int, height: Int, u: Float = 0f, v: Float = 0f, textureWidth: Int = width, textureHeight: Int = height): Boolean

Draws a texture region on HUD using current [HudRenderContext].

Parameters

ParameterDescription
ctxThe HUD render context
textureThe texture identifier string
xThe X position on screen
yThe Y position on screen
widthThe width to draw
heightThe height to draw
uThe U coordinate in the texture (default: 0)
vThe V coordinate in the texture (default: 0)
textureWidthThe total texture width (default: same as width)
textureHeightThe total texture height (default: same as height)

Returns

true if drawing succeeded, false if texture ID was invalid

drawLine3D

CommonFunction
kotlin
fun drawLine3D(ctx: WorldRenderContext, x1: Double, y1: Double, z1: Double, x2: Double, y2: Double, z2: Double, argbColor: Int, lineWidth: Float = 1.0f): Boolean

Draw a 3D line using world coordinates and ARGB color.

Uses real GPU mesh rendering via VertexConsumer+RenderType.

Parameters

ParameterDescription
ctxThe world render context
x1Start X coordinate in world space
y1Start Y coordinate in world space
z1Start Z coordinate in world space
x2End X coordinate in world space
y2End Y coordinate in world space
z2End Z coordinate in world space
argbColorThe line color in ARGB format
lineWidthThe width of the line (default: 1.0)

Returns

true if drawing succeeded, false otherwise

drawBillboard3D

CommonFunction
kotlin
fun drawBillboard3D(ctx: WorldRenderContext, x: Double, y: Double, z: Double, argbColor: Int, size: Float = 1.0f): Boolean

Draw a colored quad billboard at world position.

Uses real GPU mesh rendering via VertexConsumer+RenderType. Billboards always face the camera.

Parameters

ParameterDescription
ctxThe world render context
xThe X coordinate in world space
yThe Y coordinate in world space
zThe Z coordinate in world space
argbColorThe color in ARGB format
sizeThe size of the billboard (default: 1.0)

Returns

true if drawing succeeded, false otherwise