don't render hidden faces on connected grass
This commit is contained in:
@@ -49,7 +49,7 @@ abstract class AbstractBlockRenderingHandler(modId: String) : ResourceHandler(mo
|
||||
*/
|
||||
fun renderWorldBlockBase(ctx: BlockContext, dispatcher: BlockRendererDispatcher, renderer: VertexBuffer, layer: BlockRenderLayer?): Boolean {
|
||||
ctx.blockState(Int3.zero).let {
|
||||
if (layer == null || it.block.canRenderInLayer(layer))
|
||||
if (layer == null || it.block.canRenderInLayer(it, layer))
|
||||
return dispatcher.renderBlock(it, ctx.pos, ctx.world, renderer)
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -34,6 +34,7 @@ class ModelRenderer : ShadingContext() {
|
||||
rot: Rotation = Rotation.identity,
|
||||
trans: Double3 = blockContext.blockCenter,
|
||||
forceFlat: Boolean = false,
|
||||
quadFilter: (Int, Quad) -> Boolean = { _, _ -> true },
|
||||
icon: QuadIconResolver,
|
||||
postProcess: PostProcessLambda
|
||||
) {
|
||||
@@ -44,21 +45,23 @@ class ModelRenderer : ShadingContext() {
|
||||
worldRenderer.ensureSpaceForQuads(model.quads.size + 1)
|
||||
|
||||
model.quads.forEachIndexed { quadIdx, quad ->
|
||||
val drawIcon = icon(this, quadIdx, quad)
|
||||
if (drawIcon != null) {
|
||||
quad.verts.forEachIndexed { vertIdx, vert ->
|
||||
temp.init(vert).rotate(rotation).translate(trans)
|
||||
val shader = if (aoEnabled && !forceFlat) vert.aoShader else vert.flatShader
|
||||
shader.shade(this, temp)
|
||||
temp.postProcess(this, quadIdx, quad, vertIdx, vert)
|
||||
temp.setIcon(drawIcon)
|
||||
if (quadFilter(quadIdx, quad)) {
|
||||
val drawIcon = icon(this, quadIdx, quad)
|
||||
if (drawIcon != null) {
|
||||
quad.verts.forEachIndexed { vertIdx, vert ->
|
||||
temp.init(vert).rotate(rotation).translate(trans)
|
||||
val shader = if (aoEnabled && !forceFlat) vert.aoShader else vert.flatShader
|
||||
shader.shade(this, temp)
|
||||
temp.postProcess(this, quadIdx, quad, vertIdx, vert)
|
||||
temp.setIcon(drawIcon)
|
||||
|
||||
worldRenderer
|
||||
.pos(temp.x, temp.y, temp.z)
|
||||
.color(temp.red, temp.green, temp.blue, 1.0f)
|
||||
.tex(temp.u, temp.v)
|
||||
.lightmap(temp.brightness shr 16 and 65535, temp.brightness and 65535)
|
||||
.endVertex()
|
||||
worldRenderer
|
||||
.pos(temp.x, temp.y, temp.z)
|
||||
.color(temp.red, temp.green, temp.blue, 1.0f)
|
||||
.tex(temp.u, temp.v)
|
||||
.lightmap(temp.brightness shr 16 and 65535, temp.brightness and 65535)
|
||||
.endVertex()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ val axisDirs = listOf(POSITIVE, NEGATIVE)
|
||||
val EnumFacing.dir: AxisDirection get() = axisDirection
|
||||
val AxisDirection.sign: String get() = when(this) { POSITIVE -> "+"; NEGATIVE -> "-" }
|
||||
val forgeDirs = EnumFacing.values()
|
||||
val forgeDirsHorizontal = listOf(NORTH, SOUTH, EAST, WEST)
|
||||
val forgeDirOffsets = forgeDirs.map { Int3(it) }
|
||||
val Pair<Axis, AxisDirection>.face: EnumFacing get() = when(this) {
|
||||
X to POSITIVE -> EAST; X to NEGATIVE -> WEST;
|
||||
|
||||
Reference in New Issue
Block a user