coloredRectRenderType
This commit is contained in:
parent
279e28095b
commit
b93faa77b7
@ -5,6 +5,8 @@ import com.mojang.blaze3d.systems.RenderSystem
|
|||||||
import com.mojang.blaze3d.vertex.*
|
import com.mojang.blaze3d.vertex.*
|
||||||
import com.mojang.math.Matrix4f
|
import com.mojang.math.Matrix4f
|
||||||
import net.minecraft.client.renderer.GameRenderer
|
import net.minecraft.client.renderer.GameRenderer
|
||||||
|
import net.minecraft.client.renderer.RenderStateShard
|
||||||
|
import net.minecraft.client.renderer.RenderType
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite
|
||||||
import org.lwjgl.opengl.GL11
|
import org.lwjgl.opengl.GL11
|
||||||
import org.lwjgl.opengl.GL11.GL_ALWAYS
|
import org.lwjgl.opengl.GL11.GL_ALWAYS
|
||||||
@ -668,3 +670,41 @@ fun drawArc(
|
|||||||
BufferUploader.drawWithShader(builder.end())
|
BufferUploader.drawWithShader(builder.end())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val coloredRectRenderType by lazy {
|
||||||
|
val builder = RenderType.CompositeState.builder()
|
||||||
|
|
||||||
|
builder.setShaderState(RenderStateShard.ShaderStateShard(GameRenderer::getPositionColorShader))
|
||||||
|
builder.setTransparencyState(RenderStateShard.TransparencyStateShard("normal_blend", {
|
||||||
|
RenderSystem.enableBlend()
|
||||||
|
RenderSystem.defaultBlendFunc()
|
||||||
|
}, {
|
||||||
|
RenderSystem.disableBlend()
|
||||||
|
}))
|
||||||
|
|
||||||
|
@Suppress("INACCESSIBLE_TYPE")
|
||||||
|
RenderType.create("colored_rect",
|
||||||
|
DefaultVertexFormat.POSITION_COLOR,
|
||||||
|
VertexFormat.Mode.QUADS,
|
||||||
|
2048,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
builder.createCompositeState(false)) as RenderType
|
||||||
|
}
|
||||||
|
|
||||||
|
fun VertexConsumer.quad(
|
||||||
|
pose: PoseStack,
|
||||||
|
x: Float,
|
||||||
|
y: Float,
|
||||||
|
width: Float,
|
||||||
|
height: Float,
|
||||||
|
z: Float,
|
||||||
|
color: RGBAColor? = null,
|
||||||
|
) {
|
||||||
|
val intColor = color?.toARGB() ?: 0
|
||||||
|
val matrix = pose.last().pose()
|
||||||
|
vertex(matrix, x, y + height, z).also { if (color != null) it.color(intColor) }.endVertex()
|
||||||
|
vertex(matrix, x + width, y + height, z).also { if (color != null) it.color(intColor) }.endVertex()
|
||||||
|
vertex(matrix, x + width, y, z).also { if (color != null) it.color(intColor) }.endVertex()
|
||||||
|
vertex(matrix, x, y, z).also { if (color != null) it.color(intColor) }.endVertex()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user