diff options
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/util')
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) |