aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/gui/WBar.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/gui/WBar.kt')
-rw-r--r--src/main/kotlin/moe/nea/firmament/gui/WBar.kt15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/gui/WBar.kt b/src/main/kotlin/moe/nea/firmament/gui/WBar.kt
index 04c5e3d..ed812ec 100644
--- a/src/main/kotlin/moe/nea/firmament/gui/WBar.kt
+++ b/src/main/kotlin/moe/nea/firmament/gui/WBar.kt
@@ -5,6 +5,7 @@ import io.github.cottonmc.cotton.gui.client.ScreenDrawing
import io.github.cottonmc.cotton.gui.widget.WWidget
import io.github.cottonmc.cotton.gui.widget.data.Texture
import me.shedaniel.math.Color
+import net.minecraft.client.gui.DrawContext
import net.minecraft.client.util.math.MatrixStack
import moe.nea.firmament.Firmament
@@ -27,7 +28,7 @@ open class WBar(
}
private fun drawSection(
- matrices: MatrixStack,
+ context: DrawContext,
texture: Texture,
x: Int,
y: Int,
@@ -36,18 +37,18 @@ open class WBar(
sectionEnd: Double
) {
if (sectionEnd < progress && width == 4) {
- ScreenDrawing.texturedRect(matrices, x, y, 4, 8, texture, fillColor.color)
+ ScreenDrawing.texturedRect(context, x, y, 4, 8, texture, fillColor.color)
return
}
if (sectionStart > progress && width == 4) {
- ScreenDrawing.texturedRect(matrices, x, y, 4, 8, texture, emptyColor.color)
+ ScreenDrawing.texturedRect(context, x, y, 4, 8, texture, emptyColor.color)
return
}
val increasePerPixel = (sectionEnd - sectionStart / 4)
var valueAtPixel = sectionStart
for (i in (0 until width)) {
ScreenDrawing.texturedRect(
- matrices, x + i, y, 1, 8,
+ context, x + i, y, 1, 8,
texture.image, texture.u1 + i / 64F, texture.v1, texture.u1 + (i + 1) / 64F, texture.v2,
if (valueAtPixel < progress) fillColor.color else emptyColor.color
)
@@ -55,11 +56,11 @@ open class WBar(
}
}
- override fun paint(matrices: MatrixStack, x: Int, y: Int, mouseX: Int, mouseY: Int) {
+ override fun paint(context: DrawContext, x: Int, y: Int, mouseX: Int, mouseY: Int) {
var i = 0
while (i < width - 4) {
drawSection(
- matrices,
+ context,
if (i == 0) left else middle,
x + i, y,
(width - (i + 4)).coerceAtMost(4),
@@ -67,7 +68,7 @@ open class WBar(
)
i += 4
}
- drawSection(matrices, right, x + width - 4, y, 4, (width - 4) * total / width, total)
+ drawSection(context, right, x + width - 4, y, 4, (width - 4) * total / width, total)
RenderSystem.setShaderColor(1F, 1F, 1F, 1F)
}
}