aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/util
diff options
context:
space:
mode:
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)