aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric/features/CustomBlockOutline.kt
diff options
context:
space:
mode:
authoringlettronald <inglettronald@gmail.com>2023-06-12 20:51:33 -0500
committeringlettronald <inglettronald@gmail.com>2023-06-12 20:51:33 -0500
commit2b93c22070564ed3ad31cd1862c65185b79c1a78 (patch)
tree89909715392a1af4567ec9cdb0584269786d7e5c /src/main/kotlin/com/dulkirfabric/features/CustomBlockOutline.kt
parenteea733bdab195e3a68d4f0d8264abddd5ab2ae59 (diff)
downloadDulkirMod-Fabric-2b93c22070564ed3ad31cd1862c65185b79c1a78.tar.gz
DulkirMod-Fabric-2b93c22070564ed3ad31cd1862c65185b79c1a78.tar.bz2
DulkirMod-Fabric-2b93c22070564ed3ad31cd1862c65185b79c1a78.zip
Added a naive implementation of selected block outlines options
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