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

HudRenderContextCommonData Class
kotlin
data class HudRenderContext( val graphics: GuiGraphicsExtractor, 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

WorldRenderContextCommonData Class
kotlin
data class WorldRenderContext( val camera: CameraRenderState?, val tickDelta: Float )

World-space render callback context.

Contains matrix and camera information for 3D world rendering.

Properties

PropertyDescription
cameraThe current camera instance (may be null)
tickDeltaThe partial tick time for smooth animations

HudRenderLayer

HudRenderLayerCommonEnum Class
kotlin
enum class HudRenderLayer

Ordering bucket for HUD render callbacks.

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

WorldRenderLayer

WorldRenderLayerCommonEnum Class
kotlin
enum class WorldRenderLayer

Ordering bucket for world render callbacks.

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

registerHudRenderer

registerHudRendererCommonFunction
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

registerHudRendererCommonFunction
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

unregisterHudRendererCommonFunction
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

registerWorldRendererCommonFunction
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

registerWorldRendererCommonFunction
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

unregisterWorldRendererCommonFunction
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

clearClientRenderersCommonFunction
kotlin
fun clearClientRenderers()

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

Useful for cleanup during script reload or when resetting state.

dispatchHudRender

dispatchHudRenderCommonFunction
kotlin
@JvmName("dispatchHudRender")
@JvmName("dispatchHudRender") fun dispatchHudRender(graphics: GuiGraphicsExtractor, 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

dispatchWorldRenderCommonFunction
kotlin
@JvmName("dispatchWorldRender")
@JvmName("dispatchWorldRender") fun dispatchWorldRender(camera: CameraRenderState?, tickDelta: Float)

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

Parameters

ParameterDescription
cameraThe camera instance
tickDeltaThe partial tick time

drawHudText

drawHudTextCommonFunction
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

fillHudRectCommonFunction
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

drawHudTextureCommonFunction
kotlin
fun drawHudTexture(ctx: HudRenderContext, texture: String, x: Int, y: Int, width: Int, height: Int, u0: Float = 0f, u1: Float = 1f, v0: Float = 0f, v1: Float = 1f): 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
u0The U coordinate of the texture region (default: 0)
u1The U coordinate of the texture region (default: 1)
v0The V coordinate of the texture region (default: 0)
v1The V coordinate of the texture region (default: 1)

Returns

true if drawing succeeded, false if texture ID was invalid

drawLine3D

drawLine3DCommonFunction
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