aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com
diff options
context:
space:
mode:
authoringlettronald <inglettronald@gmail.com>2023-06-11 17:19:53 -0500
committeringlettronald <inglettronald@gmail.com>2023-06-11 17:19:53 -0500
commit63012eec9f39fb3752bcded90bfc710ab3d05219 (patch)
treea2b9ef95dcab48108d875ff51cb90e77909aa89d /src/main/kotlin/com
parentf3f6da9f50edfbe9ed3be42fa16146210e60fbf3 (diff)
downloadDulkirMod-Fabric-63012eec9f39fb3752bcded90bfc710ab3d05219.tar.gz
DulkirMod-Fabric-63012eec9f39fb3752bcded90bfc710ab3d05219.tar.bz2
DulkirMod-Fabric-63012eec9f39fb3752bcded90bfc710ab3d05219.zip
yeah I'm not documenting this today
Diffstat (limited to 'src/main/kotlin/com')
-rw-r--r--src/main/kotlin/com/dulkirfabric/Registrations.kt7
-rw-r--r--src/main/kotlin/com/dulkirfabric/events/WorldRenderLastEvent.kt7
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/RenderBoxTest.kt15
-rw-r--r--src/main/kotlin/com/dulkirfabric/util/WorldRenderUtils.kt56
4 files changed, 85 insertions, 0 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/Registrations.kt b/src/main/kotlin/com/dulkirfabric/Registrations.kt
index 3122924..a3ab96d 100644
--- a/src/main/kotlin/com/dulkirfabric/Registrations.kt
+++ b/src/main/kotlin/com/dulkirfabric/Registrations.kt
@@ -7,10 +7,13 @@ import com.dulkirfabric.commands.JoinDungeonCommands
import com.dulkirfabric.events.ChatReceivedEvent
import com.dulkirfabric.events.ClientTickEvent
import com.dulkirfabric.events.OverlayReceivedEvent
+import com.dulkirfabric.events.WorldRenderLastEvent
import com.dulkirfabric.features.KeyShortCutImpl
+import com.dulkirfabric.features.RenderBoxTest
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents
+import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents
/**
@@ -42,6 +45,7 @@ object Registrations {
fun registerEventListeners() {
EVENT_BUS.subscribe(DulkirModFabric)
EVENT_BUS.subscribe(KeyShortCutImpl)
+ EVENT_BUS.subscribe(RenderBoxTest)
}
fun registerEvents() {
@@ -55,5 +59,8 @@ object Registrations {
else !ChatReceivedEvent(message.toString()).post()
}
)
+ WorldRenderEvents.END.register(
+ WorldRenderEvents.End { context -> WorldRenderLastEvent(context).post()}
+ )
}
} \ No newline at end of file
diff --git a/src/main/kotlin/com/dulkirfabric/events/WorldRenderLastEvent.kt b/src/main/kotlin/com/dulkirfabric/events/WorldRenderLastEvent.kt
new file mode 100644
index 0000000..11b7714
--- /dev/null
+++ b/src/main/kotlin/com/dulkirfabric/events/WorldRenderLastEvent.kt
@@ -0,0 +1,7 @@
+package com.dulkirfabric.events
+
+import com.dulkirfabric.events.base.Event
+import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext
+
+data class
+WorldRenderLastEvent(val context: WorldRenderContext): Event()
diff --git a/src/main/kotlin/com/dulkirfabric/features/RenderBoxTest.kt b/src/main/kotlin/com/dulkirfabric/features/RenderBoxTest.kt
new file mode 100644
index 0000000..e037dd9
--- /dev/null
+++ b/src/main/kotlin/com/dulkirfabric/features/RenderBoxTest.kt
@@ -0,0 +1,15 @@
+package com.dulkirfabric.features
+
+import com.dulkirfabric.events.WorldRenderLastEvent
+import com.dulkirfabric.util.WorldRenderUtils
+import meteordevelopment.orbit.EventHandler
+import java.awt.Color
+
+object RenderBoxTest {
+
+ @EventHandler
+ fun onRender(event: WorldRenderLastEvent) {
+ WorldRenderUtils.drawBox(event.context,0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f,
+ Color(255, 255, 255, 255), 3f, false)
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/com/dulkirfabric/util/WorldRenderUtils.kt b/src/main/kotlin/com/dulkirfabric/util/WorldRenderUtils.kt
new file mode 100644
index 0000000..30c19c7
--- /dev/null
+++ b/src/main/kotlin/com/dulkirfabric/util/WorldRenderUtils.kt
@@ -0,0 +1,56 @@
+package com.dulkirfabric.util
+
+import com.mojang.blaze3d.platform.GlStateManager
+import com.mojang.blaze3d.systems.RenderSystem
+import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext
+import net.minecraft.client.render.GameRenderer
+import net.minecraft.client.render.Tessellator
+import net.minecraft.client.render.VertexFormat
+import net.minecraft.client.render.VertexFormats
+import java.awt.Color
+
+
+object WorldRenderUtils {
+ fun drawBox(
+ context: WorldRenderContext,
+ x1: Float,
+ y1: Float,
+ z1: Float,
+ x2: Float,
+ y2: Float,
+ z2: Float,
+ color: Color,
+ thickness: Float,
+ depthTest: Boolean = true
+ ) {
+ val matrices = context.matrixStack()
+ matrices.push()
+ RenderSystem.setShader(GameRenderer::getRenderTypeLinesProgram)
+ RenderSystem.enableBlend()
+ RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA)
+ RenderSystem.lineWidth(thickness)
+ RenderSystem.setShaderColor(color.red / 255f, color.green / 255f, color.blue / 255f, color.alpha / 255f)
+ if (!depthTest) RenderSystem.disableDepthTest()
+ matrices.translate(-context.camera().pos.x, -context.camera().pos.y, -context.camera().pos.z)
+ val tess = Tessellator.getInstance()
+ val buf = tess.buffer
+ val matrix4f = matrices.peek().positionMatrix
+
+ buf.begin(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR)
+ buf.fixedColor(255, 255, 255, 255)
+
+ buf.vertex(matrix4f, x1, y1, z1).next()
+ buf.vertex(matrix4f, x2, y1, z1).next()
+
+ //buf.vertex(matrix4f, x2, y2, z1).next()
+
+ buf.unfixColor()
+ tess.draw()
+
+
+ RenderSystem.enableDepthTest()
+ RenderSystem.disableBlend()
+ RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
+ matrices.pop()
+ }
+} \ No newline at end of file