aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features/misc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/features/misc')
-rw-r--r--src/main/kotlin/features/misc/CustomCapes.kt48
-rw-r--r--src/main/kotlin/features/misc/Hud.kt19
2 files changed, 40 insertions, 27 deletions
diff --git a/src/main/kotlin/features/misc/CustomCapes.kt b/src/main/kotlin/features/misc/CustomCapes.kt
index dc5187a..a3725e5 100644
--- a/src/main/kotlin/features/misc/CustomCapes.kt
+++ b/src/main/kotlin/features/misc/CustomCapes.kt
@@ -1,6 +1,8 @@
package moe.nea.firmament.features.misc
+import com.mojang.blaze3d.buffers.GpuBuffer
import com.mojang.blaze3d.systems.RenderSystem
+import java.nio.ByteBuffer
import java.util.OptionalDouble
import java.util.OptionalInt
import util.render.CustomRenderPipelines
@@ -63,34 +65,44 @@ object CustomCapes : FirmamentFeature {
vertexConsumerProvider: VertexConsumerProvider,
model: (VertexConsumer) -> Unit
) {
+ // TODO: figure out how exactly the rotation abstraction works
+ val animationValue = (startTime.passedTime() / animationSpeed).mod(1F)
+ val commandEncoder = RenderSystem.getDevice().createCommandEncoder()
+ val animationBufSource = ByteBuffer.allocateDirect(8)
+ animationBufSource.putFloat(animationValue.toFloat())
+ animationBufSource.flip()
BufferAllocator(2048).use { allocator ->
val bufferBuilder = BufferBuilder(allocator, renderLayer.drawMode, renderLayer.vertexFormat)
model(bufferBuilder)
bufferBuilder.end().use { buffer ->
- val commandEncoder = RenderSystem.getDevice().createCommandEncoder()
val vertexBuffer = renderLayer.vertexFormat.uploadImmediateVertexBuffer(buffer.buffer)
val indexBufferConstructor = RenderSystem.getSequentialBuffer(renderLayer.drawMode)
val indexBuffer = indexBufferConstructor.getIndexBuffer(buffer.drawParameters.indexCount)
val templateTexture = MC.textureManager.getTexture(template)
val backgroundTexture = MC.textureManager.getTexture(background)
val foregroundTexture = MC.textureManager.getTexture(overlay)
- commandEncoder.createRenderPass(
- MC.instance.framebuffer.colorAttachment,
- OptionalInt.empty(),
- MC.instance.framebuffer.depthAttachment,
- OptionalDouble.empty(),
- ).use { renderPass ->
- // TODO: account for lighting
- renderPass.setPipeline(CustomRenderPipelines.PARALLAX_CAPE_SHADER)
- renderPass.bindSampler("Sampler0", templateTexture.glTexture)
- renderPass.bindSampler("Sampler1", backgroundTexture.glTexture)
- renderPass.bindSampler("Sampler3", foregroundTexture.glTexture)
- val animationValue = (startTime.passedTime() / animationSpeed).mod(1F)
- renderPass.setUniform("Animation", animationValue.toFloat())
- renderPass.setIndexBuffer(indexBuffer, indexBufferConstructor.indexType)
- renderPass.setVertexBuffer(0, vertexBuffer)
- renderPass.drawIndexed(0, buffer.drawParameters.indexCount)
- }
+ RenderSystem.getDevice()
+ .createBuffer({ "Firm Cape Animation" }, GpuBuffer.USAGE_UNIFORM, animationBufSource)
+ .use { animationUniformBuf ->
+ commandEncoder.createRenderPass(
+ { "FirmamentCustomCape" },
+ MC.instance.framebuffer.colorAttachmentView,
+ OptionalInt.empty(),
+ MC.instance.framebuffer.depthAttachmentView,
+ OptionalDouble.empty(),
+ ).use { renderPass ->
+ // TODO: account for lighting
+ renderPass.setPipeline(CustomRenderPipelines.PARALLAX_CAPE_SHADER)
+ renderPass.bindSampler("Sampler0", templateTexture.glTextureView)
+ renderPass.bindSampler("Sampler1", backgroundTexture.glTextureView)
+ renderPass.bindSampler("Sampler3", foregroundTexture.glTextureView)
+ renderPass.setUniform("Animation", animationUniformBuf)
+ renderPass.setIndexBuffer(indexBuffer, indexBufferConstructor.indexType)
+ renderPass.setVertexBuffer(0, vertexBuffer)
+ renderPass.drawIndexed(0, 0, buffer.drawParameters.indexCount, 1)
+ }
+
+ }
}
}
}
diff --git a/src/main/kotlin/features/misc/Hud.kt b/src/main/kotlin/features/misc/Hud.kt
index 9661fc5..8c785ab 100644
--- a/src/main/kotlin/features/misc/Hud.kt
+++ b/src/main/kotlin/features/misc/Hud.kt
@@ -7,6 +7,7 @@ import moe.nea.firmament.gui.config.ManagedConfig
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.tr
import moe.nea.jarvis.api.Point
+import org.joml.Vector2i
import net.minecraft.client.network.PlayerListEntry
import net.minecraft.text.Text
@@ -16,11 +17,11 @@ object Hud : FirmamentFeature {
object TConfig : ManagedConfig(identifier, Category.MISC) {
var dayCount by toggle("day-count") { false }
- val dayCountHud by position("day-count-hud", 80, 10) { Point(0.5, 0.8) }
+ val dayCountHud by position("day-count-hud", 80, 10) { Vector2i() }
var fpsCount by toggle("fps-count") { false }
- val fpsCountHud by position("fps-count-hud", 80, 10) { Point(0.5, 0.9) }
+ val fpsCountHud by position("fps-count-hud", 80, 10) { Vector2i() }
var pingCount by toggle("ping-count") { false }
- val pingCountHud by position("ping-count-hud", 80, 10) { Point(0.5, 1.0) }
+ val pingCountHud by position("ping-count-hud", 80, 10) { Vector2i() }
}
override val config: ManagedConfig
@@ -29,7 +30,7 @@ object Hud : FirmamentFeature {
@Subscribe
fun onRenderHud(it: HudRenderEvent) {
if (TConfig.dayCount) {
- it.context.matrices.push()
+ it.context.matrices.pushMatrix()
TConfig.dayCountHud.applyTransformations(it.context.matrices)
val day = (MC.world?.timeOfDay ?: 0L) / 24000
it.context.drawText(
@@ -40,11 +41,11 @@ object Hud : FirmamentFeature {
-1,
true
)
- it.context.matrices.pop()
+ it.context.matrices.popMatrix()
}
if (TConfig.fpsCount) {
- it.context.matrices.push()
+ it.context.matrices.pushMatrix()
TConfig.fpsCountHud.applyTransformations(it.context.matrices)
it.context.drawText(
MC.font, Text.literal(
@@ -53,11 +54,11 @@ object Hud : FirmamentFeature {
)
), 36, MC.font.fontHeight, -1, true
)
- it.context.matrices.pop()
+ it.context.matrices.popMatrix()
}
if (TConfig.pingCount) {
- it.context.matrices.push()
+ it.context.matrices.pushMatrix()
TConfig.pingCountHud.applyTransformations(it.context.matrices)
val ping = MC.player?.let {
val entry: PlayerListEntry? = MC.networkHandler?.getPlayerListEntry(it.uuid)
@@ -71,7 +72,7 @@ object Hud : FirmamentFeature {
), 36, MC.font.fontHeight, -1, true
)
- it.context.matrices.pop()
+ it.context.matrices.popMatrix()
}
}
}