Skip to content

Commit

Permalink
block models: don't shade elements if shade=false
Browse files Browse the repository at this point in the history
This fixes shading on saplings and cobwebs
  • Loading branch information
Bixilon committed Oct 10, 2023
1 parent c3bf0f1 commit bc1e0f4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ data class SingleBlockStateApply(
}

val faceProperties = if (rotation == null && this@SingleBlockStateApply.rotation == null) positions.properties(rotatedXY, texture) else null
val bakedFace = BakedFace(positions, uv, face.tintIndex, texture, rotatedXY, faceProperties)
val bakedFace = BakedFace(positions, uv, this.shade, face.tintIndex, texture, rotatedXY, faceProperties)

faces[rotatedXY.ordinal] += bakedFace
properties[rotatedXY.ordinal] += faceProperties ?: continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class BakedFace(
private val lightIndex = cull?.ordinal ?: SELF_LIGHT_INDEX


constructor(positions: FaceVertexData, uv: FaceVertexData, tintIndex: Int, texture: Texture, direction: Directions, properties: FaceProperties?) : this(positions, uv, direction.shade, tintIndex, if (properties == null) null else direction, texture, properties)
constructor(positions: FaceVertexData, uv: FaceVertexData, shade: Boolean, tintIndex: Int, texture: Texture, direction: Directions, properties: FaceProperties?) : this(positions, uv, if (shade) direction.shade else Shades.NONE, tintIndex, if (properties == null) null else direction, texture, properties)

private fun color(tint: Int): Int {
if (tint <= 0) return shade.color
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ enum class Shades(val shade: Float) {
}

companion object {
val NONE = UP


val Directions.shade: Shades
Expand Down

0 comments on commit bc1e0f4

Please sign in to comment.