Skip to content

Commit

Permalink
0.6.1 RenderUtil alpha overload
Browse files Browse the repository at this point in the history
  • Loading branch information
fzzyhmstrs committed Jan 16, 2025
1 parent 9d4c0e8 commit ae6f99e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ open class CustomPressableWidget(x: Int, y: Int, width: Int, height: Int, messag
open fun renderBackground(context: DrawContext, x: Int, y: Int, width: Int, height: Int, mouseX: Int, mouseY: Int, delta: Float) {
RenderSystem.enableBlend()
RenderSystem.enableDepthTest()
context.drawNineSlice(textures.get(active, this.isSelected), x, y, width, height, ColorHelper.getWhite(this.alpha))
context.drawNineSlice(textures.get(active, this.isSelected), x, y, width, height, this.alpha)
}

override fun renderWidget(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) {
Expand Down
17 changes: 17 additions & 0 deletions src/main/kotlin/me/fzzyhmstrs/fzzy_config/util/RenderUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@ object RenderUtil {
this.drawTex(id, x, y, width, height, color)
}

/**
* Extension function to replicate the nine-slice functionality drawGuiTexture from 1.20.2+.
*
* __in 1.20.2+ this is a compat method; maintained as-is to avoid needing to alter mod code elsewhere.__
* @param id Identifier - The sprite identifier (1.20.2+ style) for the image.
* @param x Int - the x location of the texture
* @param y Int - the y location of the texture
* @param width Int - the width of the drawn texture
* @param height Int - the height of the drawn texture
* @param alpha Float - the texture transparency
* @author fzzyhmstrs
* @since 0.6.1
*/
fun DrawContext.drawNineSlice(id: Identifier, x: Int, y: Int, width: Int, height: Int, alpha: Float) {
this.drawTex(id, x, y, width, height, alpha)
}

/**
* Extension function to draw a texture, replacing drawtexture. Uses the [RenderLayer.getGuiTextured] method to fill in the function param
* @param id Identifier - The sprite identifier for the image.
Expand Down

0 comments on commit ae6f99e

Please sign in to comment.