aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/com/dulkirfabric/Registrations.kt5
-rw-r--r--src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt19
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/CustomBlockOutline.kt2
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/RenderTest.kt22
-rw-r--r--src/main/kotlin/com/dulkirfabric/hud/ActionBarHudReplacements.kt12
-rw-r--r--src/main/kotlin/com/dulkirfabric/hud/SpeedOverlay.kt3
-rw-r--r--src/main/kotlin/com/dulkirfabric/util/JarvisIntegrationPlugin.kt5
-rw-r--r--src/main/kotlin/com/dulkirfabric/util/render/WorldRenderUtils.kt39
8 files changed, 67 insertions, 40 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/Registrations.kt b/src/main/kotlin/com/dulkirfabric/Registrations.kt
index 7e68f90..f41aecc 100644
--- a/src/main/kotlin/com/dulkirfabric/Registrations.kt
+++ b/src/main/kotlin/com/dulkirfabric/Registrations.kt
@@ -77,6 +77,9 @@ object Registrations {
EVENT_BUS.subscribe(ActionBarUtil)
EVENT_BUS.subscribe(ActionBarHudReplacements)
EVENT_BUS.subscribe(ChatStacking)
+
+ if (FabricLoader.getInstance().isDevelopmentEnvironment)
+ EVENT_BUS.subscribe(RenderTest)
}
fun registerEvents() {
@@ -101,7 +104,7 @@ object Registrations {
ModifyCommandEvent(command).also { it.post() }.command
}
- WorldRenderEvents.END.register { context -> WorldRenderLastEvent(context).post() }
+ WorldRenderEvents.LAST.register { context -> WorldRenderLastEvent(context).post() }
ScreenEvents.BEFORE_INIT.register(
ScreenEvents.BeforeInit { client, screen, scaledWidth, scaledHeight ->
diff --git a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
index d310be4..7447595 100644
--- a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
+++ b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
@@ -25,6 +25,7 @@ import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import me.shedaniel.clothconfig2.api.ConfigBuilder
+import meteordevelopment.orbit.EventHandler
import moe.nea.jarvis.api.Point
import net.minecraft.client.gui.screen.Screen
import net.minecraft.client.util.InputUtil
@@ -304,25 +305,24 @@ class DulkirConfig {
var configOptions = ConfigOptions()
- val huds = mutableListOf<Pair<HudElement, Point>>()
+ val huds = mutableListOf<Triple<HudElement, Point, Float>>()
fun hudElement(
id: String, label: Text, width: Int, height: Int,
- defaultPosition: Point
+ defaultPosition: Point, scale: Float = 1f
): HudElement {
val element = HudElement(
configOptions.positions.getOrPut(
id
- ) { HudElement.Positioning(defaultPosition.x(), defaultPosition.y(), 1F) },
+ ) { HudElement.Positioning(defaultPosition.x(), defaultPosition.y(), scale) },
id,
label, width, height,
)
- huds.add(Pair(element, defaultPosition))
+ huds.add(Triple(element, defaultPosition, scale))
return element
}
-
- private fun saveConfig() {
+ fun saveConfig() {
val json = Json {
prettyPrint = true
ignoreUnknownKeys = true
@@ -349,11 +349,10 @@ class DulkirConfig {
}
configOptions = json.decodeFromString<ConfigOptions>(configFile.readText())
}
- huds.forEach { (element, defaultPosition) ->
+ huds.forEach { (element, defaultPosition, scale) ->
element.positioning = configOptions.positions.getOrPut(
- element.key,
- { HudElement.Positioning(defaultPosition.x(), defaultPosition.y(), 1F) }
- )
+ element.key
+ ) { HudElement.Positioning(defaultPosition.x(), defaultPosition.y(), scale) }
}
}
}
diff --git a/src/main/kotlin/com/dulkirfabric/features/CustomBlockOutline.kt b/src/main/kotlin/com/dulkirfabric/features/CustomBlockOutline.kt
index 3aa3121..b64fe6b 100644
--- a/src/main/kotlin/com/dulkirfabric/features/CustomBlockOutline.kt
+++ b/src/main/kotlin/com/dulkirfabric/features/CustomBlockOutline.kt
@@ -23,7 +23,7 @@ object CustomBlockOutline {
val z = blockPos.z.toDouble()
val color = ColorUtil.toRGB(DulkirConfig.configOptions.blockOutlineColor)
- WorldRenderUtils.drawBox(
+ WorldRenderUtils.drawWireFrame(
event.worldRenderContext, Box(x, y, z, x + 1, y + 1, z + 1),
color, 3f * DulkirConfig.configOptions.blockOutlineThickness, true
)
diff --git a/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt b/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt
index 3442f8a..5eda0f9 100644
--- a/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt
+++ b/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt
@@ -1,13 +1,9 @@
package com.dulkirfabric.features
-import com.dulkirfabric.DulkirModFabric.mc
-import com.dulkirfabric.config.DulkirConfig
import com.dulkirfabric.events.EntityLoadEvent
-import com.dulkirfabric.events.HudRenderEvent
import com.dulkirfabric.events.WorldRenderLastEvent
import com.dulkirfabric.util.render.WorldRenderUtils
import meteordevelopment.orbit.EventHandler
-import moe.nea.jarvis.api.Point
import net.minecraft.text.Style
import net.minecraft.text.Text
import net.minecraft.util.math.Vec3d
@@ -22,11 +18,7 @@ object RenderTest {
Vec3d(-183.5, 79.0, -465.5)
)
-// mc.world?.entities?.forEach {
-// if (it is GlowingEntityInterface)
-// it.setDulkirEntityGlow(true, Color(255, 255, 255, 255), Random(it.id).nextBoolean())
-// }
- //HudRenderUtil.drawTitle(event.context, Text.literal("Hello World!"))
+ WorldRenderUtils.drawBox(event.context, 0.0, 0.0, 0.0, 2.0, 2.0, 2.0, Color(0, 200, 200, 150), false)
}
@EventHandler
@@ -34,16 +26,4 @@ object RenderTest {
//if (event.entity !is GlowingEntityInterface) return
//event.entity.setDulkirEntityGlow(true, Color(0, 0, 255, 255),false)
}
-
- val fooHud = DulkirConfig.hudElement("foobar", Text.literal("Text"), 200, 10, Point(0.4, 0.4))
-
- @EventHandler
- fun onRenderHud(event: HudRenderEvent) {
- val context = event.context
- val matrices = context.matrices
- matrices.push()
- fooHud.applyTransformations(matrices)
- context.drawText(mc.textRenderer, Text.literal("ยง6This is the actual element."),0, 0, -1, true)
- matrices.pop()
- }
} \ No newline at end of file
diff --git a/src/main/kotlin/com/dulkirfabric/hud/ActionBarHudReplacements.kt b/src/main/kotlin/com/dulkirfabric/hud/ActionBarHudReplacements.kt
index 8bacec0..6e86de8 100644
--- a/src/main/kotlin/com/dulkirfabric/hud/ActionBarHudReplacements.kt
+++ b/src/main/kotlin/com/dulkirfabric/hud/ActionBarHudReplacements.kt
@@ -10,10 +10,14 @@ import moe.nea.jarvis.api.Point
import net.minecraft.text.Text
object ActionBarHudReplacements {
- private val hpHud = DulkirConfig.hudElement("hpHud", Text.literal("Health"), 50, 11, Point(0.21, 0.21))
- private val defHud = DulkirConfig.hudElement("defHud", Text.literal("Def"), 50, 25, Point(0.22, 0.22))
- private val stackHud = DulkirConfig.hudElement("stackHud", Text.literal("Stacks"), 50, 11, Point(0.22, 0.22))
- private val manaHud = DulkirConfig.hudElement("manaHud", Text.literal("Mana"), 50, 11, Point(0.23, 0.23))
+ private val hpHud = DulkirConfig.hudElement("hpHud", Text.literal("Health"), 50, 11,
+ Point(0.4056462738575835, 0.8479382203757649),1.2286775f)
+ private val defHud = DulkirConfig.hudElement("defHud", Text.literal("Def"), 50, 25,
+ Point(0.6407475196141946, 0.9963439393439096), 1.189786f)
+ private val stackHud = DulkirConfig.hudElement("stackHud", Text.literal("Stacks"), 50, 11,
+ Point(0.4046055614026583, 0.8128084113198316), 1.2318832f)
+ private val manaHud = DulkirConfig.hudElement("manaHud", Text.literal("Mana"), 50, 11,
+ Point(0.5699228055607499, 0.8479382203757649), 1.2286775f)
@EventHandler
fun onHudRender(event: HudRenderEvent) {
diff --git a/src/main/kotlin/com/dulkirfabric/hud/SpeedOverlay.kt b/src/main/kotlin/com/dulkirfabric/hud/SpeedOverlay.kt
index eaee06c..53aca50 100644
--- a/src/main/kotlin/com/dulkirfabric/hud/SpeedOverlay.kt
+++ b/src/main/kotlin/com/dulkirfabric/hud/SpeedOverlay.kt
@@ -9,7 +9,8 @@ import moe.nea.jarvis.api.Point
import net.minecraft.text.Text
object SpeedOverlay {
- private val speedHud = DulkirConfig.hudElement("SpeedHud", Text.literal("Speed"), 24 + 4, 11, Point(0.2, 0.2))
+ private val speedHud = DulkirConfig.hudElement("SpeedHud", Text.literal("Speed"), 24 + 4, 11,
+ Point(0.3669986675110943, 0.9857798862704453), 1.6367052f)
@EventHandler
fun onHudRender(event: HudRenderEvent) {
diff --git a/src/main/kotlin/com/dulkirfabric/util/JarvisIntegrationPlugin.kt b/src/main/kotlin/com/dulkirfabric/util/JarvisIntegrationPlugin.kt
index 28b0fd3..1958819 100644
--- a/src/main/kotlin/com/dulkirfabric/util/JarvisIntegrationPlugin.kt
+++ b/src/main/kotlin/com/dulkirfabric/util/JarvisIntegrationPlugin.kt
@@ -12,4 +12,9 @@ class JarvisIntegrationPlugin: JarvisPlugin {
override fun getAllHuds(): List<JarvisHud> {
return DulkirConfig.huds.map { it.first }
}
+
+ override fun onHudEditorClosed() {
+ super.onHudEditorClosed()
+ DulkirConfig.saveConfig()
+ }
} \ No newline at end of file
diff --git a/src/main/kotlin/com/dulkirfabric/util/render/WorldRenderUtils.kt b/src/main/kotlin/com/dulkirfabric/util/render/WorldRenderUtils.kt
index ceb631d..e6f58df 100644
--- a/src/main/kotlin/com/dulkirfabric/util/render/WorldRenderUtils.kt
+++ b/src/main/kotlin/com/dulkirfabric/util/render/WorldRenderUtils.kt
@@ -12,6 +12,7 @@ import net.minecraft.util.Formatting
import net.minecraft.util.math.Box
import net.minecraft.util.math.Vec3d
import org.joml.Vector3f
+import org.lwjgl.opengl.GL11
import java.awt.Color
import kotlin.math.max
import kotlin.math.pow
@@ -51,7 +52,7 @@ object WorldRenderUtils {
* TODO: write a more custom rendering function so we don't have to do this ugly translation of
* Minecraft's screen space rendering logic to a world space rendering function.
*/
- fun drawBox(
+ fun drawWireFrame(
context: WorldRenderContext,
box: Box,
color: Color,
@@ -215,7 +216,7 @@ object WorldRenderUtils {
depthTest: Boolean = true,
scale: Float = 1f
) {
- if (depthTest) {
+ if (!depthTest) {
RenderSystem.disableDepthTest()
}
RenderSystem.enableBlend()
@@ -348,4 +349,38 @@ object WorldRenderUtils {
RenderSystem.enableCull()
RenderSystem.disableBlend()
}
+
+ /**
+ * Draws a filled box at a given position
+ */
+ fun drawBox(
+ context: WorldRenderContext,
+ x: Double,
+ y: Double,
+ z: Double,
+ width: Double,
+ height: Double,
+ depth: Double,
+ color: Color,
+ depthTest: Boolean
+ ) {
+ if (!depthTest) {
+ RenderSystem.disableDepthTest()
+ //RenderSystem.depthMask(false)
+ } else {
+ RenderSystem.enableDepthTest()
+ }
+ val matrices = context.matrixStack()
+ matrices.push()
+ val vertexConsumers = context.worldRenderer().bufferBuilders.entityVertexConsumers
+ val vertexConsumer = vertexConsumers.getBuffer(RenderLayer.getDebugFilledBox())
+
+ matrices.translate(-context.camera().pos.x, -context.camera().pos.y, -context.camera().pos.z)
+
+ WorldRenderer.renderFilledBox(matrices, vertexConsumer, x, y, z, x + width, y + height, z + depth,
+ color.red.toFloat(), color.green.toFloat(), color.blue.toFloat(), color.alpha.toFloat())
+ vertexConsumers.draw()
+ RenderSystem.enableDepthTest()
+ matrices.pop()
+ }
} \ No newline at end of file