aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/notenoughupdates/util
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-05-07 12:22:36 +0200
committernea <nea@nea.moe>2023-05-08 00:17:34 +0200
commit942dd629efbf12183b1c5f5a966c36d4b0647a6b (patch)
tree407e8d2cdcfefa77673c768e5126857a86ddb89a /src/main/kotlin/moe/nea/notenoughupdates/util
parent229f724ef4a0a4cbc426f31e27f9a57e9b1307c9 (diff)
downloadFirmament-942dd629efbf12183b1c5f5a966c36d4b0647a6b.tar.gz
Firmament-942dd629efbf12183b1c5f5a966c36d4b0647a6b.tar.bz2
Firmament-942dd629efbf12183b1c5f5a966c36d4b0647a6b.zip
Add fishing particle highlighter
Currently does not work when sneaking or when the bobber moves too much, since the position desyncs with the server
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/util')
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/util/MC.kt1
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/util/TimeMark.kt15
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/util/render/block.kt13
3 files changed, 28 insertions, 1 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/util/MC.kt b/src/main/kotlin/moe/nea/notenoughupdates/util/MC.kt
index 36aa726..956a330 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/util/MC.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/util/MC.kt
@@ -6,6 +6,7 @@ import net.minecraft.util.math.BlockPos
object MC {
inline val player get() = MinecraftClient.getInstance().player
+ inline val world get() = MinecraftClient.getInstance().world
}
val Coordinate.blockPos: BlockPos
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/util/TimeMark.kt b/src/main/kotlin/moe/nea/notenoughupdates/util/TimeMark.kt
new file mode 100644
index 0000000..5196606
--- /dev/null
+++ b/src/main/kotlin/moe/nea/notenoughupdates/util/TimeMark.kt
@@ -0,0 +1,15 @@
+package moe.nea.notenoughupdates.util
+
+import kotlin.time.Duration
+import kotlin.time.ExperimentalTime
+import kotlin.time.TimeSource
+
+@OptIn(ExperimentalTime::class)
+class TimeMark private constructor(private val timeMark: TimeSource.Monotonic.ValueTimeMark?) {
+ fun passedTime() = timeMark?.elapsedNow() ?: Duration.INFINITE
+
+ companion object {
+ fun now() = TimeMark(TimeSource.Monotonic.markNow())
+ fun farPast() = TimeMark(null)
+ }
+}
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/util/render/block.kt b/src/main/kotlin/moe/nea/notenoughupdates/util/render/block.kt
index 5fc70ef..0d6c63b 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/util/render/block.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/util/render/block.kt
@@ -11,6 +11,7 @@ import net.minecraft.client.render.VertexFormat
import net.minecraft.client.render.VertexFormats
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.util.math.BlockPos
+import net.minecraft.util.math.Vec3d
class RenderBlockContext private constructor(private val tesselator: Tessellator, private val matrixStack: MatrixStack) {
private val buffer = tesselator.buffer
@@ -21,7 +22,16 @@ class RenderBlockContext private constructor(private val tesselator: Tessellator
fun block(blockPos: BlockPos) {
matrixStack.push()
matrixStack.translate(blockPos.x.toFloat(), blockPos.y.toFloat(), blockPos.z.toFloat())
- RenderSystem.setShader(GameRenderer::getPositionColorProgram)
+ buildCube(matrixStack.peek().positionMatrix, buffer)
+ tesselator.draw()
+ matrixStack.pop()
+ }
+
+ fun tinyBlock(vec3d: Vec3d, size: Float) {
+ matrixStack.push()
+ matrixStack.translate(vec3d.x, vec3d.y, vec3d.z)
+ matrixStack.scale(size, size, size)
+ matrixStack.translate(-.5, -.5, -.5)
buildCube(matrixStack.peek().positionMatrix, buffer)
tesselator.draw()
matrixStack.pop()
@@ -74,6 +84,7 @@ class RenderBlockContext private constructor(private val tesselator: Tessellator
RenderSystem.disableDepthTest()
RenderSystem.enableBlend()
RenderSystem.defaultBlendFunc()
+ RenderSystem.setShader(GameRenderer::getPositionColorProgram)
matrices.push()
matrices.translate(-camera.pos.x, -camera.pos.y, -camera.pos.z)