Skip to content

net.kernelpanicsoft.archie.gui.util.extension

Functions

addVertex

fun VertexConsumer.addVertex(
    matrix: Matrix4f, 
    x: Int, 
    y: Int, 
    z: Int
): VertexConsumer

Adds a vertex to this VertexConsumer using integer screen coordinates.

blit

fun GuiGraphics.blit(
    state: SimpleThemeState, 
    x: Int, 
    y: Int
)

A helper extension to blit a SimpleThemeState without manually extracting all its properties.

blitTinted

fun GuiGraphics.blitTinted(
    atlasLocation: ResourceLocation, 
    x: Int, 
    y: Int, 
    uOffset: Float, 
    vOffset: Float, 
    width: Int, 
    height: Int, 
    textureWidth: Int, 
    textureHeight: Int, 
    red: Float, 
    green: Float, 
    blue: Float, 
    alpha: Float
)

Tinted counterpart to vanilla's own untinted blit(ResourceLocation, x,y, uOffset,vOffset, width,height, textureWidth,textureHeight) overload.

drawRectOutline

fun GuiGraphics.drawRectOutline(
    x: Int, 
    y: Int, 
    width: Int, 
    height: Int, 
    color: Int, 
    thickness: Int = 1
)

Draws an unfilled rectangle outline of thickness pixels using the default GUI RenderType.

fun GuiGraphics.drawRectOutline(
    type: RenderType, 
    x: Int, 
    y: Int, 
    width: Int, 
    height: Int, 
    color: Int, 
    thickness: Int = 1
)

Draws an unfilled rectangle outline of thickness pixels as four filled edge strips.

drawThemeState

fun GuiGraphics.drawThemeState(
    state: ThemeState, 
    x: Int, 
    y: Int, 
    width: Int, 
    height: Int
)

Draws a ThemeState to the screen - tinted by whatever RenderSystem.setShaderColor currently has active (net.kernelpanicsoft.archie.gui.composables.containers.Tinted is what sets it), automatically and for every caller: the plain, opaque-white default (no Tinted wrapper active anywhere above this call) draws exactly as this always has, and anything else routes through a genuinely different draw call, not just a different pose/uniform state applied on top of the usual one. Vanilla's own atlas-sprite blit path (GuiGraphics.blitSprite, used below for any atlas-sprite texture, node_frame included) draws through an immediate Tesselator call using a plain, colorless position_tex shader - confirmed directly against GuiGraphics's own decompiled source, not assumed - that never samples the ColorModulator uniform RenderSystem.setShaderColor sets at all, unlike ordinary text rendering (which goes through the normal batched RenderType pipeline and does sample it) - the reason a Tinted wrapper around, say, a net.kernelpanicsoft.archie.gui.composables.containers.NodeAnimation fade would otherwise visibly reach a node's own text but not its themed background. innerBlitTinted and friends below port vanilla's own private nine-slice/tile blitting (GuiGraphics.blitNineSlicedSprite/ blitTiledSprite, package-private and therefore unreachable from here) line-for-line, just threading an explicit tint through every one of their own leaf draw calls instead of the colorless one vanilla's own private innerBlit overload uses - a plain single-quad stretch would otherwise visibly distort anything nine-sliced (node_frame's own border art, say) for as long as it stays tinted, not just a passing frame or two. A raw (non-atlas) SimpleThemeState.texture has no TextureAtlasSprite/nine-slice metadata to port a tinted path against, but still reaches innerBlitTinted directly via blitTinted below - the same UV normalization ((uOffset + 0) / textureWidth, etc.) vanilla's own untinted blit(ResourceLocation, x,y,width,height, uOffset,vOffset,uWidth,vHeight, textureWidth,textureHeight) overload uses on its own way down to its own private innerBlit, confirmed directly against GuiGraphics's own decompiled source rather than assumed.

fillGradient

fun GuiGraphics.fillGradient(
    x: Int, 
    y: Int, 
    width: Int, 
    height: Int, 
    topLeftColor: Int, 
    topRightColor: Int, 
    bottomLeftColor: Int, 
    bottomRightColor: Int
)

Fills a rectangle with a 4-corner color gradient using the default GUI RenderType.

fun GuiGraphics.fillGradient(
    type: RenderType, 
    x: Int, 
    y: Int, 
    width: Int, 
    height: Int, 
    topLeftColor: Int, 
    topRightColor: Int, 
    bottomLeftColor: Int, 
    bottomRightColor: Int
)

Fills a rectangle with a 4-corner color gradient, unlike vanilla's GuiGraphics.fillGradient (top-to-bottom only), by directly emitting one quad with a per-vertex ARGB color to type.

invoke

operator fun GuiGraphics.invoke(block: GuiGraphics.() -> Unit)

Lets a GuiGraphics receiver be invoked like guiGraphics { ... }, running block with this as the receiver. Used throughout the built-in composables' Renderer implementations to avoid repeating the guiGraphics. prefix on every draw call.

pose

fun <T> GuiGraphics.pose(block: PoseStack.() -> T): T

Runs block with this GuiGraphics's PoseStack pushed, popping it again afterwards (including when block throws). Saves the manual pose().pushPose() / pose().popPose() pairing renderers otherwise need around translate/scale/rotate calls.

scissor

fun <T> GuiGraphics.scissor(rect: IntRect, block: () -> T): T

Overload of scissor taking the clip bounds as an IntRect.

fun <T> GuiGraphics.scissor(
    minX: Int, 
    minY: Int, 
    maxX: Int, 
    maxY: Int, 
    block: () -> T
): T

Runs block with scissoring enabled to the [minX, minY, maxX, maxY) rectangle, disabling it again afterwards. Saves the manual enableScissor(...) / disableScissor() pairing renderers otherwise need around clipped content.