feat: transparent block renders
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package moe.nea.firmament.features.items
|
||||
|
||||
import me.shedaniel.math.Color
|
||||
import moe.nea.firmament.annotations.Subscribe
|
||||
import moe.nea.firmament.features.FirmamentFeature
|
||||
import moe.nea.firmament.gui.config.ManagedConfig
|
||||
@@ -43,7 +44,7 @@ object EtherwarpOverlay : FirmamentFeature {
|
||||
if (!world.getBlockState(blockPos.up()).isAir) return
|
||||
if (!world.getBlockState(blockPos.up(2)).isAir) return
|
||||
RenderInWorldContext.renderInWorld(event) {
|
||||
if (TConfig.cube) block(blockPos, 0xFFFFFF00.toInt())
|
||||
if (TConfig.cube) block(blockPos, Color.ofRGBA(172, 0, 255, 60).color)
|
||||
if (TConfig.wireframe) wireframeCube(blockPos, 10f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package moe.nea.firmament.features.world
|
||||
|
||||
import io.github.moulberry.repo.data.Coordinate
|
||||
import me.shedaniel.math.Color
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.serializer
|
||||
import net.minecraft.text.Text
|
||||
@@ -100,7 +101,7 @@ object FairySouls : FirmamentFeature {
|
||||
if (!TConfig.displaySouls) return
|
||||
renderInWorld(it) {
|
||||
currentMissingSouls.forEach {
|
||||
block(it.blockPos, 0x80FFFF00.toInt())
|
||||
block(it.blockPos, Color.ofRGBA(176, 0, 255, 128).color)
|
||||
}
|
||||
color(1f, 0f, 1f, 1f)
|
||||
currentLocationSouls.forEach {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package moe.nea.firmament.features.world
|
||||
|
||||
import me.shedaniel.math.Color
|
||||
import kotlin.compareTo
|
||||
import kotlin.text.clear
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
@@ -38,7 +39,7 @@ object TemporaryWaypoints {
|
||||
if (temporaryPlayerWaypointList.isEmpty()) return
|
||||
RenderInWorldContext.renderInWorld(event) {
|
||||
temporaryPlayerWaypointList.forEach { (_, waypoint) ->
|
||||
block(waypoint.pos, 0xFFFFFF00.toInt())
|
||||
block(waypoint.pos, Color.ofRGBA(255, 255, 0, 128).color)
|
||||
}
|
||||
temporaryPlayerWaypointList.forEach { (player, waypoint) ->
|
||||
val skin =
|
||||
|
||||
@@ -45,7 +45,7 @@ object Waypoints : FirmamentFeature {
|
||||
RenderInWorldContext.renderInWorld(event) {
|
||||
if (!w.isOrdered) {
|
||||
w.waypoints.withIndex().forEach {
|
||||
block(it.value.blockPos, 0x800050A0.toInt())
|
||||
block(it.value.blockPos, Color.ofRGBA(0, 80, 160, 128).color)
|
||||
if (TConfig.showIndex) withFacingThePlayer(it.value.blockPos.toCenterPos()) {
|
||||
text(Text.literal(it.index.toString()))
|
||||
}
|
||||
|
||||
12
src/main/kotlin/util/IntUtil.kt
Normal file
12
src/main/kotlin/util/IntUtil.kt
Normal file
@@ -0,0 +1,12 @@
|
||||
package moe.nea.firmament.util
|
||||
|
||||
object IntUtil {
|
||||
data class RGBA(val r: Int, val g: Int, val b: Int, val a: Int)
|
||||
|
||||
fun Int.toRGBA(): RGBA {
|
||||
return RGBA(
|
||||
r = (this shr 16) and 0xFF, g = (this shr 8) and 0xFF, b = this and 0xFF, a = (this shr 24) and 0xFF
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,6 +39,7 @@ object CustomRenderPipelines {
|
||||
.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST)
|
||||
.withCull(false)
|
||||
.withDepthWrite(false)
|
||||
.withBlend(BlendFunction.TRANSLUCENT)
|
||||
.build()
|
||||
|
||||
val CIRCLE_FILTER_TRANSLUCENT_GUI_TRIS =
|
||||
|
||||
@@ -20,6 +20,7 @@ import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.util.math.Vec3d
|
||||
import moe.nea.firmament.events.WorldRenderLastEvent
|
||||
import moe.nea.firmament.util.FirmFormatters
|
||||
import moe.nea.firmament.util.IntUtil.toRGBA
|
||||
import moe.nea.firmament.util.MC
|
||||
|
||||
@RenderContextDSL
|
||||
@@ -204,37 +205,39 @@ class RenderInWorldContext private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildCube(matrix: Matrix4f, buf: VertexConsumer, color: Int) {
|
||||
private fun buildCube(matrix: Matrix4f, buf: VertexConsumer, colorInt: Int) {
|
||||
val (r, g, b, a) = colorInt.toRGBA()
|
||||
|
||||
// Y-
|
||||
buf.vertex(matrix, 0F, 0F, 0F).color(color)
|
||||
buf.vertex(matrix, 0F, 0F, 1F).color(color)
|
||||
buf.vertex(matrix, 1F, 0F, 1F).color(color)
|
||||
buf.vertex(matrix, 1F, 0F, 0F).color(color)
|
||||
buf.vertex(matrix, 0F, 0F, 0F).color(r, g, b, a)
|
||||
buf.vertex(matrix, 0F, 0F, 1F).color(r, g, b, a)
|
||||
buf.vertex(matrix, 1F, 0F, 1F).color(r, g, b, a)
|
||||
buf.vertex(matrix, 1F, 0F, 0F).color(r, g, b, a)
|
||||
// Y+
|
||||
buf.vertex(matrix, 0F, 1F, 0F).color(color)
|
||||
buf.vertex(matrix, 1F, 1F, 0F).color(color)
|
||||
buf.vertex(matrix, 1F, 1F, 1F).color(color)
|
||||
buf.vertex(matrix, 0F, 1F, 1F).color(color)
|
||||
buf.vertex(matrix, 0F, 1F, 0F).color(r, g, b, a)
|
||||
buf.vertex(matrix, 1F, 1F, 0F).color(r, g, b, a)
|
||||
buf.vertex(matrix, 1F, 1F, 1F).color(r, g, b, a)
|
||||
buf.vertex(matrix, 0F, 1F, 1F).color(r, g, b, a)
|
||||
// X-
|
||||
buf.vertex(matrix, 0F, 0F, 0F).color(color)
|
||||
buf.vertex(matrix, 0F, 0F, 1F).color(color)
|
||||
buf.vertex(matrix, 0F, 1F, 1F).color(color)
|
||||
buf.vertex(matrix, 0F, 1F, 0F).color(color)
|
||||
buf.vertex(matrix, 0F, 0F, 0F).color(r, g, b, a)
|
||||
buf.vertex(matrix, 0F, 0F, 1F).color(r, g, b, a)
|
||||
buf.vertex(matrix, 0F, 1F, 1F).color(r, g, b, a)
|
||||
buf.vertex(matrix, 0F, 1F, 0F).color(r, g, b, a)
|
||||
// X+
|
||||
buf.vertex(matrix, 1F, 0F, 0F).color(color)
|
||||
buf.vertex(matrix, 1F, 1F, 0F).color(color)
|
||||
buf.vertex(matrix, 1F, 1F, 1F).color(color)
|
||||
buf.vertex(matrix, 1F, 0F, 1F).color(color)
|
||||
buf.vertex(matrix, 1F, 0F, 0F).color(r, g, b, a)
|
||||
buf.vertex(matrix, 1F, 1F, 0F).color(r, g, b, a)
|
||||
buf.vertex(matrix, 1F, 1F, 1F).color(r, g, b, a)
|
||||
buf.vertex(matrix, 1F, 0F, 1F).color(r, g, b, a)
|
||||
// Z-
|
||||
buf.vertex(matrix, 0F, 0F, 0F).color(color)
|
||||
buf.vertex(matrix, 1F, 0F, 0F).color(color)
|
||||
buf.vertex(matrix, 1F, 1F, 0F).color(color)
|
||||
buf.vertex(matrix, 0F, 1F, 0F).color(color)
|
||||
buf.vertex(matrix, 0F, 0F, 0F).color(r, g, b, a)
|
||||
buf.vertex(matrix, 1F, 0F, 0F).color(r, g, b, a)
|
||||
buf.vertex(matrix, 1F, 1F, 0F).color(r, g, b, a)
|
||||
buf.vertex(matrix, 0F, 1F, 0F).color(r, g, b, a)
|
||||
// Z+
|
||||
buf.vertex(matrix, 0F, 0F, 1F).color(color)
|
||||
buf.vertex(matrix, 0F, 1F, 1F).color(color)
|
||||
buf.vertex(matrix, 1F, 1F, 1F).color(color)
|
||||
buf.vertex(matrix, 1F, 0F, 1F).color(color)
|
||||
buf.vertex(matrix, 0F, 0F, 1F).color(r, g, b, a)
|
||||
buf.vertex(matrix, 0F, 1F, 1F).color(r, g, b, a)
|
||||
buf.vertex(matrix, 1F, 1F, 1F).color(r, g, b, a)
|
||||
buf.vertex(matrix, 1F, 0F, 1F).color(r, g, b, a)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user