Fix waypoints rendering inverted
This commit is contained in:
@@ -17,6 +17,8 @@ import net.minecraft.client.render.BufferBuilder
|
|||||||
import net.minecraft.client.render.BufferRenderer
|
import net.minecraft.client.render.BufferRenderer
|
||||||
import net.minecraft.client.render.Camera
|
import net.minecraft.client.render.Camera
|
||||||
import net.minecraft.client.render.GameRenderer
|
import net.minecraft.client.render.GameRenderer
|
||||||
|
import net.minecraft.client.render.RenderLayer
|
||||||
|
import net.minecraft.client.render.RenderPhase
|
||||||
import net.minecraft.client.render.RenderTickCounter
|
import net.minecraft.client.render.RenderTickCounter
|
||||||
import net.minecraft.client.render.Tessellator
|
import net.minecraft.client.render.Tessellator
|
||||||
import net.minecraft.client.render.VertexConsumerProvider
|
import net.minecraft.client.render.VertexConsumerProvider
|
||||||
@@ -41,6 +43,19 @@ class RenderInWorldContext private constructor(
|
|||||||
val vertexConsumers: VertexConsumerProvider.Immediate,
|
val vertexConsumers: VertexConsumerProvider.Immediate,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
object RenderLayers {
|
||||||
|
val TRANSLUCENT_TRIS = RenderLayer.of("firmament_translucent_tris",
|
||||||
|
VertexFormats.POSITION_COLOR,
|
||||||
|
VertexFormat.DrawMode.TRIANGLES,
|
||||||
|
RenderLayer.DEFAULT_BUFFER_SIZE,
|
||||||
|
false, true,
|
||||||
|
RenderLayer.MultiPhaseParameters.builder()
|
||||||
|
.depthTest(RenderPhase.ALWAYS_DEPTH_TEST)
|
||||||
|
.transparency(RenderPhase.TRANSLUCENT_TRANSPARENCY)
|
||||||
|
.program(RenderPhase.COLOR_PROGRAM)
|
||||||
|
.build(false))
|
||||||
|
}
|
||||||
|
|
||||||
fun color(color: me.shedaniel.math.Color) {
|
fun color(color: me.shedaniel.math.Color) {
|
||||||
color(color.red / 255F, color.green / 255f, color.blue / 255f, color.alpha / 255f)
|
color(color.red / 255F, color.green / 255f, color.blue / 255f, color.alpha / 255f)
|
||||||
}
|
}
|
||||||
@@ -50,7 +65,6 @@ class RenderInWorldContext private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun block(blockPos: BlockPos) {
|
fun block(blockPos: BlockPos) {
|
||||||
RenderSystem.setShader(GameRenderer::getPositionColorProgram)
|
|
||||||
matrixStack.push()
|
matrixStack.push()
|
||||||
matrixStack.translate(blockPos.x.toFloat(), blockPos.y.toFloat(), blockPos.z.toFloat())
|
matrixStack.translate(blockPos.x.toFloat(), blockPos.y.toFloat(), blockPos.z.toFloat())
|
||||||
buildCube(matrixStack.peek().positionMatrix, tesselator)
|
buildCube(matrixStack.peek().positionMatrix, tesselator)
|
||||||
@@ -85,7 +99,7 @@ class RenderInWorldContext private constructor(
|
|||||||
val vec = position.subtract(camera.pos).multiply(distanceToMoveTowardsCamera / actualCameraDistance)
|
val vec = position.subtract(camera.pos).multiply(distanceToMoveTowardsCamera / actualCameraDistance)
|
||||||
matrixStack.translate(vec.x, vec.y, vec.z)
|
matrixStack.translate(vec.x, vec.y, vec.z)
|
||||||
matrixStack.multiply(camera.rotation)
|
matrixStack.multiply(camera.rotation)
|
||||||
matrixStack.scale(-0.025F, -0.025F, -1F)
|
matrixStack.scale(0.025F, -0.025F, 1F)
|
||||||
|
|
||||||
FacingThePlayerContext(this).run(block)
|
FacingThePlayerContext(this).run(block)
|
||||||
|
|
||||||
@@ -210,44 +224,44 @@ class RenderInWorldContext private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun buildCube(matrix: Matrix4f, tessellator: Tessellator) {
|
private fun buildCube(matrix: Matrix4f, tessellator: Tessellator) {
|
||||||
val buf = tessellator.begin(VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION)
|
val buf = tessellator.begin(VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION_COLOR)
|
||||||
buf.vertex(matrix, 0.0F, 0.0F, 0.0F).next()
|
buf.vertex(matrix, 0.0F, 0.0F, 0.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 0.0F, 0.0F, 1.0F).next()
|
buf.vertex(matrix, 0.0F, 0.0F, 1.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 0.0F, 1.0F, 1.0F).next()
|
buf.vertex(matrix, 0.0F, 1.0F, 1.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 1.0F, 1.0F, 0.0F).next()
|
buf.vertex(matrix, 1.0F, 1.0F, 0.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 0.0F, 0.0F, 0.0F).next()
|
buf.vertex(matrix, 0.0F, 0.0F, 0.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 0.0F, 1.0F, 0.0F).next()
|
buf.vertex(matrix, 0.0F, 1.0F, 0.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 1.0F, 0.0F, 1.0F).next()
|
buf.vertex(matrix, 1.0F, 0.0F, 1.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 0.0F, 0.0F, 0.0F).next()
|
buf.vertex(matrix, 0.0F, 0.0F, 0.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 1.0F, 0.0F, 0.0F).next()
|
buf.vertex(matrix, 1.0F, 0.0F, 0.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 1.0F, 1.0F, 0.0F).next()
|
buf.vertex(matrix, 1.0F, 1.0F, 0.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 1.0F, 0.0F, 0.0F).next()
|
buf.vertex(matrix, 1.0F, 0.0F, 0.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 0.0F, 0.0F, 0.0F).next()
|
buf.vertex(matrix, 0.0F, 0.0F, 0.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 0.0F, 0.0F, 0.0F).next()
|
buf.vertex(matrix, 0.0F, 0.0F, 0.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 0.0F, 1.0F, 1.0F).next()
|
buf.vertex(matrix, 0.0F, 1.0F, 1.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 0.0F, 1.0F, 0.0F).next()
|
buf.vertex(matrix, 0.0F, 1.0F, 0.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 1.0F, 0.0F, 1.0F).next()
|
buf.vertex(matrix, 1.0F, 0.0F, 1.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 0.0F, 0.0F, 1.0F).next()
|
buf.vertex(matrix, 0.0F, 0.0F, 1.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 0.0F, 0.0F, 0.0F).next()
|
buf.vertex(matrix, 0.0F, 0.0F, 0.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 0.0F, 1.0F, 1.0F).next()
|
buf.vertex(matrix, 0.0F, 1.0F, 1.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 0.0F, 0.0F, 1.0F).next()
|
buf.vertex(matrix, 0.0F, 0.0F, 1.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 1.0F, 0.0F, 1.0F).next()
|
buf.vertex(matrix, 1.0F, 0.0F, 1.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 1.0F, 1.0F, 1.0F).next()
|
buf.vertex(matrix, 1.0F, 1.0F, 1.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 1.0F, 0.0F, 0.0F).next()
|
buf.vertex(matrix, 1.0F, 0.0F, 0.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 1.0F, 1.0F, 0.0F).next()
|
buf.vertex(matrix, 1.0F, 1.0F, 0.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 1.0F, 0.0F, 0.0F).next()
|
buf.vertex(matrix, 1.0F, 0.0F, 0.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 1.0F, 1.0F, 1.0F).next()
|
buf.vertex(matrix, 1.0F, 1.0F, 1.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 1.0F, 0.0F, 1.0F).next()
|
buf.vertex(matrix, 1.0F, 0.0F, 1.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 1.0F, 1.0F, 1.0F).next()
|
buf.vertex(matrix, 1.0F, 1.0F, 1.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 1.0F, 1.0F, 0.0F).next()
|
buf.vertex(matrix, 1.0F, 1.0F, 0.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 0.0F, 1.0F, 0.0F).next()
|
buf.vertex(matrix, 0.0F, 1.0F, 0.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 1.0F, 1.0F, 1.0F).next()
|
buf.vertex(matrix, 1.0F, 1.0F, 1.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 0.0F, 1.0F, 0.0F).next()
|
buf.vertex(matrix, 0.0F, 1.0F, 0.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 0.0F, 1.0F, 1.0F).next()
|
buf.vertex(matrix, 0.0F, 1.0F, 1.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 1.0F, 1.0F, 1.0F).next()
|
buf.vertex(matrix, 1.0F, 1.0F, 1.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 0.0F, 1.0F, 1.0F).next()
|
buf.vertex(matrix, 0.0F, 1.0F, 1.0F).color(-1).next()
|
||||||
buf.vertex(matrix, 1.0F, 0.0F, 1.0F).next()
|
buf.vertex(matrix, 1.0F, 0.0F, 1.0F).color(-1).next()
|
||||||
BufferRenderer.drawWithGlobalProgram(buf.end())
|
RenderLayers.TRANSLUCENT_TRIS.draw(buf.end())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,11 @@
|
|||||||
|
|
||||||
package moe.nea.firmament.util
|
package moe.nea.firmament.util
|
||||||
|
|
||||||
|
import net.minecraft.text.MutableText
|
||||||
import net.minecraft.text.PlainTextContent
|
import net.minecraft.text.PlainTextContent
|
||||||
import net.minecraft.text.Text
|
import net.minecraft.text.Text
|
||||||
import net.minecraft.text.TranslatableTextContent
|
import net.minecraft.text.TranslatableTextContent
|
||||||
|
import net.minecraft.util.Formatting
|
||||||
import moe.nea.firmament.Firmament
|
import moe.nea.firmament.Firmament
|
||||||
|
|
||||||
|
|
||||||
@@ -96,6 +98,8 @@ val Text.unformattedString: String
|
|||||||
get() = string.removeColorCodes()
|
get() = string.removeColorCodes()
|
||||||
|
|
||||||
|
|
||||||
|
fun MutableText.withColor(formatting: Formatting) = this.styled { it.withColor(formatting) }
|
||||||
|
|
||||||
fun Text.transformEachRecursively(function: (Text) -> Text): Text {
|
fun Text.transformEachRecursively(function: (Text) -> Text): Text {
|
||||||
val c = this.content
|
val c = this.content
|
||||||
if (c is TranslatableTextContent) {
|
if (c is TranslatableTextContent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user