diff options
author | Linnea Gräf <nea@nea.moe> | 2025-02-02 00:08:18 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2025-02-02 00:08:18 +0100 |
commit | 89bceb6735a1e934287c3e01636a203758b085c8 (patch) | |
tree | 0766b8d4c10510bdd09f69fc1b50f7a4c1849372 /src/main/kotlin/util/render | |
parent | c2aefe09ab9bb8fec234ec10cbfc127dd6f7e4d2 (diff) | |
download | Firmament-89bceb6735a1e934287c3e01636a203758b085c8.tar.gz Firmament-89bceb6735a1e934287c3e01636a203758b085c8.tar.bz2 Firmament-89bceb6735a1e934287c3e01636a203758b085c8.zip |
feat: Highlight century cake slice players
Diffstat (limited to 'src/main/kotlin/util/render')
-rw-r--r-- | src/main/kotlin/util/render/TintedOverlayTexture.kt | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/main/kotlin/util/render/TintedOverlayTexture.kt b/src/main/kotlin/util/render/TintedOverlayTexture.kt new file mode 100644 index 0000000..a02eccc --- /dev/null +++ b/src/main/kotlin/util/render/TintedOverlayTexture.kt @@ -0,0 +1,44 @@ +package moe.nea.firmament.util.render + +import com.mojang.blaze3d.platform.GlConst +import com.mojang.blaze3d.systems.RenderSystem +import me.shedaniel.math.Color +import net.minecraft.client.render.OverlayTexture +import net.minecraft.util.math.ColorHelper +import moe.nea.firmament.util.ErrorUtil + +class TintedOverlayTexture : OverlayTexture() { + companion object { + val size = 16 + } + + private var lastColor: Color? = null + fun setColor(color: Color): TintedOverlayTexture { + val image = ErrorUtil.notNullOr(texture.image, "Disposed TintedOverlayTexture written to") { return this } + if (color == lastColor) return this + lastColor = color + + for (i in 0..<size) { + for (j in 0..<size) { + if (i < 8) { + image.setColorArgb(j, i, 0xB2FF0000.toInt()) + } else { + val k = ((1F - j / 15F * 0.75F) * 255F).toInt() + image.setColorArgb(j, i, ColorHelper.withAlpha(k, color.color)) + } + } + } + + RenderSystem.activeTexture(GlConst.GL_TEXTURE1) + texture.bindTexture() + texture.setFilter(false, false) + texture.setClamp(true) + image.upload(0, + 0, 0, + 0, 0, + image.width, image.height, + false) + RenderSystem.activeTexture(GlConst.GL_TEXTURE0) + return this + } +} |