aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/util
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-05-26 23:23:03 +0200
committernea <nea@nea.moe>2023-05-26 23:23:03 +0200
commit59ea00dabceeddf01fec7bf87ec548d7beedd7cc (patch)
tree9711c61022f2bac793c423de97901d2370b7c316 /src/main/kotlin/moe/nea/firmament/util
parent484a4b1a61493eb1401ac9c8ac063db3f847cf98 (diff)
downloadFirmament-59ea00dabceeddf01fec7bf87ec548d7beedd7cc.tar.gz
Firmament-59ea00dabceeddf01fec7bf87ec548d7beedd7cc.tar.bz2
Firmament-59ea00dabceeddf01fec7bf87ec548d7beedd7cc.zip
Fix bug in WFixedPanel and use WScrollPanel + WBox for config
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/util')
-rw-r--r--src/main/kotlin/moe/nea/firmament/util/MC.kt2
-rw-r--r--src/main/kotlin/moe/nea/firmament/util/TimeMark.kt9
-rw-r--r--src/main/kotlin/moe/nea/firmament/util/render/block.kt7
3 files changed, 17 insertions, 1 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/util/MC.kt b/src/main/kotlin/moe/nea/firmament/util/MC.kt
index 2f3d029..53bad8b 100644
--- a/src/main/kotlin/moe/nea/firmament/util/MC.kt
+++ b/src/main/kotlin/moe/nea/firmament/util/MC.kt
@@ -31,7 +31,9 @@ object MC {
get() = MinecraftClient.getInstance().currentScreen
set(value) = MinecraftClient.getInstance().setScreen(value)
inline val handledScreen: HandledScreen<*>? get() = MinecraftClient.getInstance().currentScreen as? HandledScreen<*>
+ inline val window get() = MinecraftClient.getInstance().window
}
+
val Coordinate.blockPos: BlockPos
get() = BlockPos(x, y, z)
diff --git a/src/main/kotlin/moe/nea/firmament/util/TimeMark.kt b/src/main/kotlin/moe/nea/firmament/util/TimeMark.kt
index e9826f1..3331a76 100644
--- a/src/main/kotlin/moe/nea/firmament/util/TimeMark.kt
+++ b/src/main/kotlin/moe/nea/firmament/util/TimeMark.kt
@@ -23,11 +23,18 @@ import kotlin.time.ExperimentalTime
import kotlin.time.TimeSource
@OptIn(ExperimentalTime::class)
-class TimeMark private constructor(private val timeMark: TimeSource.Monotonic.ValueTimeMark?) {
+class TimeMark private constructor(private val timeMark: TimeSource.Monotonic.ValueTimeMark?) : Comparable<TimeMark> {
fun passedTime() = timeMark?.elapsedNow() ?: Duration.INFINITE
companion object {
fun now() = TimeMark(TimeSource.Monotonic.markNow())
fun farPast() = TimeMark(null)
}
+
+ override fun compareTo(other: TimeMark): Int {
+ if (this.timeMark == other.timeMark) return 0
+ if (this.timeMark == null) return -1
+ if (other.timeMark == null) return -1
+ return this.timeMark.compareTo(other.timeMark)
+ }
}
diff --git a/src/main/kotlin/moe/nea/firmament/util/render/block.kt b/src/main/kotlin/moe/nea/firmament/util/render/block.kt
index bc5a889..7df610b 100644
--- a/src/main/kotlin/moe/nea/firmament/util/render/block.kt
+++ b/src/main/kotlin/moe/nea/firmament/util/render/block.kt
@@ -24,7 +24,9 @@ import net.minecraft.client.gl.VertexBuffer
import net.minecraft.client.render.BufferBuilder
import net.minecraft.client.render.Camera
import net.minecraft.client.render.GameRenderer
+import net.minecraft.client.render.RenderLayer
import net.minecraft.client.render.Tessellator
+import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.VertexFormat
import net.minecraft.client.render.VertexFormats
import net.minecraft.client.util.math.MatrixStack
@@ -33,6 +35,7 @@ import net.minecraft.util.math.Vec3d
class RenderBlockContext private constructor(private val tesselator: Tessellator, private val matrixStack: MatrixStack) {
private val buffer = tesselator.buffer
+
fun color(red: Float, green: Float, blue: Float, alpha: Float) {
RenderSystem.setShaderColor(red, green, blue, alpha)
}
@@ -55,6 +58,10 @@ class RenderBlockContext private constructor(private val tesselator: Tessellator
matrixStack.pop()
}
+ fun line(vararg points: Vec3d, size: Double = 2.0) {
+
+ }
+
companion object {
private fun buildCube(matrix: Matrix4f, buf: BufferBuilder) {
buf.begin(VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION_COLOR)