Merge branch 'kotlin-1.10' into kotlin-1.11.2
This commit is contained in:
@@ -13,7 +13,6 @@ import net.minecraft.client.renderer.BlockRendererDispatcher
|
||||
import net.minecraft.client.renderer.VertexBuffer
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite
|
||||
import net.minecraft.util.BlockRenderLayer
|
||||
import net.minecraft.util.EnumFacing
|
||||
import net.minecraft.util.EnumFacing.*
|
||||
import net.minecraftforge.fml.relauncher.Side
|
||||
import net.minecraftforge.fml.relauncher.SideOnly
|
||||
@@ -28,14 +27,18 @@ interface IColumnTextureInfo {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
interface IColumnRegistry {
|
||||
operator fun get(state: IBlockState): IColumnTextureInfo?
|
||||
operator fun get(state: IBlockState, rand: Int): IColumnTextureInfo?
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
data class StaticColumnInfo(override val axis: Axis?,
|
||||
val topTexture: TextureAtlasSprite,
|
||||
val bottomTexture: TextureAtlasSprite,
|
||||
val sideTexture: TextureAtlasSprite) : IColumnTextureInfo {
|
||||
val sideTextures: List<TextureAtlasSprite>) : IColumnTextureInfo {
|
||||
|
||||
// index offsets for EnumFacings, to make it less likely for neighboring faces to get the same bark texture
|
||||
val dirToIdx = arrayOf(0, 1, 2, 4, 3, 5)
|
||||
|
||||
override val top: QuadIconResolver = { ctx, _, _ ->
|
||||
OptifineCTM.override(topTexture, blockContext, UP.rotate(ctx.rotation))
|
||||
}
|
||||
@@ -43,7 +46,9 @@ data class StaticColumnInfo(override val axis: Axis?,
|
||||
OptifineCTM.override(bottomTexture, blockContext, DOWN.rotate(ctx.rotation))
|
||||
}
|
||||
override val side: QuadIconResolver = { ctx, idx, _ ->
|
||||
OptifineCTM.override(sideTexture, blockContext, (if ((idx and 1) == 0) SOUTH else EAST).rotate(ctx.rotation))
|
||||
val worldFace = (if ((idx and 1) == 0) SOUTH else EAST).rotate(ctx.rotation)
|
||||
val baseTexture = sideTextures[(blockContext.random(1) + dirToIdx[worldFace.ordinal]) % sideTextures.size]
|
||||
OptifineCTM.override(baseTexture, blockContext, worldFace)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +146,7 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
||||
override fun render(ctx: BlockContext, dispatcher: BlockRendererDispatcher, renderer: VertexBuffer, layer: BlockRenderLayer): Boolean {
|
||||
if (ctx.isSurroundedBy(surroundPredicate) ) return false
|
||||
|
||||
val columnTextures = registry[ctx.blockState(Int3.zero)]
|
||||
val columnTextures = registry[ctx.blockState(Int3.zero), ctx.random(0)]
|
||||
if (columnTextures == null) {
|
||||
Client.logRenderError(ctx.blockState(Int3.zero), ctx.pos)
|
||||
return renderWorldBlockBase(ctx, dispatcher, renderer, null)
|
||||
@@ -346,7 +351,7 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
||||
return if (!blockPredicate(state)) {
|
||||
if (state.isOpaqueCube) SOLID else NONSOLID
|
||||
} else {
|
||||
(registry[state]?.axis ?: if (Config.roundLogs.defaultY) Axis.Y else null)?.let {
|
||||
(registry[state, random(0)]?.axis ?: if (Config.roundLogs.defaultY) Axis.Y else null)?.let {
|
||||
if (it == axis) PARALLEL else PERPENDICULAR
|
||||
} ?: SOLID
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import mods.octarinecore.client.render.HSB
|
||||
import mods.octarinecore.common.Double3
|
||||
import mods.octarinecore.minmax
|
||||
import mods.octarinecore.random
|
||||
import mods.octarinecore.semiRandom
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.renderer.VertexBuffer
|
||||
import net.minecraft.util.EnumFacing.DOWN
|
||||
@@ -45,7 +46,7 @@ AbstractEntityFX(world, pos.x.toDouble() + 0.5, pos.y.toDouble(), pos.z.toDouble
|
||||
|
||||
val state = world.getBlockState(pos)
|
||||
val blockColor = Minecraft.getMinecraft().blockColors.colorMultiplier(state, world, pos, 0)
|
||||
val leafInfo = LeafRegistry.get(state, world, pos, DOWN)
|
||||
val leafInfo = LeafRegistry.get(state, world, pos, DOWN, semiRandom(pos.x, pos.y, pos.z, 0))
|
||||
if (leafInfo != null) {
|
||||
particleTexture = leafInfo.particleTextures?.get(rand.nextInt(1024))
|
||||
calculateParticleColor(leafInfo.averageColor, blockColor)
|
||||
|
||||
@@ -14,9 +14,6 @@ const val chamferAffinity = 0.9f
|
||||
/** Amount to shrink column extension bits to stop Z-fighting. */
|
||||
val zProtectionScale: Double3 get() = Double3(Config.roundLogs.zProtection, 1.0, Config.roundLogs.zProtection)
|
||||
|
||||
/** nVidia does it different... */
|
||||
val nVidia = GL11.glGetString(GL11.GL_VENDOR).toLowerCase().contains("nvidia")
|
||||
|
||||
fun Model.columnSide(radius: Double, yBottom: Double, yTop: Double, transform: (Quad) -> Quad = { it }) {
|
||||
val halfRadius = radius * 0.5
|
||||
listOf(
|
||||
@@ -96,14 +93,14 @@ fun Model.columnLid(radius: Double, transform: (Quad)->Quad = { it }) {
|
||||
1 -> EdgeInterpolateFallback(UP, SOUTH, 0.0)
|
||||
else -> vertex.aoShader
|
||||
})}
|
||||
.cycleVertices(if (nVidia) 0 else 1)
|
||||
.cycleVertices(if (Config.nVidia) 0 else 1)
|
||||
val q2 = Quad(v1, v4, v5, v6).setAoShader(faceOrientedAuto(overrideFace = UP, corner = cornerAo(Axis.Y)))
|
||||
.transformVI { vertex, idx -> vertex.copy(aoShader = when(idx) {
|
||||
0 -> FaceCenter(UP)
|
||||
3 -> EdgeInterpolateFallback(UP, EAST, 0.0)
|
||||
else -> vertex.aoShader
|
||||
})}
|
||||
.cycleVertices(if (nVidia) 0 else 1)
|
||||
.cycleVertices(if (Config.nVidia) 0 else 1)
|
||||
listOf(q1, q2).forEach { transform(it.setFlatShader(FaceFlat(UP))).add() }
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import mods.betterfoliage.BetterFoliageMod
|
||||
import mods.betterfoliage.client.Client
|
||||
import mods.betterfoliage.client.config.Config
|
||||
import mods.octarinecore.client.render.*
|
||||
import mods.octarinecore.client.resource.ModelVariant
|
||||
import mods.octarinecore.client.resource.TextureListModelProcessor
|
||||
import mods.octarinecore.client.resource.registerSprite
|
||||
import mods.octarinecore.common.Int3
|
||||
@@ -35,8 +36,9 @@ class RenderCactus : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||
|
||||
init { MinecraftForge.EVENT_BUS.register(this) }
|
||||
|
||||
override var stateToKey = mutableMapOf<IBlockState, List<String>>()
|
||||
override var stateToValue = mapOf<IBlockState, IColumnTextureInfo>()
|
||||
override var variants = mutableMapOf<IBlockState, MutableList<ModelVariant>>()
|
||||
override var variantToKey = mutableMapOf<ModelVariant, List<String>>()
|
||||
override var variantToValue = mapOf<ModelVariant, IColumnTextureInfo>()
|
||||
|
||||
override val logger = BetterFoliageMod.logDetail
|
||||
override val logName = "CactusTextures"
|
||||
@@ -45,14 +47,17 @@ class RenderCactus : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||
modelTextures("block/cactus", "top", "bottom", "side")
|
||||
)
|
||||
|
||||
override fun processStitch(state: IBlockState, key: List<String>, atlas: TextureMap): IColumnTextureInfo? {
|
||||
override fun processStitch(variant: ModelVariant, key: List<String>, atlas: TextureMap): IColumnTextureInfo? {
|
||||
val topTex = atlas.registerSprite(key[0])
|
||||
val bottomTex = atlas.registerSprite(key[1])
|
||||
val sideTex = atlas.registerSprite(key[2])
|
||||
return StaticColumnInfo(Axis.Y, topTex, bottomTex, sideTex)
|
||||
return StaticColumnInfo(Axis.Y, topTex, bottomTex, listOf(sideTex))
|
||||
}
|
||||
|
||||
override fun get(state: IBlockState) = stateToValue[state]
|
||||
override fun get(state: IBlockState, rand: Int): IColumnTextureInfo? {
|
||||
val variant = getVariant(state, rand) ?: return null
|
||||
return variantToValue[variant]
|
||||
}
|
||||
}
|
||||
|
||||
val modelStem = model {
|
||||
@@ -98,7 +103,7 @@ class RenderCactus : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||
|
||||
// get AO data
|
||||
modelRenderer.updateShading(Int3.zero, allFaces)
|
||||
val icons = cactusTextures[ctx.blockState(Int3.zero)] ?: return renderWorldBlockBase(ctx, dispatcher, renderer, null)
|
||||
val icons = cactusTextures[ctx.blockState(Int3.zero), ctx.random(0)] ?: return renderWorldBlockBase(ctx, dispatcher, renderer, null)
|
||||
|
||||
modelRenderer.render(
|
||||
renderer,
|
||||
|
||||
@@ -3,6 +3,7 @@ package mods.betterfoliage.client.render
|
||||
import mods.betterfoliage.BetterFoliageMod
|
||||
import mods.betterfoliage.client.Client
|
||||
import mods.betterfoliage.client.config.Config
|
||||
import mods.betterfoliage.client.integration.OptifineCTM
|
||||
import mods.betterfoliage.client.integration.ShadersModIntegration
|
||||
import mods.betterfoliage.client.texture.GrassRegistry
|
||||
import mods.octarinecore.client.render.*
|
||||
@@ -68,7 +69,7 @@ class RenderGrass : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||
Client.logRenderError(ctx.blockState(Int3.zero), ctx.pos)
|
||||
return renderWorldBlockBase(ctx, dispatcher, renderer, null)
|
||||
}
|
||||
val blockColor = ctx.blockData(Int3.zero).color
|
||||
val blockColor = OptifineCTM.getBlockColor(ctx)
|
||||
|
||||
if (connectedGrass) {
|
||||
// get full AO data
|
||||
|
||||
@@ -3,6 +3,7 @@ package mods.betterfoliage.client.render
|
||||
import mods.betterfoliage.BetterFoliageMod
|
||||
import mods.betterfoliage.client.Client
|
||||
import mods.betterfoliage.client.config.Config
|
||||
import mods.betterfoliage.client.integration.OptifineCTM
|
||||
import mods.betterfoliage.client.integration.ShadersModIntegration
|
||||
import mods.betterfoliage.client.texture.LeafRegistry
|
||||
import mods.octarinecore.PI2
|
||||
@@ -57,7 +58,7 @@ class RenderLeaves : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||
Client.logRenderError(ctx.blockState(Int3.zero), ctx.pos)
|
||||
return renderWorldBlockBase(ctx, dispatcher, renderer, layer)
|
||||
}
|
||||
val blockColor = ctx.blockData(Int3.zero).color
|
||||
val blockColor = OptifineCTM.getBlockColor(ctx)
|
||||
|
||||
renderWorldBlockBase(ctx, dispatcher, renderer, layer)
|
||||
if (!layer.isCutout) return true
|
||||
|
||||
@@ -3,6 +3,7 @@ package mods.betterfoliage.client.render
|
||||
import mods.betterfoliage.BetterFoliageMod
|
||||
import mods.betterfoliage.client.config.Config
|
||||
import mods.octarinecore.client.render.BlockContext
|
||||
import mods.octarinecore.client.resource.ModelVariant
|
||||
import mods.octarinecore.client.resource.TextureListModelProcessor
|
||||
import mods.octarinecore.client.resource.registerSprite
|
||||
import mods.octarinecore.common.config.ConfigurableBlockMatcher
|
||||
@@ -43,7 +44,7 @@ class RenderLog : AbstractRenderColumn(BetterFoliageMod.MOD_ID) {
|
||||
@SideOnly(Side.CLIENT)
|
||||
object LogRegistry : IColumnRegistry {
|
||||
val subRegistries: MutableList<IColumnRegistry> = mutableListOf()
|
||||
override fun get(state: IBlockState) = subRegistries.findFirst { it[state] }
|
||||
override fun get(state: IBlockState, rand: Int) = subRegistries.findFirst { it[state, rand] }
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -54,22 +55,27 @@ object StandardLogSupport : TextureListModelProcessor<IColumnTextureInfo>, IColu
|
||||
MinecraftForge.EVENT_BUS.register(this)
|
||||
}
|
||||
|
||||
override var stateToKey = mutableMapOf<IBlockState, List<String>>()
|
||||
override var stateToValue = mapOf<IBlockState, IColumnTextureInfo>()
|
||||
override var variants = mutableMapOf<IBlockState, MutableList<ModelVariant>>()
|
||||
override var variantToKey = mutableMapOf<ModelVariant, List<String>>()
|
||||
override var variantToValue = mapOf<ModelVariant, IColumnTextureInfo>()
|
||||
|
||||
override val logger = BetterFoliageMod.logDetail
|
||||
override val logName = "StandardLogSupport"
|
||||
override val matchClasses: ConfigurableBlockMatcher get() = Config.blocks.logClasses
|
||||
override val modelTextures: List<ModelTextureList> get() = Config.blocks.logModels.list
|
||||
|
||||
override fun processStitch(state: IBlockState, key: List<String>, atlas: TextureMap): IColumnTextureInfo? {
|
||||
override fun processStitch(variant: ModelVariant, key: List<String>, atlas: TextureMap): IColumnTextureInfo? {
|
||||
val topTex = atlas.registerSprite(key[0])
|
||||
val bottomTex = atlas.registerSprite(key[1])
|
||||
val sideTex = atlas.registerSprite(key[2])
|
||||
return StaticColumnInfo(getAxis(state), topTex, bottomTex, sideTex)
|
||||
val sideTexList = key.drop(2).map { atlas.registerSprite(it) }
|
||||
if (sideTexList.isEmpty()) return null
|
||||
return StaticColumnInfo(getAxis(variant.state), topTex, bottomTex, sideTexList)
|
||||
}
|
||||
|
||||
override fun get(state: IBlockState) = stateToValue[state]
|
||||
override fun get(state: IBlockState, rand: Int): IColumnTextureInfo? {
|
||||
val variant = getVariant(state, rand) ?: return null
|
||||
return variantToValue[variant]
|
||||
}
|
||||
|
||||
fun getAxis(state: IBlockState): Axis? {
|
||||
val axis = tryDefault(null) { state.getValue(BlockLog.LOG_AXIS).toString() } ?:
|
||||
|
||||
@@ -11,7 +11,6 @@ import mods.octarinecore.common.Double3
|
||||
import mods.octarinecore.common.Rotation
|
||||
import net.minecraft.client.renderer.BlockRendererDispatcher
|
||||
import net.minecraft.client.renderer.VertexBuffer
|
||||
import net.minecraft.init.Blocks
|
||||
import net.minecraft.util.BlockRenderLayer
|
||||
import net.minecraftforge.fml.relauncher.Side
|
||||
import net.minecraftforge.fml.relauncher.SideOnly
|
||||
@@ -29,8 +28,8 @@ class RenderMycelium : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||
|
||||
override fun isEligible(ctx: BlockContext): Boolean {
|
||||
if (!Config.enabled || !Config.shortGrass.myceliumEnabled) return false
|
||||
return ctx.block == Blocks.MYCELIUM &&
|
||||
ctx.cameraDistance < Config.shortGrass.distance
|
||||
return Config.blocks.mycelium.matchesClass(ctx.block) &&
|
||||
ctx.cameraDistance < Config.shortGrass.distance
|
||||
}
|
||||
|
||||
override fun render(ctx: BlockContext, dispatcher: BlockRendererDispatcher, renderer: VertexBuffer, layer: BlockRenderLayer): Boolean {
|
||||
|
||||
@@ -9,7 +9,6 @@ import mods.octarinecore.common.Rotation
|
||||
import mods.octarinecore.random
|
||||
import net.minecraft.client.renderer.BlockRendererDispatcher
|
||||
import net.minecraft.client.renderer.VertexBuffer
|
||||
import net.minecraft.init.Blocks
|
||||
import net.minecraft.util.BlockRenderLayer
|
||||
import net.minecraft.util.EnumFacing.*
|
||||
import net.minecraftforge.fml.relauncher.Side
|
||||
@@ -35,8 +34,8 @@ class RenderNetherrack : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID)
|
||||
|
||||
override fun isEligible(ctx: BlockContext): Boolean {
|
||||
if (!Config.enabled || !Config.netherrack.enabled) return false
|
||||
return ctx.block == Blocks.NETHERRACK &&
|
||||
ctx.cameraDistance < Config.netherrack.distance
|
||||
return Config.blocks.netherrack.matchesClass(ctx.block) &&
|
||||
ctx.cameraDistance < Config.netherrack.distance
|
||||
}
|
||||
|
||||
override fun render(ctx: BlockContext, dispatcher: BlockRendererDispatcher, renderer: VertexBuffer, layer: BlockRenderLayer): Boolean {
|
||||
|
||||
Reference in New Issue
Block a user