Switch to Kotlin 1.1.1, use typealias feature
This commit is contained in:
@@ -6,7 +6,7 @@ version = "2.1.3"
|
|||||||
archivesBaseName = rootProject.name + '-MC1.10.2'
|
archivesBaseName = rootProject.name + '-MC1.10.2'
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.0.3'
|
ext.kotlin_version = '1.1.1'
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven {
|
maven {
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ import net.minecraftforge.fml.relauncher.SideOnly
|
|||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
interface IColumnTextureInfo {
|
interface IColumnTextureInfo {
|
||||||
val axis: Axis?
|
val axis: Axis?
|
||||||
val top: (ShadingContext, Int, Quad)->TextureAtlasSprite?
|
val top: QuadIconResolver
|
||||||
val bottom: (ShadingContext, Int, Quad)->TextureAtlasSprite?
|
val bottom: QuadIconResolver
|
||||||
val side: (ShadingContext, Int, Quad)->TextureAtlasSprite?
|
val side: QuadIconResolver
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@@ -35,13 +35,13 @@ data class StaticColumnInfo(override val axis: Axis?,
|
|||||||
val topTexture: TextureAtlasSprite,
|
val topTexture: TextureAtlasSprite,
|
||||||
val bottomTexture: TextureAtlasSprite,
|
val bottomTexture: TextureAtlasSprite,
|
||||||
val sideTexture: TextureAtlasSprite) : IColumnTextureInfo {
|
val sideTexture: TextureAtlasSprite) : IColumnTextureInfo {
|
||||||
override val top = { ctx: ShadingContext, idx: Int, quad: Quad ->
|
override val top: QuadIconResolver = { ctx, _, _ ->
|
||||||
OptifineCTM.override(topTexture, blockContext, UP.rotate(ctx.rotation))
|
OptifineCTM.override(topTexture, blockContext, UP.rotate(ctx.rotation))
|
||||||
}
|
}
|
||||||
override val bottom = { ctx: ShadingContext, idx: Int, quad: Quad ->
|
override val bottom: QuadIconResolver = { ctx, _, _ ->
|
||||||
OptifineCTM.override(bottomTexture, blockContext, DOWN.rotate(ctx.rotation))
|
OptifineCTM.override(bottomTexture, blockContext, DOWN.rotate(ctx.rotation))
|
||||||
}
|
}
|
||||||
override val side = { ctx: ShadingContext, idx: Int, quad: Quad ->
|
override val side: QuadIconResolver = { ctx, idx, _ ->
|
||||||
OptifineCTM.override(sideTexture, blockContext, (if ((idx and 1) == 0) SOUTH else EAST).rotate(ctx.rotation))
|
OptifineCTM.override(sideTexture, blockContext, (if ((idx and 1) == 0) SOUTH else EAST).rotate(ctx.rotation))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,7 +129,7 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
|||||||
val transitionTop = model { mix(sideRoundLarge.model, sideRoundSmall.model) { it > 1 } }
|
val transitionTop = model { mix(sideRoundLarge.model, sideRoundSmall.model) { it > 1 } }
|
||||||
val transitionBottom = model { mix(sideRoundSmall.model, sideRoundLarge.model) { it > 1 } }
|
val transitionBottom = model { mix(sideRoundSmall.model, sideRoundLarge.model) { it > 1 } }
|
||||||
|
|
||||||
inline fun continous(q1: QuadrantType, q2: QuadrantType) =
|
inline fun continuous(q1: QuadrantType, q2: QuadrantType) =
|
||||||
q1 == q2 || ((q1 == SQUARE || q1 == INVISIBLE) && (q2 == SQUARE || q2 == INVISIBLE))
|
q1 == q2 || ((q1 == SQUARE || q1 == INVISIBLE) && (q2 == SQUARE || q2 == INVISIBLE))
|
||||||
|
|
||||||
abstract val blockPredicate: (IBlockState)->Boolean
|
abstract val blockPredicate: (IBlockState)->Boolean
|
||||||
@@ -185,7 +185,6 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
|||||||
renderer,
|
renderer,
|
||||||
sideModel,
|
sideModel,
|
||||||
rotation,
|
rotation,
|
||||||
blockContext.blockCenter,
|
|
||||||
icon = columnTextures.side,
|
icon = columnTextures.side,
|
||||||
postProcess = noPost
|
postProcess = noPost
|
||||||
)
|
)
|
||||||
@@ -210,7 +209,7 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PARALLEL -> {
|
PARALLEL -> {
|
||||||
if (!continous(quadrants[idx], quadrantsTop[idx])) {
|
if (!continuous(quadrants[idx], quadrantsTop[idx])) {
|
||||||
if (quadrants[idx] == SQUARE || quadrants[idx] == INVISIBLE) {
|
if (quadrants[idx] == SQUARE || quadrants[idx] == INVISIBLE) {
|
||||||
upModel = topSquare.model
|
upModel = topSquare.model
|
||||||
}
|
}
|
||||||
@@ -229,7 +228,7 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PARALLEL -> {
|
PARALLEL -> {
|
||||||
if (!continous(quadrants[idx], quadrantsBottom[idx]) &&
|
if (!continuous(quadrants[idx], quadrantsBottom[idx]) &&
|
||||||
(quadrants[idx] == SQUARE || quadrants[idx] == INVISIBLE)) {
|
(quadrants[idx] == SQUARE || quadrants[idx] == INVISIBLE)) {
|
||||||
downModel = bottomSquare.model
|
downModel = bottomSquare.model
|
||||||
}
|
}
|
||||||
@@ -240,9 +239,8 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
|||||||
renderer,
|
renderer,
|
||||||
upModel,
|
upModel,
|
||||||
rotation,
|
rotation,
|
||||||
blockContext.blockCenter,
|
|
||||||
icon = upIcon,
|
icon = upIcon,
|
||||||
postProcess = { ctx, qi, q, vi, v ->
|
postProcess = { _, _, _, _, _ ->
|
||||||
if (isLidUp) {
|
if (isLidUp) {
|
||||||
rotateUV(idx + if (logAxis == Axis.X) 1 else 0)
|
rotateUV(idx + if (logAxis == Axis.X) 1 else 0)
|
||||||
if (logAxis == Axis.X) mirrorUV(true, true)
|
if (logAxis == Axis.X) mirrorUV(true, true)
|
||||||
@@ -253,9 +251,8 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
|||||||
renderer,
|
renderer,
|
||||||
downModel,
|
downModel,
|
||||||
rotation,
|
rotation,
|
||||||
blockContext.blockCenter,
|
|
||||||
icon = downIcon,
|
icon = downIcon,
|
||||||
postProcess = { ctx, qi, q, vi, v ->
|
postProcess = { _, _, _, _, _ ->
|
||||||
if (isLidDown) {
|
if (isLidDown) {
|
||||||
rotateUV((if (logAxis == Axis.X) 0 else 3) - idx)
|
rotateUV((if (logAxis == Axis.X) 0 else 3) - idx)
|
||||||
if (logAxis != Axis.Y) mirrorUV(true, true)
|
if (logAxis != Axis.Y) mirrorUV(true, true)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class RenderAlgae : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
|||||||
renderer,
|
renderer,
|
||||||
algaeModels[rand[2]],
|
algaeModels[rand[2]],
|
||||||
Rotation.identity,
|
Rotation.identity,
|
||||||
icon = { ctx, qi, q -> algaeIcons[rand[qi and 1]]!! },
|
icon = { _, qi, _ -> algaeIcons[rand[qi and 1]]!! },
|
||||||
postProcess = noPost
|
postProcess = noPost
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,14 +112,14 @@ class RenderCactus : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
|||||||
renderer,
|
renderer,
|
||||||
modelCross[ctx.random(0)],
|
modelCross[ctx.random(0)],
|
||||||
Rotation.identity,
|
Rotation.identity,
|
||||||
icon = { ctx, qi, q -> iconCross.icon!!},
|
icon = { _, _, _ -> iconCross.icon!!},
|
||||||
postProcess = noPost
|
postProcess = noPost
|
||||||
)
|
)
|
||||||
modelRenderer.render(
|
modelRenderer.render(
|
||||||
renderer,
|
renderer,
|
||||||
modelArm[ctx.random(1)],
|
modelArm[ctx.random(1)],
|
||||||
cactusArmRotation[ctx.random(2) % 4],
|
cactusArmRotation[ctx.random(2) % 4],
|
||||||
icon = { ctx2, qi, q -> iconArm[ctx.random(3)]!!},
|
icon = { _, _, _ -> iconArm[ctx.random(3)]!!},
|
||||||
postProcess = noPost
|
postProcess = noPost
|
||||||
)
|
)
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class RenderCoral : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
|||||||
renderer,
|
renderer,
|
||||||
coralModels[variation++],
|
coralModels[variation++],
|
||||||
rotationFromUp[idx],
|
rotationFromUp[idx],
|
||||||
icon = { ctx, qi, q -> if (qi == 4) crustIcons[variation]!! else coralIcons[variation + (qi and 1)]!!},
|
icon = { _, qi, _ -> if (qi == 4) crustIcons[variation]!! else coralIcons[variation + (qi and 1)]!!},
|
||||||
postProcess = noPost
|
postProcess = noPost
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ class RenderGrass : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
|||||||
fullCube,
|
fullCube,
|
||||||
Rotation.identity,
|
Rotation.identity,
|
||||||
ctx.blockCenter,
|
ctx.blockCenter,
|
||||||
icon = { ctx, qi, q -> grassInfo.grassTopTexture },
|
icon = { _, _, _ -> grassInfo.grassTopTexture },
|
||||||
postProcess = { ctx, qi, q, vi, v ->
|
postProcess = { ctx, _, _, _, _ ->
|
||||||
rotateUV(2)
|
rotateUV(2)
|
||||||
if (isSnowed) {
|
if (isSnowed) {
|
||||||
if (!ctx.aoEnabled) setGrey(1.4f)
|
if (!ctx.aoEnabled) setGrey(1.4f)
|
||||||
@@ -104,10 +104,8 @@ class RenderGrass : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
|||||||
grassModels[rand[0]],
|
grassModels[rand[0]],
|
||||||
Rotation.identity,
|
Rotation.identity,
|
||||||
ctx.blockCenter + (if (isSnowed) snowOffset else Double3.zero),
|
ctx.blockCenter + (if (isSnowed) snowOffset else Double3.zero),
|
||||||
icon = { ctx: ShadingContext, qi: Int, q: Quad ->
|
icon = { _, qi, _ -> if (Config.shortGrass.useGenerated) iconGen.icon!! else iconset[rand[qi and 1]]!! },
|
||||||
if (Config.shortGrass.useGenerated) iconGen.icon!! else iconset[rand[qi and 1]]!!
|
postProcess = { _, _, _, _, _ -> if (isSnowed) setGrey(1.0f) else multiplyColor(grassInfo.overrideColor ?: blockColor) }
|
||||||
},
|
|
||||||
postProcess = { ctx, qi, q, vi, v -> if (isSnowed) setGrey(1.0f) else multiplyColor(grassInfo.overrideColor ?: blockColor) }
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ class RenderLeaves : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
|||||||
leavesModel.model,
|
leavesModel.model,
|
||||||
rotation,
|
rotation,
|
||||||
ctx.blockCenter + perturbs[rand[0]],
|
ctx.blockCenter + perturbs[rand[0]],
|
||||||
icon = { ctx, qi, q -> leafInfo.roundLeafTexture },
|
icon = { _, _, _ -> leafInfo.roundLeafTexture },
|
||||||
postProcess = { ctx, qi, q, vi, v ->
|
postProcess = { _, _, _, _, _ ->
|
||||||
rotateUV(rand[1])
|
rotateUV(rand[1])
|
||||||
multiplyColor(blockColor)
|
multiplyColor(blockColor)
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,7 @@ class RenderLeaves : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
|||||||
leavesModel.model,
|
leavesModel.model,
|
||||||
Rotation.identity,
|
Rotation.identity,
|
||||||
ctx.blockCenter + perturbs[rand[0]],
|
ctx.blockCenter + perturbs[rand[0]],
|
||||||
icon = { ctx, qi, q -> snowedIcon[rand[1]]!! },
|
icon = { _, _, _ -> snowedIcon[rand[1]]!! },
|
||||||
postProcess = whitewash
|
postProcess = whitewash
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class RenderLilypad : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
|||||||
Rotation.identity,
|
Rotation.identity,
|
||||||
ctx.blockCenter.add(perturbs[rand[4]]),
|
ctx.blockCenter.add(perturbs[rand[4]]),
|
||||||
forceFlat = true,
|
forceFlat = true,
|
||||||
icon = { ctx, qi, q -> flowerIcon[rand[0]]!! },
|
icon = { _, _, _ -> flowerIcon[rand[0]]!! },
|
||||||
postProcess = noPost
|
postProcess = noPost
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ object StandardLogSupport : TextureListModelProcessor<IColumnTextureInfo>, IColu
|
|||||||
|
|
||||||
fun getAxis(state: IBlockState): Axis? {
|
fun getAxis(state: IBlockState): Axis? {
|
||||||
val axis = tryDefault(null) { state.getValue(BlockLog.LOG_AXIS).toString() } ?:
|
val axis = tryDefault(null) { state.getValue(BlockLog.LOG_AXIS).toString() } ?:
|
||||||
state.properties.entries.find { it.key.getName().toLowerCase() == "axis" }?.let { it.value.toString() }
|
state.properties.entries.find { it.key.getName().toLowerCase() == "axis" }?.value?.toString()
|
||||||
return when (axis) {
|
return when (axis) {
|
||||||
"x" -> Axis.X
|
"x" -> Axis.X
|
||||||
"y" -> Axis.Y
|
"y" -> Axis.Y
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class RenderMycelium : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
|||||||
myceliumModel[rand[0]],
|
myceliumModel[rand[0]],
|
||||||
Rotation.identity,
|
Rotation.identity,
|
||||||
ctx.blockCenter + (if (isSnowed) snowOffset else Double3.zero),
|
ctx.blockCenter + (if (isSnowed) snowOffset else Double3.zero),
|
||||||
icon = { ctx, qi, q -> myceliumIcon[rand[qi and 1]]!! },
|
icon = { _, qi, _ -> myceliumIcon[rand[qi and 1]]!! },
|
||||||
postProcess = if (isSnowed) whitewash else noPost
|
postProcess = if (isSnowed) whitewash else noPost
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class RenderNetherrack : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID)
|
|||||||
renderer,
|
renderer,
|
||||||
netherrackModel[rand[0]],
|
netherrackModel[rand[0]],
|
||||||
Rotation.identity,
|
Rotation.identity,
|
||||||
icon = { ctx, qi, q -> netherrackIcon[rand[qi and 1]]!! },
|
icon = { _, qi, _ -> netherrackIcon[rand[qi and 1]]!! },
|
||||||
postProcess = noPost
|
postProcess = noPost
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class RenderReeds : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
|||||||
reedModels[ctx.random(0)],
|
reedModels[ctx.random(0)],
|
||||||
Rotation.identity,
|
Rotation.identity,
|
||||||
forceFlat = true,
|
forceFlat = true,
|
||||||
icon = { ctx, qi, q -> reedIcons[iconVar]!! },
|
icon = { _, _, _ -> reedIcons[iconVar]!! },
|
||||||
postProcess = noPost
|
postProcess = noPost
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ val snowOffset = UP * 0.0625
|
|||||||
val normalLeavesRot = arrayOf(Rotation.identity)
|
val normalLeavesRot = arrayOf(Rotation.identity)
|
||||||
val denseLeavesRot = arrayOf(Rotation.identity, Rotation.rot90[EAST.ordinal], Rotation.rot90[SOUTH.ordinal])
|
val denseLeavesRot = arrayOf(Rotation.identity, Rotation.rot90[EAST.ordinal], Rotation.rot90[SOUTH.ordinal])
|
||||||
|
|
||||||
val whitewash: RenderVertex.(ShadingContext, Int, Quad, Int, Vertex)->Unit = { ctx, qi, q, vi, v -> setGrey(1.4f) }
|
val whitewash: PostProcessLambda = { _, _, _, _, _ -> setGrey(1.4f) }
|
||||||
val greywash: RenderVertex.(ShadingContext, Int, Quad, Int, Vertex)->Unit = { ctx, qi, q, vi, v -> setGrey(1.0f) }
|
val greywash: PostProcessLambda = { _, _, _, _, _ -> setGrey(1.0f) }
|
||||||
|
|
||||||
val IBlockState.isSnow: Boolean get() = material.let { it == Material.SNOW || it == Material.CRAFTED_SNOW }
|
val IBlockState.isSnow: Boolean get() = material.let { it == Material.SNOW || it == Material.CRAFTED_SNOW }
|
||||||
|
|
||||||
|
|||||||
@@ -70,13 +70,13 @@ data class Quad(val v1: Vertex, val v2: Vertex, val v3: Vertex, val v4: Vertex)
|
|||||||
fun clampUV(minU: Double = -0.5, maxU: Double = 0.5, minV: Double = -0.5, maxV: Double = 0.5) =
|
fun clampUV(minU: Double = -0.5, maxU: Double = 0.5, minV: Double = -0.5, maxV: Double = 0.5) =
|
||||||
transformV { it.copy(uv = it.uv.clamp(minU, maxU, minV, maxV)) }
|
transformV { it.copy(uv = it.uv.clamp(minU, maxU, minV, maxV)) }
|
||||||
fun mirrorUV(mirrorU: Boolean, mirrorV: Boolean) = transformV { it.copy(uv = it.uv.mirror(mirrorU, mirrorV)) }
|
fun mirrorUV(mirrorU: Boolean, mirrorV: Boolean) = transformV { it.copy(uv = it.uv.mirror(mirrorU, mirrorV)) }
|
||||||
fun setAoShader(resolver: (Quad, Vertex)->Shader, predicate: (Vertex, Int)->Boolean = { v, vi -> true }) =
|
fun setAoShader(factory: ShaderFactory, predicate: (Vertex, Int)->Boolean = { v, vi -> true }) =
|
||||||
transformVI { vertex, idx ->
|
transformVI { vertex, idx ->
|
||||||
if (!predicate(vertex, idx)) vertex else vertex.copy(aoShader = resolver(this@Quad, vertex))
|
if (!predicate(vertex, idx)) vertex else vertex.copy(aoShader = factory(this@Quad, vertex))
|
||||||
}
|
}
|
||||||
fun setFlatShader(resolver: (Quad, Vertex)->Shader, predicate: (Vertex, Int)->Boolean = { v, vi -> true }) =
|
fun setFlatShader(factory: ShaderFactory, predicate: (Vertex, Int)->Boolean = { v, vi -> true }) =
|
||||||
transformVI { vertex, idx ->
|
transformVI { vertex, idx ->
|
||||||
if (!predicate(vertex, idx)) vertex else vertex.copy(flatShader = resolver(this@Quad, vertex))
|
if (!predicate(vertex, idx)) vertex else vertex.copy(flatShader = factory(this@Quad, vertex))
|
||||||
}
|
}
|
||||||
fun setFlatShader(shader: Shader) = transformVI { vertex, idx -> vertex.copy(flatShader = shader) }
|
fun setFlatShader(shader: Shader) = transformVI { vertex, idx -> vertex.copy(flatShader = shader) }
|
||||||
val flipped: Quad get() = Quad(v4, v3, v2, v1)
|
val flipped: Quad get() = Quad(v4, v3, v2, v1)
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite
|
|||||||
import net.minecraft.util.EnumFacing
|
import net.minecraft.util.EnumFacing
|
||||||
import net.minecraft.util.EnumFacing.*
|
import net.minecraft.util.EnumFacing.*
|
||||||
|
|
||||||
class ModelRenderer() : ShadingContext() {
|
typealias QuadIconResolver = (ShadingContext, Int, Quad) -> TextureAtlasSprite?
|
||||||
|
typealias PostProcessLambda = RenderVertex.(ShadingContext, Int, Quad, Int, Vertex) -> Unit
|
||||||
|
|
||||||
|
class ModelRenderer : ShadingContext() {
|
||||||
|
|
||||||
/** Holds final vertex data before it goes to the [Tessellator]. */
|
/** Holds final vertex data before it goes to the [Tessellator]. */
|
||||||
val temp = RenderVertex()
|
val temp = RenderVertex()
|
||||||
@@ -25,14 +28,14 @@ class ModelRenderer() : ShadingContext() {
|
|||||||
* @param[rotateUV] lambda to get amount of UV rotation for each quad
|
* @param[rotateUV] lambda to get amount of UV rotation for each quad
|
||||||
* @param[postProcess] lambda to perform arbitrary modifications on the [RenderVertex] just before it goes to the [Tessellator]
|
* @param[postProcess] lambda to perform arbitrary modifications on the [RenderVertex] just before it goes to the [Tessellator]
|
||||||
*/
|
*/
|
||||||
inline fun render(
|
fun render(
|
||||||
worldRenderer: VertexBuffer,
|
worldRenderer: VertexBuffer,
|
||||||
model: Model,
|
model: Model,
|
||||||
rot: Rotation,
|
rot: Rotation = Rotation.identity,
|
||||||
trans: Double3 = blockContext.blockCenter,
|
trans: Double3 = blockContext.blockCenter,
|
||||||
forceFlat: Boolean = false,
|
forceFlat: Boolean = false,
|
||||||
icon: (ShadingContext, Int, Quad) -> TextureAtlasSprite?,
|
icon: QuadIconResolver,
|
||||||
postProcess: RenderVertex.(ShadingContext, Int, Quad, Int, Vertex) -> Unit
|
postProcess: PostProcessLambda
|
||||||
) {
|
) {
|
||||||
rotation = rot
|
rotation = rot
|
||||||
aoEnabled = Minecraft.isAmbientOcclusionEnabled()
|
aoEnabled = Minecraft.isAmbientOcclusionEnabled()
|
||||||
@@ -167,4 +170,4 @@ val allFaces: (EnumFacing) -> Boolean = { true }
|
|||||||
val topOnly: (EnumFacing) -> Boolean = { it == UP }
|
val topOnly: (EnumFacing) -> Boolean = { it == UP }
|
||||||
|
|
||||||
/** Perform no post-processing */
|
/** Perform no post-processing */
|
||||||
val noPost: RenderVertex.(ShadingContext, Int, Quad, Int, Vertex) -> Unit = { ctx, qi, q, vi, v -> }
|
val noPost: PostProcessLambda = { _, _, _, _, _ -> }
|
||||||
@@ -10,7 +10,7 @@ const val defaultEdgeDimming = 0.8f
|
|||||||
// ================================
|
// ================================
|
||||||
// Shader instantiation lambdas
|
// Shader instantiation lambdas
|
||||||
// ================================
|
// ================================
|
||||||
fun cornerAo(fallbackAxis: EnumFacing.Axis): (EnumFacing, EnumFacing, EnumFacing)->Shader = { face, dir1, dir2 ->
|
fun cornerAo(fallbackAxis: EnumFacing.Axis): CornerShaderFactory = { face, dir1, dir2 ->
|
||||||
val fallbackDir = listOf(face, dir1, dir2).find { it.axis == fallbackAxis }!!
|
val fallbackDir = listOf(face, dir1, dir2).find { it.axis == fallbackAxis }!!
|
||||||
CornerSingleFallback(face, dir1, dir2, fallbackDir)
|
CornerSingleFallback(face, dir1, dir2, fallbackDir)
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ fun cornerAoTri(func: (AoData, AoData)-> AoData) = { face: EnumFacing, dir1: Enu
|
|||||||
}
|
}
|
||||||
val cornerAoMaxGreen = cornerAoTri { s1, s2 -> if (s1.green > s2.green) s1 else s2 }
|
val cornerAoMaxGreen = cornerAoTri { s1, s2 -> if (s1.green > s2.green) s1 else s2 }
|
||||||
|
|
||||||
fun cornerInterpolate(edgeAxis: EnumFacing.Axis, weight: Float, dimming: Float): (EnumFacing, EnumFacing, EnumFacing)->Shader = { dir1, dir2, dir3 ->
|
fun cornerInterpolate(edgeAxis: EnumFacing.Axis, weight: Float, dimming: Float): CornerShaderFactory = { dir1, dir2, dir3 ->
|
||||||
val edgeDir = listOf(dir1, dir2, dir3).find { it.axis == edgeAxis }!!
|
val edgeDir = listOf(dir1, dir2, dir3).find { it.axis == edgeAxis }!!
|
||||||
val faceDirs = listOf(dir1, dir2, dir3).filter { it.axis != edgeAxis }
|
val faceDirs = listOf(dir1, dir2, dir3).filter { it.axis != edgeAxis }
|
||||||
CornerInterpolateDimming(faceDirs[0], faceDirs[1], edgeDir, weight, dimming)
|
CornerInterpolateDimming(faceDirs[0], faceDirs[1], edgeDir, weight, dimming)
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ import net.minecraft.util.EnumFacing.*
|
|||||||
import java.lang.Math.min
|
import java.lang.Math.min
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
typealias EdgeShaderFactory = (EnumFacing, EnumFacing) -> Shader
|
||||||
|
typealias CornerShaderFactory = (EnumFacing, EnumFacing, EnumFacing) -> Shader
|
||||||
|
typealias ShaderFactory = (Quad, Vertex) -> Shader
|
||||||
|
|
||||||
/** Holds shading values for block corners as calculated by vanilla Minecraft rendering. */
|
/** Holds shading values for block corners as calculated by vanilla Minecraft rendering. */
|
||||||
class AoData() {
|
class AoData() {
|
||||||
var valid = false
|
var valid = false
|
||||||
@@ -140,8 +144,8 @@ interface Shader {
|
|||||||
* @param[edge] shader instantiation lambda for edge midpoint vertices
|
* @param[edge] shader instantiation lambda for edge midpoint vertices
|
||||||
*/
|
*/
|
||||||
fun faceOrientedAuto(overrideFace: EnumFacing? = null,
|
fun faceOrientedAuto(overrideFace: EnumFacing? = null,
|
||||||
corner: ((EnumFacing, EnumFacing, EnumFacing)->Shader)? = null,
|
corner: CornerShaderFactory? = null,
|
||||||
edge: ((EnumFacing, EnumFacing)->Shader)? = null) =
|
edge: EdgeShaderFactory? = null) =
|
||||||
fun(quad: Quad, vertex: Vertex): Shader {
|
fun(quad: Quad, vertex: Vertex): Shader {
|
||||||
val quadFace = overrideFace ?: quad.normal.nearestCardinal
|
val quadFace = overrideFace ?: quad.normal.nearestCardinal
|
||||||
val nearestCorner = nearestPosition(vertex.xyz, faceCorners[quadFace.ordinal].asList) {
|
val nearestCorner = nearestPosition(vertex.xyz, faceCorners[quadFace.ordinal].asList) {
|
||||||
@@ -167,7 +171,7 @@ fun faceOrientedAuto(overrideFace: EnumFacing? = null,
|
|||||||
* @param[corner] shader instantiation lambda
|
* @param[corner] shader instantiation lambda
|
||||||
*/
|
*/
|
||||||
fun edgeOrientedAuto(overrideEdge: Pair<EnumFacing, EnumFacing>? = null,
|
fun edgeOrientedAuto(overrideEdge: Pair<EnumFacing, EnumFacing>? = null,
|
||||||
corner: (EnumFacing, EnumFacing, EnumFacing)->Shader) =
|
corner: CornerShaderFactory) =
|
||||||
fun(quad: Quad, vertex: Vertex): Shader {
|
fun(quad: Quad, vertex: Vertex): Shader {
|
||||||
val edgeDir = overrideEdge ?: nearestAngle(quad.normal, boxEdges) { it.first.vec + it.second.vec }.first
|
val edgeDir = overrideEdge ?: nearestAngle(quad.normal, boxEdges) { it.first.vec + it.second.vec }.first
|
||||||
val nearestFace = nearestPosition(vertex.xyz, edgeDir.toList()) { it.vec }.first
|
val nearestFace = nearestPosition(vertex.xyz, edgeDir.toList()) { it.vec }.first
|
||||||
|
|||||||
Reference in New Issue
Block a user