aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/gui/WBar.kt
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-06-08 00:11:46 +0200
committernea <nea@nea.moe>2023-06-08 00:11:46 +0200
commitf98a1f5d53792c026c3688fa89dea3e69910cb3a (patch)
tree873ee14abe51b1d229149c62f4958252026505fa /src/main/kotlin/moe/nea/firmament/gui/WBar.kt
parentb65382a7b74836e13d8d9c9104971737288d1496 (diff)
downloadfirmament-f98a1f5d53792c026c3688fa89dea3e69910cb3a.tar.gz
firmament-f98a1f5d53792c026c3688fa89dea3e69910cb3a.tar.bz2
firmament-f98a1f5d53792c026c3688fa89dea3e69910cb3a.zip
Update to 1.20
- Remove some devenv mods that are not updated yet - Replace lib39 with fletchingtable for automixins - Use non kotlin entrypoints - Make use of DrawContext in a bunch of places
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)
}
}