aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric/features/CustomBlockOutline.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/features/CustomBlockOutline.kt')
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/CustomBlockOutline.kt32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/features/CustomBlockOutline.kt b/src/main/kotlin/com/dulkirfabric/features/CustomBlockOutline.kt
new file mode 100644
index 0000000..df306e1
--- /dev/null
+++ b/src/main/kotlin/com/dulkirfabric/features/CustomBlockOutline.kt
@@ -0,0 +1,32 @@
+package com.dulkirfabric.features
+
+import com.dulkirfabric.config.DulkirConfig
+import com.dulkirfabric.events.BlockOutlineEvent
+import com.dulkirfabric.util.ColorUtil
+import com.dulkirfabric.util.WorldRenderUtils
+import meteordevelopment.orbit.EventHandler
+import net.minecraft.util.math.Box
+
+object CustomBlockOutline {
+
+ /**
+ * This is kind of a lazy implementation, but it works.
+ * Notes: This always draws a 1x1x1 box around the block you're looking at. This is not accurate for all blocks,
+ * because not all blocks have a 1x1x1 bounding box. It will still tell you the correct block you're looking at correctly.
+ */
+ @EventHandler
+ fun onBlockOutline(event: BlockOutlineEvent) {
+ if (!DulkirConfig.configOptions.customBlockOutlines) return
+ val blockPos = event.blockOutlineContext.blockPos()
+ val x = blockPos.x.toDouble()
+ val y = blockPos.y.toDouble()
+ val z = blockPos.z.toDouble()
+ val color = ColorUtil.toRGB(DulkirConfig.configOptions.blockOutlineColor)
+
+ WorldRenderUtils.drawBox(
+ event.worldRenderContext, Box(x, y, z, x + 1, y + 1, z + 1),
+ color, 3f * DulkirConfig.configOptions.blockOutlineThickness, true
+ )
+ event.isCancelled = true
+ }
+} \ No newline at end of file