disable Optifine CTM support, fix custom colors
This commit is contained in:
@@ -71,7 +71,7 @@ object Client {
|
|||||||
LeafWindTracker,
|
LeafWindTracker,
|
||||||
RisingSoulTextures,
|
RisingSoulTextures,
|
||||||
ShadersModIntegration,
|
ShadersModIntegration,
|
||||||
OptifineCTM,
|
OptifineCustomColors,
|
||||||
ForestryIntegration,
|
ForestryIntegration,
|
||||||
IC2Integration,
|
IC2Integration,
|
||||||
TechRebornIntegration,
|
TechRebornIntegration,
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ import net.minecraftforge.fml.relauncher.SideOnly
|
|||||||
import org.apache.logging.log4j.Level.INFO
|
import org.apache.logging.log4j.Level.INFO
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration for OptiFine.
|
* Integration for OptiFine CTM.
|
||||||
|
*
|
||||||
|
* Currently broken and unused
|
||||||
*/
|
*/
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@@ -33,17 +35,13 @@ object OptifineCTM {
|
|||||||
Refs.CTblockProperties, Refs.CTtileProperties,
|
Refs.CTblockProperties, Refs.CTtileProperties,
|
||||||
Refs.CPtileIcons, Refs.CPmatchesIcon
|
Refs.CPtileIcons, Refs.CPmatchesIcon
|
||||||
)
|
)
|
||||||
val isColorAvailable = allAvailable(
|
|
||||||
Refs.CustomColors, Refs.getColorMultiplier
|
|
||||||
)
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
Client.log(INFO, "Optifine CTM support is ${if (isCTMAvailable) "enabled" else "disabled" }")
|
Client.log(INFO, "Optifine CTM support is ${if (isCTMAvailable) "enabled" else "disabled" }")
|
||||||
Client.log(INFO, "Optifine custom color support is ${if (isColorAvailable) "enabled" else "disabled" }")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val renderEnv by ThreadLocalDelegate { OptifineRenderEnv() }
|
val renderEnv by ThreadLocalDelegate { OptifineRenderEnv() }
|
||||||
val fakeQuad = BakedQuad(IntArray(0), 1, EnumFacing.UP, null, true, DefaultVertexFormats.BLOCK)
|
|
||||||
val isCustomColors: Boolean get() = if (!isCTMAvailable) false else Minecraft.getMinecraft().gameSettings.reflectField<Boolean>("ofCustomColors") ?: false
|
val isCustomColors: Boolean get() = if (!isCTMAvailable) false else Minecraft.getMinecraft().gameSettings.reflectField<Boolean>("ofCustomColors") ?: false
|
||||||
|
|
||||||
val connectedProperties: Iterable<Any> get() {
|
val connectedProperties: Iterable<Any> get() {
|
||||||
@@ -88,13 +86,7 @@ object OptifineCTM {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getBlockColor(ctx: BlockContext): Int {
|
|
||||||
val ofColor = if (isColorAvailable && Minecraft.getMinecraft().gameSettings.reflectField<Boolean>("ofCustomColors") == true) {
|
|
||||||
renderEnv.reset(ctx.world!!, ctx.blockState(Int3.zero), ctx.pos)
|
|
||||||
Refs.getColorMultiplier.invokeStatic(fakeQuad, ctx.blockState(Int3.zero), ctx.world!!, ctx.pos, renderEnv.wrapped) as? Int
|
|
||||||
} else null
|
|
||||||
return if (ofColor == null || ofColor == -1) ctx.blockData(Int3.zero).color else ofColor
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package mods.betterfoliage.client.integration
|
||||||
|
|
||||||
|
import mods.betterfoliage.client.Client
|
||||||
|
import mods.betterfoliage.loader.Refs
|
||||||
|
import mods.octarinecore.client.render.BlockContext
|
||||||
|
import mods.octarinecore.common.Int3
|
||||||
|
import mods.octarinecore.metaprog.allAvailable
|
||||||
|
import mods.octarinecore.metaprog.reflectField
|
||||||
|
import net.minecraft.client.Minecraft
|
||||||
|
import net.minecraft.client.renderer.block.model.BakedQuad
|
||||||
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats
|
||||||
|
import net.minecraft.util.EnumFacing
|
||||||
|
import net.minecraftforge.fml.relauncher.Side
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly
|
||||||
|
import org.apache.logging.log4j.Level
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integration for OptiFine custom block colors.
|
||||||
|
*/
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
object OptifineCustomColors {
|
||||||
|
|
||||||
|
val isColorAvailable = allAvailable(
|
||||||
|
Refs.CustomColors, Refs.getColorMultiplier
|
||||||
|
)
|
||||||
|
|
||||||
|
init {
|
||||||
|
Client.log(Level.INFO, "Optifine custom color support is ${if (isColorAvailable) "enabled" else "disabled" }")
|
||||||
|
}
|
||||||
|
|
||||||
|
val fakeQuad = BakedQuad(IntArray(0), 1, EnumFacing.UP, null, true, DefaultVertexFormats.BLOCK)
|
||||||
|
|
||||||
|
fun getBlockColor(ctx: BlockContext): Int {
|
||||||
|
val ofColor = if (isColorAvailable && Minecraft.getMinecraft().gameSettings.reflectField<Boolean>("ofCustomColors") == true) {
|
||||||
|
OptifineCTM.renderEnv.reset(ctx.world!!, ctx.blockState(Int3.zero), ctx.pos)
|
||||||
|
Refs.getColorMultiplier.invokeStatic(fakeQuad, ctx.blockState(Int3.zero), ctx.world!!, ctx.pos, OptifineCTM.renderEnv.wrapped) as? Int
|
||||||
|
} else null
|
||||||
|
return if (ofColor == null || ofColor == -1) ctx.blockData(Int3.zero).color else ofColor
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ import mods.betterfoliage.client.render.StaticColumnInfo
|
|||||||
import mods.betterfoliage.client.texture.StandardLeafSupport
|
import mods.betterfoliage.client.texture.StandardLeafSupport
|
||||||
import mods.betterfoliage.loader.Refs
|
import mods.betterfoliage.loader.Refs
|
||||||
import mods.octarinecore.client.render.Quad
|
import mods.octarinecore.client.render.Quad
|
||||||
|
import mods.octarinecore.client.render.QuadIconResolver
|
||||||
import mods.octarinecore.client.render.ShadingContext
|
import mods.octarinecore.client.render.ShadingContext
|
||||||
import mods.octarinecore.client.render.blockContext
|
import mods.octarinecore.client.render.blockContext
|
||||||
import mods.octarinecore.client.resource.*
|
import mods.octarinecore.client.resource.*
|
||||||
@@ -72,16 +73,11 @@ data class RubberLogColumnInfo(override val axis: EnumFacing.Axis?,
|
|||||||
val bottomTexture: TextureAtlasSprite,
|
val bottomTexture: TextureAtlasSprite,
|
||||||
val sideTexture: TextureAtlasSprite,
|
val sideTexture: TextureAtlasSprite,
|
||||||
val spotTexture: TextureAtlasSprite): IColumnTextureInfo {
|
val spotTexture: TextureAtlasSprite): IColumnTextureInfo {
|
||||||
override val top = { ctx: ShadingContext, idx: Int, quad: Quad ->
|
override val top: QuadIconResolver = { _, _, _ -> topTexture }
|
||||||
OptifineCTM.override(topTexture, blockContext, EnumFacing.UP.rotate(ctx.rotation))
|
override val bottom: QuadIconResolver = { _, _, _ -> bottomTexture }
|
||||||
}
|
override val side: QuadIconResolver = { ctx: ShadingContext, idx: Int, quad: Quad ->
|
||||||
override val bottom = { ctx: ShadingContext, idx: Int, quad: Quad ->
|
|
||||||
OptifineCTM.override(bottomTexture, blockContext, EnumFacing.DOWN.rotate(ctx.rotation))
|
|
||||||
}
|
|
||||||
override val side = { ctx: ShadingContext, idx: Int, quad: Quad ->
|
|
||||||
val worldRelativeSide = (if ((idx and 1) == 0) EnumFacing.SOUTH else EnumFacing.EAST).rotate(ctx.rotation)
|
val worldRelativeSide = (if ((idx and 1) == 0) EnumFacing.SOUTH else EnumFacing.EAST).rotate(ctx.rotation)
|
||||||
val texture = if (worldRelativeSide == spotDir) spotTexture else sideTexture
|
if (worldRelativeSide == spotDir) spotTexture else sideTexture
|
||||||
OptifineCTM.override(texture, blockContext, worldRelativeSide)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,16 +39,11 @@ data class StaticColumnInfo(override val axis: Axis?,
|
|||||||
// index offsets for EnumFacings, to make it less likely for neighboring faces to get the same bark texture
|
// 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)
|
val dirToIdx = arrayOf(0, 1, 2, 4, 3, 5)
|
||||||
|
|
||||||
override val top: QuadIconResolver = { ctx, _, _ ->
|
override val top: QuadIconResolver = { _, _, _ -> topTexture }
|
||||||
OptifineCTM.override(topTexture, blockContext, UP.rotate(ctx.rotation))
|
override val bottom: QuadIconResolver = { _, _, _ -> bottomTexture }
|
||||||
}
|
|
||||||
override val bottom: QuadIconResolver = { ctx, _, _ ->
|
|
||||||
OptifineCTM.override(bottomTexture, blockContext, DOWN.rotate(ctx.rotation))
|
|
||||||
}
|
|
||||||
override val side: QuadIconResolver = { ctx, idx, _ ->
|
override val side: QuadIconResolver = { ctx, idx, _ ->
|
||||||
val worldFace = (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]
|
sideTextures[(blockContext.random(1) + dirToIdx[worldFace.ordinal]) % sideTextures.size]
|
||||||
OptifineCTM.override(baseTexture, blockContext, worldFace)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import mods.betterfoliage.BetterFoliageMod
|
|||||||
import mods.betterfoliage.client.Client
|
import mods.betterfoliage.client.Client
|
||||||
import mods.betterfoliage.client.config.Config
|
import mods.betterfoliage.client.config.Config
|
||||||
import mods.betterfoliage.client.integration.OptifineCTM
|
import mods.betterfoliage.client.integration.OptifineCTM
|
||||||
|
import mods.betterfoliage.client.integration.OptifineCustomColors
|
||||||
import mods.betterfoliage.client.integration.ShadersModIntegration
|
import mods.betterfoliage.client.integration.ShadersModIntegration
|
||||||
import mods.betterfoliage.client.texture.GrassRegistry
|
import mods.betterfoliage.client.texture.GrassRegistry
|
||||||
import mods.octarinecore.client.render.*
|
import mods.octarinecore.client.render.*
|
||||||
@@ -69,7 +70,7 @@ class RenderGrass : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
|||||||
Client.logRenderError(ctx.blockState(Int3.zero), ctx.pos)
|
Client.logRenderError(ctx.blockState(Int3.zero), ctx.pos)
|
||||||
return renderWorldBlockBase(ctx, dispatcher, renderer, null)
|
return renderWorldBlockBase(ctx, dispatcher, renderer, null)
|
||||||
}
|
}
|
||||||
val blockColor = OptifineCTM.getBlockColor(ctx)
|
val blockColor = OptifineCustomColors.getBlockColor(ctx)
|
||||||
|
|
||||||
if (connectedGrass) {
|
if (connectedGrass) {
|
||||||
// get full AO data
|
// get full AO data
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import mods.betterfoliage.BetterFoliageMod
|
|||||||
import mods.betterfoliage.client.Client
|
import mods.betterfoliage.client.Client
|
||||||
import mods.betterfoliage.client.config.Config
|
import mods.betterfoliage.client.config.Config
|
||||||
import mods.betterfoliage.client.integration.OptifineCTM
|
import mods.betterfoliage.client.integration.OptifineCTM
|
||||||
|
import mods.betterfoliage.client.integration.OptifineCustomColors
|
||||||
import mods.betterfoliage.client.integration.ShadersModIntegration
|
import mods.betterfoliage.client.integration.ShadersModIntegration
|
||||||
import mods.betterfoliage.client.texture.LeafRegistry
|
import mods.betterfoliage.client.texture.LeafRegistry
|
||||||
import mods.octarinecore.PI2
|
import mods.octarinecore.PI2
|
||||||
@@ -58,7 +59,7 @@ class RenderLeaves : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
|||||||
Client.logRenderError(ctx.blockState(Int3.zero), ctx.pos)
|
Client.logRenderError(ctx.blockState(Int3.zero), ctx.pos)
|
||||||
return renderWorldBlockBase(ctx, dispatcher, renderer, layer)
|
return renderWorldBlockBase(ctx, dispatcher, renderer, layer)
|
||||||
}
|
}
|
||||||
val blockColor = OptifineCTM.getBlockColor(ctx)
|
val blockColor = OptifineCustomColors.getBlockColor(ctx)
|
||||||
|
|
||||||
renderWorldBlockBase(ctx, dispatcher, renderer, layer)
|
renderWorldBlockBase(ctx, dispatcher, renderer, layer)
|
||||||
if (!layer.isCutout) return true
|
if (!layer.isCutout) return true
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ object StandardGrassSupport :
|
|||||||
override fun get(state: IBlockState, world: IBlockAccess, pos: BlockPos, face: EnumFacing, rand: Int): GrassInfo? {
|
override fun get(state: IBlockState, world: IBlockAccess, pos: BlockPos, face: EnumFacing, rand: Int): GrassInfo? {
|
||||||
val variant = getVariant(state, rand) ?: return null
|
val variant = getVariant(state, rand) ?: return null
|
||||||
val baseTexture = variantToValue[variant] ?: return null
|
val baseTexture = variantToValue[variant] ?: return null
|
||||||
return textureToValue[OptifineCTM.override(baseTexture, world, pos, face)] ?: textureToValue[baseTexture]
|
return textureToValue[baseTexture]
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun get(state: IBlockState, rand: Int): GrassInfo? {
|
override fun get(state: IBlockState, rand: Int): GrassInfo? {
|
||||||
@@ -85,13 +85,7 @@ object StandardGrassSupport :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun processStitch(variant: ModelVariant, key: List<String>, atlas: TextureMap) = atlas.registerSprite(key[0])
|
override fun processStitch(variant: ModelVariant, key: List<String>, atlas: TextureMap) = atlas.registerSprite(key[0])
|
||||||
|
override fun processTexture(variants: List<ModelVariant>, texture: TextureAtlasSprite, atlas: TextureMap) { registerGrass(texture, atlas) }
|
||||||
override fun processTexture(variants: List<ModelVariant>, texture: TextureAtlasSprite, atlas: TextureMap) {
|
|
||||||
registerGrass(texture, atlas)
|
|
||||||
OptifineCTM.getAllCTM(variants.map { it.state }, texture).forEach {
|
|
||||||
registerGrass(it, atlas)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun registerGrass(texture: TextureAtlasSprite, atlas: TextureMap) {
|
fun registerGrass(texture: TextureAtlasSprite, atlas: TextureMap) {
|
||||||
logger.log(Level.DEBUG, "$logName: texture ${texture.iconName}")
|
logger.log(Level.DEBUG, "$logName: texture ${texture.iconName}")
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ object StandardLeafSupport :
|
|||||||
override fun get(state: IBlockState, world: IBlockAccess, pos: BlockPos, face: EnumFacing, rand: Int): LeafInfo? {
|
override fun get(state: IBlockState, world: IBlockAccess, pos: BlockPos, face: EnumFacing, rand: Int): LeafInfo? {
|
||||||
val variant = getVariant(state, rand) ?: return null
|
val variant = getVariant(state, rand) ?: return null
|
||||||
val baseTexture = variantToValue[variant] ?: return null
|
val baseTexture = variantToValue[variant] ?: return null
|
||||||
return textureToValue[OptifineCTM.override(baseTexture, world, pos, face)] ?: textureToValue[baseTexture]
|
return textureToValue[baseTexture]
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun get(state: IBlockState, rand: Int): LeafInfo? {
|
override fun get(state: IBlockState, rand: Int): LeafInfo? {
|
||||||
@@ -123,10 +123,6 @@ object StandardLeafSupport :
|
|||||||
logger?.log(Level.DEBUG, "$logName: #variants ${variants.size}")
|
logger?.log(Level.DEBUG, "$logName: #variants ${variants.size}")
|
||||||
logger?.log(Level.DEBUG, "$logName: #states ${variants.distinctBy { it.state }.size}")
|
logger?.log(Level.DEBUG, "$logName: #states ${variants.distinctBy { it.state }.size}")
|
||||||
registerLeaf(texture, atlas)
|
registerLeaf(texture, atlas)
|
||||||
OptifineCTM.getAllCTM(variants.map { it.state }, texture).forEach {
|
|
||||||
logger?.log(Level.DEBUG, "$logName: CTM ${texture.iconName}")
|
|
||||||
registerLeaf(it, atlas)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun registerLeaf(texture: TextureAtlasSprite, atlas: TextureMap) {
|
fun registerLeaf(texture: TextureAtlasSprite, atlas: TextureMap) {
|
||||||
|
|||||||
@@ -93,25 +93,27 @@ object Refs {
|
|||||||
val getBlockId = MethodRef(BlockStateBase, "getBlockId", ClassRef.int);
|
val getBlockId = MethodRef(BlockStateBase, "getBlockId", ClassRef.int);
|
||||||
val getMetadata = MethodRef(BlockStateBase, "getMetadata", ClassRef.int);
|
val getMetadata = MethodRef(BlockStateBase, "getMetadata", ClassRef.int);
|
||||||
|
|
||||||
val RenderEnv = ClassRef("RenderEnv")
|
// Optifine: CTM
|
||||||
|
val RenderEnv = ClassRef("net.optifine.render.RenderEnv")
|
||||||
val RenderEnv_reset = MethodRef(RenderEnv, "reset", ClassRef.void, IBlockAccess, IBlockState, BlockPos)
|
val RenderEnv_reset = MethodRef(RenderEnv, "reset", ClassRef.void, IBlockAccess, IBlockState, BlockPos)
|
||||||
val ConnectedTextures = ClassRef("ConnectedTextures")
|
val ConnectedTextures = ClassRef("net.optifine.ConnectedTextures")
|
||||||
val getConnectedTexture = MethodRef(ConnectedTextures, "getConnectedTextureMultiPass", TextureAtlasSprite, IBlockAccess, IBlockState, BlockPos, EnumFacing, TextureAtlasSprite, RenderEnv)
|
val getConnectedTexture = MethodRef(ConnectedTextures, "getConnectedTextureMultiPass", TextureAtlasSprite, IBlockAccess, IBlockState, BlockPos, EnumFacing, TextureAtlasSprite, RenderEnv)
|
||||||
val CTblockProperties = FieldRef(ConnectedTextures, "blockProperties", null)
|
val CTblockProperties = FieldRef(ConnectedTextures, "blockProperties", null)
|
||||||
val CTtileProperties = FieldRef(ConnectedTextures, "tileProperties", null)
|
val CTtileProperties = FieldRef(ConnectedTextures, "tileProperties", null)
|
||||||
|
|
||||||
val ConnectedProperties = ClassRef("ConnectedProperties")
|
val ConnectedProperties = ClassRef("net.optifine.ConnectedProperties")
|
||||||
val CPtileIcons = FieldRef(ConnectedProperties, "tileIcons", null)
|
val CPtileIcons = FieldRef(ConnectedProperties, "tileIcons", null)
|
||||||
val CPmatchesBlock = MethodRef(ConnectedProperties, "matchesBlock", ClassRef.boolean, ClassRef.int, ClassRef.int)
|
val CPmatchesBlock = MethodRef(ConnectedProperties, "matchesBlock", ClassRef.boolean, ClassRef.int, ClassRef.int)
|
||||||
val CPmatchesIcon = MethodRef(ConnectedProperties, "matchesIcon", ClassRef.boolean, TextureAtlasSprite)
|
val CPmatchesIcon = MethodRef(ConnectedProperties, "matchesIcon", ClassRef.boolean, TextureAtlasSprite)
|
||||||
|
|
||||||
val quadSprite = FieldRef(BufferBuilder, "quadSprite", TextureAtlasSprite)
|
val quadSprite = FieldRef(BufferBuilder, "quadSprite", TextureAtlasSprite)
|
||||||
|
|
||||||
val CustomColors = ClassRef("CustomColors")
|
// Optifine: custom colors
|
||||||
|
val CustomColors = ClassRef("net.optifine.CustomColors")
|
||||||
val getColorMultiplier = MethodRef(CustomColors, "getColorMultiplier", ClassRef.int, BakedQuad, IBlockState, IBlockAccess, BlockPos, RenderEnv)
|
val getColorMultiplier = MethodRef(CustomColors, "getColorMultiplier", ClassRef.int, BakedQuad, IBlockState, IBlockAccess, BlockPos, RenderEnv)
|
||||||
|
|
||||||
|
|
||||||
// ShadersMod
|
// Optifine: shaders
|
||||||
val SVertexBuilder = ClassRef("net.optifine.shaders.SVertexBuilder")
|
val SVertexBuilder = ClassRef("net.optifine.shaders.SVertexBuilder")
|
||||||
val sVertexBuilder = FieldRef(BufferBuilder, "sVertexBuilder", SVertexBuilder)
|
val sVertexBuilder = FieldRef(BufferBuilder, "sVertexBuilder", SVertexBuilder)
|
||||||
val pushEntity_state = MethodRef(SVertexBuilder, "pushEntity", ClassRef.void, IBlockState, BlockPos, IBlockAccess, BufferBuilder)
|
val pushEntity_state = MethodRef(SVertexBuilder, "pushEntity", ClassRef.void, IBlockState, BlockPos, IBlockAccess, BufferBuilder)
|
||||||
|
|||||||
Reference in New Issue
Block a user