aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/util/render
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-08-07 21:34:16 +0200
committerLinnea Gräf <nea@nea.moe>2024-08-07 21:34:16 +0200
commitb4f9ca21ef801bb3e39c53ae21bb6bf4398c94e9 (patch)
tree1f7928e5587b6d4d7ca071949f0a70bf81282c14 /src/main/kotlin/moe/nea/firmament/util/render
parent9b277bd897490d13ee4549a086e8d1b5f4cd0e10 (diff)
downloadfirmament-b4f9ca21ef801bb3e39c53ae21bb6bf4398c94e9.tar.gz
firmament-b4f9ca21ef801bb3e39c53ae21bb6bf4398c94e9.tar.bz2
firmament-b4f9ca21ef801bb3e39c53ae21bb6bf4398c94e9.zip
Add /firm npcs command
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/util/render')
-rw-r--r--src/main/kotlin/moe/nea/firmament/util/render/FacingThePlayerContext.kt11
-rw-r--r--src/main/kotlin/moe/nea/firmament/util/render/RenderInWorldContext.kt11
2 files changed, 12 insertions, 10 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/util/render/FacingThePlayerContext.kt b/src/main/kotlin/moe/nea/firmament/util/render/FacingThePlayerContext.kt
index 01a7083..79d6e6f 100644
--- a/src/main/kotlin/moe/nea/firmament/util/render/FacingThePlayerContext.kt
+++ b/src/main/kotlin/moe/nea/firmament/util/render/FacingThePlayerContext.kt
@@ -37,7 +37,8 @@ class FacingThePlayerContext(val worldContext: RenderInWorldContext) {
fun text(
vararg texts: Text,
- verticalAlign: RenderInWorldContext.VerticalAlign = RenderInWorldContext.VerticalAlign.CENTER
+ verticalAlign: RenderInWorldContext.VerticalAlign = RenderInWorldContext.VerticalAlign.CENTER,
+ background: Int = 0x70808080,
) {
assertTrueOr(texts.isNotEmpty()) { return@text }
for ((index, text) in texts.withIndex()) {
@@ -47,14 +48,14 @@ class FacingThePlayerContext(val worldContext: RenderInWorldContext) {
val vertexConsumer: VertexConsumer =
worldContext.vertexConsumers.getBuffer(RenderLayer.getTextBackgroundSeeThrough())
val matrix4f = worldContext.matrixStack.peek().positionMatrix
- vertexConsumer.vertex(matrix4f, -1.0f, -1.0f, 0.0f).color(0x70808080)
+ vertexConsumer.vertex(matrix4f, -1.0f, -1.0f, 0.0f).color(background)
.light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE).next()
- vertexConsumer.vertex(matrix4f, -1.0f, MC.font.fontHeight.toFloat(), 0.0f).color(0x70808080)
+ vertexConsumer.vertex(matrix4f, -1.0f, MC.font.fontHeight.toFloat(), 0.0f).color(background)
.light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE).next()
vertexConsumer.vertex(matrix4f, width.toFloat(), MC.font.fontHeight.toFloat(), 0.0f)
- .color(0x70808080)
+ .color(background)
.light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE).next()
- vertexConsumer.vertex(matrix4f, width.toFloat(), -1.0f, 0.0f).color(0x70808080)
+ vertexConsumer.vertex(matrix4f, width.toFloat(), -1.0f, 0.0f).color(background)
.light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE).next()
worldContext.matrixStack.translate(0F, 0F, 0.01F)
diff --git a/src/main/kotlin/moe/nea/firmament/util/render/RenderInWorldContext.kt b/src/main/kotlin/moe/nea/firmament/util/render/RenderInWorldContext.kt
index 3b6e262..0620425 100644
--- a/src/main/kotlin/moe/nea/firmament/util/render/RenderInWorldContext.kt
+++ b/src/main/kotlin/moe/nea/firmament/util/render/RenderInWorldContext.kt
@@ -83,11 +83,12 @@ class RenderInWorldContext private constructor(
}
}
- fun waypoint(position: BlockPos, label: Text) {
+ fun waypoint(position: BlockPos, vararg label: Text) {
text(
position.toCenterPos(),
- label,
- Text.literal("§e${FirmFormatters.formatDistance(MC.player?.pos?.distanceTo(position.toCenterPos()) ?: 42069.0)}")
+ *label,
+ Text.literal("§e${FirmFormatters.formatDistance(MC.player?.pos?.distanceTo(position.toCenterPos()) ?: 42069.0)}"),
+ background = 0xAA202020.toInt()
)
}
@@ -123,9 +124,9 @@ class RenderInWorldContext private constructor(
}
}
- fun text(position: Vec3d, vararg texts: Text, verticalAlign: VerticalAlign = VerticalAlign.CENTER) {
+ fun text(position: Vec3d, vararg texts: Text, verticalAlign: VerticalAlign = VerticalAlign.CENTER, background: Int = 0x70808080) {
withFacingThePlayer(position) {
- text(*texts, verticalAlign = verticalAlign)
+ text(*texts, verticalAlign = verticalAlign, background = background)
}
}