Merge branch 'kotlin-1.9.4' into kotlin-1.10
This commit is contained in:
@@ -43,6 +43,7 @@ object Config : DelegatingConfig(BetterFoliageMod.MOD_ID, BetterFoliageMod.DOMAI
|
||||
|
||||
object leaves {
|
||||
val enabled by featureEnable()
|
||||
val snowEnabled by boolean(true)
|
||||
val distance by distanceLimit()
|
||||
val hOffset by double(max=0.4, default=0.2).lang("hOffset")
|
||||
val vOffset by double(max=0.4, default=0.1).lang("vOffset")
|
||||
|
||||
@@ -22,8 +22,12 @@ import org.apache.logging.log4j.Level.INFO
|
||||
@SideOnly(Side.CLIENT)
|
||||
object OptifineCTM {
|
||||
|
||||
val isAvailable = allAvailable(Refs.ConnectedTextures, Refs.ConnectedProperties, Refs.getConnectedTexture,
|
||||
Refs.CTblockProperties, Refs.CTtileProperties, Refs.CPtileIcons, Refs.CPmatchesBlock, Refs.CPmatchesIcon)
|
||||
val isAvailable = allAvailable(
|
||||
Refs.ConnectedTextures, Refs.ConnectedProperties,
|
||||
Refs.getConnectedTexture,
|
||||
Refs.CTblockProperties, Refs.CTtileProperties,
|
||||
Refs.CPtileIcons, Refs.CPmatchesIcon
|
||||
)
|
||||
|
||||
init {
|
||||
Client.log(INFO, "Optifine CTM support is ${if (isAvailable) "enabled" else "disabled" }")
|
||||
@@ -45,7 +49,7 @@ object OptifineCTM {
|
||||
/** Get all the CTM [TextureAtlasSprite]s that could possibly be used for this block. */
|
||||
fun getAllCTM(state: IBlockState, icon: TextureAtlasSprite): Collection<TextureAtlasSprite> {
|
||||
val result = hashSetOf<TextureAtlasSprite>()
|
||||
if (state !is BlockStateBase) return result
|
||||
if (state !is BlockStateBase || !isAvailable) return result
|
||||
|
||||
connectedProperties.forEach { cp ->
|
||||
if (Refs.CPmatchesBlock.invoke(cp, Refs.getBlockId.invoke(state), Refs.getMetadata.invoke(state)) as Boolean &&
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package mods.betterfoliage.client.render
|
||||
|
||||
import mods.betterfoliage.client.config.BlockMatcher
|
||||
import mods.betterfoliage.client.integration.OptifineCTM
|
||||
import mods.betterfoliage.client.render.AbstractRenderColumn.BlockType.*
|
||||
import mods.betterfoliage.client.render.AbstractRenderColumn.QuadrantType.*
|
||||
import mods.octarinecore.client.render.*
|
||||
import mods.octarinecore.client.resource.BlockTextureInspector
|
||||
import mods.octarinecore.common.Int3
|
||||
import mods.octarinecore.common.Rotation
|
||||
import mods.octarinecore.common.face
|
||||
import mods.octarinecore.common.rot
|
||||
import mods.octarinecore.common.*
|
||||
import net.minecraft.block.state.IBlockState
|
||||
import net.minecraft.client.renderer.BlockRendererDispatcher
|
||||
import net.minecraft.client.renderer.VertexBuffer
|
||||
@@ -18,18 +16,34 @@ import net.minecraft.util.BlockRenderLayer
|
||||
import net.minecraft.util.EnumFacing
|
||||
import net.minecraft.util.EnumFacing.*
|
||||
|
||||
data class ColumnInfo(val topTexture: TextureAtlasSprite,
|
||||
val bottomTexture: TextureAtlasSprite,
|
||||
val sideTexture: TextureAtlasSprite)
|
||||
interface ColumnTextureResolver {
|
||||
val top: (ShadingContext, Int, Quad)->TextureAtlasSprite?
|
||||
val bottom: (ShadingContext, Int, Quad)->TextureAtlasSprite?
|
||||
val side: (ShadingContext, Int, Quad)->TextureAtlasSprite?
|
||||
}
|
||||
|
||||
open class ColumnTextures(val matcher: BlockMatcher) : BlockTextureInspector<ColumnInfo>() {
|
||||
data class StaticColumnInfo(val topTexture: TextureAtlasSprite,
|
||||
val bottomTexture: TextureAtlasSprite,
|
||||
val sideTexture: TextureAtlasSprite) : ColumnTextureResolver {
|
||||
override val top = { ctx: ShadingContext, idx: Int, quad: Quad ->
|
||||
OptifineCTM.override(topTexture, blockContext, UP.rotate(ctx.rotation))
|
||||
}
|
||||
override val bottom = { ctx: ShadingContext, idx: Int, quad: Quad ->
|
||||
OptifineCTM.override(bottomTexture, blockContext, DOWN.rotate(ctx.rotation))
|
||||
}
|
||||
override val side = { ctx: ShadingContext, idx: Int, quad: Quad ->
|
||||
OptifineCTM.override(sideTexture, blockContext, (if ((idx and 1) == 0) SOUTH else EAST).rotate(ctx.rotation))
|
||||
}
|
||||
}
|
||||
|
||||
open class ColumnTextures(val matcher: BlockMatcher) : BlockTextureInspector<StaticColumnInfo>() {
|
||||
init {
|
||||
matchClassAndModel(matcher, "block/column_side", listOf("end", "end", "side"))
|
||||
matchClassAndModel(matcher, "block/cube_column", listOf("end", "end", "side"))
|
||||
matchClassAndModel(matcher, "block/cube_all", listOf("all", "all", "all"))
|
||||
}
|
||||
override fun processTextures(state: IBlockState, textures: List<TextureAtlasSprite>, atlas: TextureMap) =
|
||||
ColumnInfo(textures[0], textures[1], textures[2])
|
||||
StaticColumnInfo(textures[0], textures[1], textures[2])
|
||||
}
|
||||
|
||||
/** Index of SOUTH-EAST quadrant. */
|
||||
@@ -120,14 +134,14 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
||||
abstract val axisFunc: (IBlockState)->EnumFacing.Axis?
|
||||
abstract val blockPredicate: (IBlockState)->Boolean
|
||||
|
||||
abstract val sideTexture: (ShadingContext, Int, Quad)->TextureAtlasSprite?
|
||||
abstract val upTexture: (ShadingContext, Int, Quad)->TextureAtlasSprite?
|
||||
abstract val downTexture: (ShadingContext, Int, Quad)->TextureAtlasSprite?
|
||||
abstract fun resolver(ctx: BlockContext): ColumnTextureResolver?
|
||||
|
||||
@Suppress("NON_EXHAUSTIVE_WHEN")
|
||||
override fun render(ctx: BlockContext, dispatcher: BlockRendererDispatcher, renderer: VertexBuffer, layer: BlockRenderLayer): Boolean {
|
||||
if (ctx.isSurroundedBy(surroundPredicate) ) return false
|
||||
|
||||
val columnTextures = resolver(ctx) ?: return false
|
||||
|
||||
// get AO data
|
||||
modelRenderer.updateShading(Int3.zero, allFaces)
|
||||
|
||||
@@ -170,15 +184,15 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
||||
sideModel,
|
||||
rotation,
|
||||
blockContext.blockCenter,
|
||||
icon = sideTexture,
|
||||
icon = columnTextures.side,
|
||||
postProcess = noPost
|
||||
)
|
||||
|
||||
// render top and bottom end of current quadrant
|
||||
var upModel: Model? = null
|
||||
var downModel: Model? = null
|
||||
var upIcon = upTexture
|
||||
var downIcon = downTexture
|
||||
var upIcon = columnTextures.top
|
||||
var downIcon = columnTextures.bottom
|
||||
var isLidUp = true
|
||||
var isLidDown = true
|
||||
|
||||
@@ -188,7 +202,7 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
||||
if (!connectPerpendicular) {
|
||||
upModel = flatTop(quadrants[idx])
|
||||
} else {
|
||||
upIcon = sideTexture
|
||||
upIcon = columnTextures.side
|
||||
upModel = extendTop(quadrants[idx])
|
||||
isLidUp = false
|
||||
}
|
||||
@@ -207,7 +221,7 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
||||
if (!connectPerpendicular) {
|
||||
downModel = flatBottom(quadrants[idx])
|
||||
} else {
|
||||
downIcon = sideTexture
|
||||
downIcon = columnTextures.side
|
||||
downModel = extendBottom(quadrants[idx])
|
||||
isLidDown = false
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class RenderLeaves : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||
}
|
||||
)
|
||||
}
|
||||
if (isSnowed) modelRenderer.render(
|
||||
if (isSnowed && Config.leaves.snowEnabled) modelRenderer.render(
|
||||
renderer,
|
||||
leavesModel.model,
|
||||
Rotation.identity,
|
||||
|
||||
@@ -42,6 +42,8 @@ class RenderLog : AbstractRenderColumn(BetterFoliageMod.MOD_ID) {
|
||||
}
|
||||
}
|
||||
|
||||
override fun resolver(ctx: BlockContext): ColumnTextureResolver? = columnTextures[ctx.blockState(Int3.zero)]
|
||||
|
||||
override val blockPredicate = { state: IBlockState -> Config.blocks.logs.matchesID(state.block) }
|
||||
override val surroundPredicate = { state: IBlockState -> state.isOpaqueCube && !Config.blocks.logs.matchesID(state.block) }
|
||||
|
||||
@@ -51,21 +53,4 @@ class RenderLog : AbstractRenderColumn(BetterFoliageMod.MOD_ID) {
|
||||
override val radiusLarge: Double get() = Config.roundLogs.radiusLarge
|
||||
override val radiusSmall: Double get() = Config.roundLogs.radiusSmall
|
||||
|
||||
override val downTexture = { ctx: ShadingContext, idx: Int, quad: Quad ->
|
||||
columnTextures[ctx.blockData(Int3.zero).state]?.bottomTexture?.let { base ->
|
||||
OptifineCTM.override(base, blockContext, DOWN.rotate(ctx.rotation))
|
||||
}
|
||||
}
|
||||
|
||||
override val sideTexture = { ctx: ShadingContext, idx: Int, quad: Quad ->
|
||||
columnTextures[ctx.blockData(Int3.zero).state]?.sideTexture?.let { base ->
|
||||
OptifineCTM.override(base, blockContext, (if ((idx and 1) == 0) SOUTH else EAST).rotate(ctx.rotation))
|
||||
}
|
||||
}
|
||||
|
||||
override val upTexture = { ctx: ShadingContext, idx: Int, quad: Quad ->
|
||||
columnTextures[ctx.blockData(Int3.zero).state]?.topTexture?.let { base ->
|
||||
OptifineCTM.override(base, blockContext, UP.rotate(ctx.rotation))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,7 @@ object LeafRegistry : BlockTextureInspector<TextureAtlasSprite>() {
|
||||
init {
|
||||
matchClassAndModel(Config.blocks.leaves, "minecraft:block/leaves", listOf("all"))
|
||||
matchClassAndModel(Config.blocks.leaves, "minecraft:block/cube_all", listOf("all"))
|
||||
matchClassAndModel(Config.blocks.leaves, "biomesoplenty:block/leaves_overlay", listOf("under"))
|
||||
}
|
||||
|
||||
operator fun get(state: IBlockState, world: IBlockAccess, pos: BlockPos, face: EnumFacing): LeafInfo? {
|
||||
|
||||
Reference in New Issue
Block a user