Merge branch 'kotlin-1.10' into kotlin-1.11
This commit is contained in:
@@ -2,7 +2,7 @@ apply plugin: "net.minecraftforge.gradle.forge"
|
|||||||
apply plugin: 'kotlin'
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
group = 'com.github.octarine-noise'
|
group = 'com.github.octarine-noise'
|
||||||
version = "2.1.2"
|
version = "2.1.3"
|
||||||
archivesBaseName = rootProject.name + '-MC1.11'
|
archivesBaseName = rootProject.name + '-MC1.11'
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ package mods.betterfoliage.client
|
|||||||
|
|
||||||
import mods.betterfoliage.BetterFoliageMod
|
import mods.betterfoliage.BetterFoliageMod
|
||||||
import mods.betterfoliage.client.gui.ConfigGuiFactory
|
import mods.betterfoliage.client.gui.ConfigGuiFactory
|
||||||
import mods.betterfoliage.client.integration.ForestryIntegration
|
import mods.betterfoliage.client.integration.*
|
||||||
import mods.betterfoliage.client.integration.OptifineCTM
|
|
||||||
import mods.betterfoliage.client.integration.ShadersModIntegration
|
|
||||||
import mods.betterfoliage.client.render.*
|
import mods.betterfoliage.client.render.*
|
||||||
import mods.betterfoliage.client.texture.*
|
import mods.betterfoliage.client.texture.*
|
||||||
import mods.octarinecore.client.KeyHandler
|
import mods.octarinecore.client.KeyHandler
|
||||||
@@ -63,12 +61,14 @@ object Client {
|
|||||||
val singletons = listOf(
|
val singletons = listOf(
|
||||||
LeafRegistry,
|
LeafRegistry,
|
||||||
GrassRegistry,
|
GrassRegistry,
|
||||||
LogRegistry,
|
|
||||||
LeafWindTracker,
|
LeafWindTracker,
|
||||||
RisingSoulTextures,
|
RisingSoulTextures,
|
||||||
ShadersModIntegration,
|
ShadersModIntegration,
|
||||||
OptifineCTM,
|
OptifineCTM,
|
||||||
ForestryIntegration
|
ForestryIntegration,
|
||||||
|
IC2Integration,
|
||||||
|
TechRebornIntegration,
|
||||||
|
StandardLogSupport // add _after_ all other log registries
|
||||||
)
|
)
|
||||||
|
|
||||||
fun log(level: Level, msg: String) {
|
fun log(level: Level, msg: String) {
|
||||||
|
|||||||
@@ -3,10 +3,7 @@ package mods.betterfoliage.client.integration
|
|||||||
import mods.betterfoliage.BetterFoliageMod
|
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.render.IColumnRegistry
|
import mods.betterfoliage.client.render.*
|
||||||
import mods.betterfoliage.client.render.IColumnTextureResolver
|
|
||||||
import mods.betterfoliage.client.render.LogRegistry
|
|
||||||
import mods.betterfoliage.client.render.StaticColumnInfo
|
|
||||||
import mods.betterfoliage.client.texture.ILeafRegistry
|
import mods.betterfoliage.client.texture.ILeafRegistry
|
||||||
import mods.betterfoliage.client.texture.LeafInfo
|
import mods.betterfoliage.client.texture.LeafInfo
|
||||||
import mods.betterfoliage.client.texture.LeafRegistry
|
import mods.betterfoliage.client.texture.LeafRegistry
|
||||||
@@ -72,6 +69,7 @@ object ForestryIntegration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
object ForestryLeavesSupport : ILeafRegistry {
|
object ForestryLeavesSupport : ILeafRegistry {
|
||||||
|
|
||||||
val textureToValue = mutableMapOf<ResourceLocation, LeafInfo>()
|
val textureToValue = mutableMapOf<ResourceLocation, LeafInfo>()
|
||||||
@@ -127,10 +125,11 @@ object ForestryLeavesSupport : ILeafRegistry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object ForestryLogSupport : ModelProcessor<List<String>, IColumnTextureResolver>, IColumnRegistry {
|
@SideOnly(Side.CLIENT)
|
||||||
|
object ForestryLogSupport : ModelProcessor<List<String>, IColumnTextureInfo>, IColumnRegistry {
|
||||||
|
|
||||||
override var stateToKey = mutableMapOf<IBlockState, List<String>>()
|
override var stateToKey = mutableMapOf<IBlockState, List<String>>()
|
||||||
override var stateToValue = mapOf<IBlockState, IColumnTextureResolver>()
|
override var stateToValue = mapOf<IBlockState, IColumnTextureInfo>()
|
||||||
|
|
||||||
override val logger = BetterFoliageMod.logDetail
|
override val logger = BetterFoliageMod.logDetail
|
||||||
|
|
||||||
@@ -156,10 +155,10 @@ object ForestryLogSupport : ModelProcessor<List<String>, IColumnTextureResolver>
|
|||||||
return if (bark != null && heart != null) listOf(heart, bark) else null
|
return if (bark != null && heart != null) listOf(heart, bark) else null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processStitch(state: IBlockState, key: List<String>, atlas: TextureMap): IColumnTextureResolver? {
|
override fun processStitch(state: IBlockState, key: List<String>, atlas: TextureMap): IColumnTextureInfo? {
|
||||||
val heart = atlas.registerSprite(key[0])
|
val heart = atlas.registerSprite(key[0])
|
||||||
val bark = atlas.registerSprite(key[1])
|
val bark = atlas.registerSprite(key[1])
|
||||||
return StaticColumnInfo(heart, heart, bark)
|
return StaticColumnInfo(StandardLogSupport.getAxis(state), heart, heart, bark)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun get(state: IBlockState) = stateToValue[state]
|
override fun get(state: IBlockState) = stateToValue[state]
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ object OptifineCTM {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
class OptifineRenderEnv {
|
class OptifineRenderEnv {
|
||||||
val wrapped: Any = Refs.RenderEnv.element!!.getDeclaredConstructor(
|
val wrapped: Any = Refs.RenderEnv.element!!.getDeclaredConstructor(
|
||||||
Refs.IBlockAccess.element, Refs.IBlockState.element, Refs.BlockPos.element
|
Refs.IBlockAccess.element, Refs.IBlockState.element, Refs.BlockPos.element
|
||||||
|
|||||||
@@ -0,0 +1,217 @@
|
|||||||
|
package mods.betterfoliage.client.integration
|
||||||
|
|
||||||
|
import mods.betterfoliage.BetterFoliageMod
|
||||||
|
import mods.betterfoliage.client.Client
|
||||||
|
import mods.betterfoliage.client.config.Config
|
||||||
|
import mods.betterfoliage.client.render.IColumnRegistry
|
||||||
|
import mods.betterfoliage.client.render.IColumnTextureInfo
|
||||||
|
import mods.betterfoliage.client.render.LogRegistry
|
||||||
|
import mods.betterfoliage.client.render.StaticColumnInfo
|
||||||
|
import mods.betterfoliage.client.texture.LeafRegistry
|
||||||
|
import mods.betterfoliage.client.texture.StandardLeafSupport
|
||||||
|
import mods.betterfoliage.loader.Refs
|
||||||
|
import mods.octarinecore.client.render.Quad
|
||||||
|
import mods.octarinecore.client.render.ShadingContext
|
||||||
|
import mods.octarinecore.client.render.blockContext
|
||||||
|
import mods.octarinecore.client.resource.ModelProcessor
|
||||||
|
import mods.octarinecore.client.resource.derivesFrom
|
||||||
|
import mods.octarinecore.client.resource.get
|
||||||
|
import mods.octarinecore.client.resource.modelBlockAndLoc
|
||||||
|
import mods.octarinecore.common.rotate
|
||||||
|
import mods.octarinecore.metaprog.ClassRef
|
||||||
|
import mods.octarinecore.metaprog.MethodRef
|
||||||
|
import mods.octarinecore.metaprog.allAvailable
|
||||||
|
import net.minecraft.block.properties.PropertyDirection
|
||||||
|
import net.minecraft.block.state.IBlockState
|
||||||
|
import net.minecraft.client.renderer.block.model.ModelResourceLocation
|
||||||
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite
|
||||||
|
import net.minecraft.client.renderer.texture.TextureMap
|
||||||
|
import net.minecraft.util.EnumFacing
|
||||||
|
import net.minecraft.util.ResourceLocation
|
||||||
|
import net.minecraftforge.client.model.IModel
|
||||||
|
import net.minecraftforge.common.MinecraftForge
|
||||||
|
import net.minecraftforge.fml.common.Loader
|
||||||
|
import net.minecraftforge.fml.relauncher.Side
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly
|
||||||
|
import org.apache.logging.log4j.Level
|
||||||
|
import org.apache.logging.log4j.Logger
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
object IC2Integration {
|
||||||
|
|
||||||
|
val BlockRubWood = ClassRef("ic2.core.block.BlockRubWood")
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (Loader.isModLoaded("IC2") && allAvailable(BlockRubWood)) {
|
||||||
|
Client.log(Level.INFO, "IC2 support initialized")
|
||||||
|
LogRegistry.subRegistries.add(IC2LogSupport)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
object TechRebornIntegration {
|
||||||
|
|
||||||
|
val BlockRubberLog = ClassRef("techreborn.blocks.BlockRubberLog")
|
||||||
|
val ITexturedBlock = ClassRef("me.modmuss50.jsonDestroyer.api.ITexturedBlock")
|
||||||
|
val getTextureNameFromState = MethodRef(ITexturedBlock, "getTextureNameFromState", Refs.String, Refs.IBlockState, Refs.EnumFacing)
|
||||||
|
|
||||||
|
val rubberLogTextureNames = listOf(
|
||||||
|
"techreborn:blocks/rubber_log_top",
|
||||||
|
"techreborn:blocks/rubber_log_top",
|
||||||
|
"techreborn:blocks/rubber_log_side",
|
||||||
|
"techreborn:blocks/rubber_log_sap"
|
||||||
|
)
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (Loader.isModLoaded("techreborn") && allAvailable(BlockRubberLog, ITexturedBlock, getTextureNameFromState)) {
|
||||||
|
Client.log(Level.INFO, "TechReborn support initialized")
|
||||||
|
LogRegistry.subRegistries.add(TechRebornLogSupport)
|
||||||
|
|
||||||
|
// initialize object but don't add to registry
|
||||||
|
TechRebornLeafSupport.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
data class RubberLogModelInfo(
|
||||||
|
val axis: EnumFacing.Axis?,
|
||||||
|
val spotDir: EnumFacing?,
|
||||||
|
val textures: List<String>
|
||||||
|
)
|
||||||
|
|
||||||
|
// TODO avoid copy-paste pattern with regards to StaticColumnInfo
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
data class RubberLogColumnInfo(override val axis: EnumFacing.Axis?,
|
||||||
|
val spotDir: EnumFacing,
|
||||||
|
val topTexture: TextureAtlasSprite,
|
||||||
|
val bottomTexture: TextureAtlasSprite,
|
||||||
|
val sideTexture: TextureAtlasSprite,
|
||||||
|
val spotTexture: TextureAtlasSprite): IColumnTextureInfo {
|
||||||
|
override val top = { ctx: ShadingContext, idx: Int, quad: Quad ->
|
||||||
|
OptifineCTM.override(topTexture, blockContext, EnumFacing.UP.rotate(ctx.rotation))
|
||||||
|
}
|
||||||
|
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 texture = if (worldRelativeSide == spotDir) spotTexture else sideTexture
|
||||||
|
OptifineCTM.override(texture, blockContext, worldRelativeSide)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
abstract class RubberLogSupportBase : ModelProcessor<RubberLogModelInfo, IColumnTextureInfo>, IColumnRegistry {
|
||||||
|
|
||||||
|
override var stateToKey = mutableMapOf<IBlockState, RubberLogModelInfo>()
|
||||||
|
override var stateToValue = mapOf<IBlockState, IColumnTextureInfo>()
|
||||||
|
|
||||||
|
override val logger = BetterFoliageMod.logDetail
|
||||||
|
|
||||||
|
init { MinecraftForge.EVENT_BUS.register(this) }
|
||||||
|
|
||||||
|
override fun processStitch(state: IBlockState, key: RubberLogModelInfo, atlas: TextureMap): IColumnTextureInfo? {
|
||||||
|
val topTex = atlas[key.textures[0]] ?: return null
|
||||||
|
val bottomTex = atlas[key.textures[1]] ?: return null
|
||||||
|
val sideTex = atlas[key.textures[2]] ?: return null
|
||||||
|
if (key.spotDir == null)
|
||||||
|
return StaticColumnInfo(key.axis, topTex, bottomTex, sideTex)
|
||||||
|
else {
|
||||||
|
val spotTex = atlas[key.textures[3]] ?: return null
|
||||||
|
return RubberLogColumnInfo(key.axis, key.spotDir, topTex, bottomTex, sideTex, spotTex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun get(state: IBlockState) = stateToValue[state]
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
object IC2LogSupport : RubberLogSupportBase() {
|
||||||
|
|
||||||
|
override fun processModelLoad(state: IBlockState, modelLoc: ModelResourceLocation, model: IModel): RubberLogModelInfo? {
|
||||||
|
// check for proper block class, existence of ModelBlock, and "state" blockstate property
|
||||||
|
if (!IC2Integration.BlockRubWood.isInstance(state.block)) return null
|
||||||
|
val blockLoc = model.modelBlockAndLoc ?: return null
|
||||||
|
val type = state.properties.entries.find { it.key.getName() == "state" }?.value?.toString() ?: return null
|
||||||
|
|
||||||
|
// logs with no rubber spot
|
||||||
|
if (blockLoc.derivesFrom(ResourceLocation("block/cube_column"))) {
|
||||||
|
val axis = when(type) {
|
||||||
|
"plain_y" -> EnumFacing.Axis.Y
|
||||||
|
"plain_x" -> EnumFacing.Axis.X
|
||||||
|
"plain_z" -> EnumFacing.Axis.Z
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
val textureNames = listOf("end", "end", "side").map { blockLoc.first.resolveTextureName(it) }
|
||||||
|
logger.log(Level.DEBUG, "IC2LogSupport: block state ${state.toString()}")
|
||||||
|
logger.log(Level.DEBUG, "IC2LogSupport: axis=$axis, end=${textureNames[0]}, side=${textureNames[2]}")
|
||||||
|
return if (textureNames.all { it != "missingno" }) RubberLogModelInfo(axis, null, textureNames) else null
|
||||||
|
}
|
||||||
|
|
||||||
|
// logs with rubber spot
|
||||||
|
val spotDir = when(type) {
|
||||||
|
"dry_north", "wet_north" -> EnumFacing.NORTH
|
||||||
|
"dry_south", "wet_south" -> EnumFacing.SOUTH
|
||||||
|
"dry_west", "wet_west" -> EnumFacing.WEST
|
||||||
|
"dry_east", "wet_east" -> EnumFacing.EAST
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
val textureNames = listOf("up", "down", "south", "north").map { blockLoc.first.resolveTextureName(it) }
|
||||||
|
logger.log(Level.DEBUG, "IC2LogSupport: block state ${state.toString()}")
|
||||||
|
logger.log(Level.DEBUG, "IC2LogSupport: spotDir=$spotDir, up=${textureNames[0]}, down=${textureNames[1]}, side=${textureNames[2]}, spot=${textureNames[3]}")
|
||||||
|
return if (textureNames.all { it != "missingno" }) RubberLogModelInfo(EnumFacing.Axis.Y, spotDir, textureNames) else null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
object TechRebornLogSupport : RubberLogSupportBase() {
|
||||||
|
|
||||||
|
override fun processModelLoad(state: IBlockState, modelLoc: ModelResourceLocation, model: IModel): RubberLogModelInfo? {
|
||||||
|
// check for proper block class, existence of ModelBlock
|
||||||
|
if (!TechRebornIntegration.BlockRubberLog.isInstance(state.block)) return null
|
||||||
|
|
||||||
|
val hasSap = state.properties.entries.find { it.key.getName() == "hassap" }?.value as? Boolean ?: return null
|
||||||
|
val sapSide = state.properties.entries.find { it.key.getName() == "sapside" }?.value as? EnumFacing ?: return null
|
||||||
|
|
||||||
|
logger.log(Level.DEBUG, "TechRebornLogSupport: block state ${state.toString()}")
|
||||||
|
if (hasSap) {
|
||||||
|
val textureNames = listOf(EnumFacing.UP, EnumFacing.DOWN, sapSide.opposite, sapSide).map {
|
||||||
|
TechRebornIntegration.getTextureNameFromState.invoke(state.block, state, it) as String
|
||||||
|
}
|
||||||
|
logger.log(Level.DEBUG, "TechRebornLogSupport: spotDir=$sapSide, up=${textureNames[0]}, down=${textureNames[1]}, side=${textureNames[2]}, spot=${textureNames[3]}")
|
||||||
|
return if (textureNames.all { it != "missingno" }) RubberLogModelInfo(EnumFacing.Axis.Y, sapSide, textureNames) else null
|
||||||
|
} else {
|
||||||
|
val textureNames = listOf(EnumFacing.UP, EnumFacing.DOWN, sapSide).map {
|
||||||
|
TechRebornIntegration.getTextureNameFromState.invoke(state.block, state, it) as String
|
||||||
|
}
|
||||||
|
logger.log(Level.DEBUG, "TechRebornLogSupport: up=${textureNames[0]}, down=${textureNames[1]}, side=${textureNames[2]}")
|
||||||
|
return if (textureNames.all { it != "missingno" }) RubberLogModelInfo(EnumFacing.Axis.Y, null, textureNames) else null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
object TechRebornLeafSupport : ModelProcessor<Nothing, Nothing> {
|
||||||
|
|
||||||
|
init { MinecraftForge.EVENT_BUS.register(this) }
|
||||||
|
|
||||||
|
override var stateToKey = mutableMapOf<IBlockState, Nothing>()
|
||||||
|
override var stateToValue = mapOf<IBlockState, Nothing>()
|
||||||
|
override val logger: Logger get() = BetterFoliageMod.logDetail
|
||||||
|
|
||||||
|
override fun processModelLoad(state: IBlockState, modelLoc: ModelResourceLocation, model: IModel): Nothing? {
|
||||||
|
if (Config.blocks.leavesClasses.matchesClass(state.block) && TechRebornIntegration.ITexturedBlock.isInstance(state.block)) {
|
||||||
|
val textureName = TechRebornIntegration.getTextureNameFromState.invoke(state.block, state, EnumFacing.UP) as String
|
||||||
|
logger.log(Level.DEBUG, "TechRebornLeafSupport: block state ${state.toString()}")
|
||||||
|
logger.log(Level.DEBUG, "TechRebornLeafSupport: texture=$textureName")
|
||||||
|
// register directly into StandardLeafSupport for the sake of simplicity
|
||||||
|
StandardLeafSupport.stateToKey[state] = listOf(textureName)
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
// no-op
|
||||||
|
override fun processStitch(state: IBlockState, key: Nothing, atlas: TextureMap) = null
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package mods.betterfoliage.client.render
|
package mods.betterfoliage.client.render
|
||||||
|
|
||||||
|
import mods.betterfoliage.client.config.Config
|
||||||
import mods.betterfoliage.client.integration.OptifineCTM
|
import mods.betterfoliage.client.integration.OptifineCTM
|
||||||
import mods.betterfoliage.client.integration.ShadersModIntegration
|
import mods.betterfoliage.client.integration.ShadersModIntegration
|
||||||
import mods.betterfoliage.client.render.AbstractRenderColumn.BlockType.*
|
import mods.betterfoliage.client.render.AbstractRenderColumn.BlockType.*
|
||||||
@@ -13,20 +14,27 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite
|
|||||||
import net.minecraft.util.BlockRenderLayer
|
import net.minecraft.util.BlockRenderLayer
|
||||||
import net.minecraft.util.EnumFacing
|
import net.minecraft.util.EnumFacing
|
||||||
import net.minecraft.util.EnumFacing.*
|
import net.minecraft.util.EnumFacing.*
|
||||||
|
import net.minecraftforge.fml.relauncher.Side
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly
|
||||||
|
|
||||||
interface IColumnTextureResolver {
|
@SideOnly(Side.CLIENT)
|
||||||
|
interface IColumnTextureInfo {
|
||||||
|
val axis: Axis?
|
||||||
val top: (ShadingContext, Int, Quad)->TextureAtlasSprite?
|
val top: (ShadingContext, Int, Quad)->TextureAtlasSprite?
|
||||||
val bottom: (ShadingContext, Int, Quad)->TextureAtlasSprite?
|
val bottom: (ShadingContext, Int, Quad)->TextureAtlasSprite?
|
||||||
val side: (ShadingContext, Int, Quad)->TextureAtlasSprite?
|
val side: (ShadingContext, Int, Quad)->TextureAtlasSprite?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
interface IColumnRegistry {
|
interface IColumnRegistry {
|
||||||
operator fun get(state: IBlockState): IColumnTextureResolver?
|
operator fun get(state: IBlockState): IColumnTextureInfo?
|
||||||
}
|
}
|
||||||
|
|
||||||
data class StaticColumnInfo(val topTexture: TextureAtlasSprite,
|
@SideOnly(Side.CLIENT)
|
||||||
|
data class StaticColumnInfo(override val axis: Axis?,
|
||||||
|
val topTexture: TextureAtlasSprite,
|
||||||
val bottomTexture: TextureAtlasSprite,
|
val bottomTexture: TextureAtlasSprite,
|
||||||
val sideTexture: TextureAtlasSprite) : IColumnTextureResolver {
|
val sideTexture: TextureAtlasSprite) : IColumnTextureInfo {
|
||||||
override val top = { ctx: ShadingContext, idx: Int, quad: Quad ->
|
override val top = { ctx: ShadingContext, idx: Int, quad: Quad ->
|
||||||
OptifineCTM.override(topTexture, blockContext, UP.rotate(ctx.rotation))
|
OptifineCTM.override(topTexture, blockContext, UP.rotate(ctx.rotation))
|
||||||
}
|
}
|
||||||
@@ -47,6 +55,7 @@ const val NW = 2
|
|||||||
/** Index of SOUTH-WEST quadrant. */
|
/** Index of SOUTH-WEST quadrant. */
|
||||||
const val SW = 3
|
const val SW = 3
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandler(modId) {
|
abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandler(modId) {
|
||||||
|
|
||||||
@@ -123,7 +132,6 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
|||||||
inline fun continous(q1: QuadrantType, q2: QuadrantType) =
|
inline fun continous(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 axisFunc: (IBlockState)->EnumFacing.Axis?
|
|
||||||
abstract val blockPredicate: (IBlockState)->Boolean
|
abstract val blockPredicate: (IBlockState)->Boolean
|
||||||
|
|
||||||
abstract val registry: IColumnRegistry
|
abstract val registry: IColumnRegistry
|
||||||
@@ -138,7 +146,8 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
|||||||
modelRenderer.updateShading(Int3.zero, allFaces)
|
modelRenderer.updateShading(Int3.zero, allFaces)
|
||||||
|
|
||||||
// check log neighborhood
|
// check log neighborhood
|
||||||
val logAxis = ctx.blockAxis ?: return renderWorldBlockBase(ctx, dispatcher, renderer, null)
|
// if log axis is not defined and "Default to vertical" config option is not set, render normally
|
||||||
|
val logAxis = columnTextures.axis ?: if (Config.roundLogs.defaultY) Axis.Y else return renderWorldBlockBase(ctx, dispatcher, renderer, null)
|
||||||
val baseRotation = rotationFromUp[(logAxis to AxisDirection.POSITIVE).face.ordinal]
|
val baseRotation = rotationFromUp[(logAxis to AxisDirection.POSITIVE).face.ordinal]
|
||||||
|
|
||||||
val upType = ctx.blockType(baseRotation, logAxis, Int3(0, 1, 0))
|
val upType = ctx.blockType(baseRotation, logAxis, Int3(0, 1, 0))
|
||||||
@@ -328,9 +337,6 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the axis of the block */
|
|
||||||
val BlockContext.blockAxis: Axis? get() = axisFunc(blockState(Int3.zero))
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the type of the block at the given offset in a rotated reference frame.
|
* Get the type of the block at the given offset in a rotated reference frame.
|
||||||
*/
|
*/
|
||||||
@@ -340,7 +346,9 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
|||||||
return if (!blockPredicate(state)) {
|
return if (!blockPredicate(state)) {
|
||||||
if (state.isOpaqueCube) SOLID else NONSOLID
|
if (state.isOpaqueCube) SOLID else NONSOLID
|
||||||
} else {
|
} else {
|
||||||
axisFunc(state)?.let { if (it == axis) PARALLEL else PERPENDICULAR } ?: SOLID
|
(registry[state]?.axis ?: if (Config.roundLogs.defaultY) Axis.Y else null)?.let {
|
||||||
|
if (it == axis) PARALLEL else PERPENDICULAR
|
||||||
|
} ?: SOLID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,6 +25,7 @@ import org.lwjgl.opengl.GL11
|
|||||||
import java.lang.Math.*
|
import java.lang.Math.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
class EntityFallingLeavesFX(world: World, pos: BlockPos) :
|
class EntityFallingLeavesFX(world: World, pos: BlockPos) :
|
||||||
AbstractEntityFX(world, pos.x.toDouble() + 0.5, pos.y.toDouble(), pos.z.toDouble() + 0.5) {
|
AbstractEntityFX(world, pos.x.toDouble() + 0.5, pos.y.toDouble(), pos.z.toDouble() + 0.5) {
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import net.minecraftforge.fml.relauncher.SideOnly
|
|||||||
import org.apache.logging.log4j.Level.INFO
|
import org.apache.logging.log4j.Level.INFO
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
class EntityRisingSoulFX(world: World, pos: BlockPos) :
|
class EntityRisingSoulFX(world: World, pos: BlockPos) :
|
||||||
AbstractEntityFX(world, pos.x.toDouble() + 0.5, pos.y.toDouble() + 1.0, pos.z.toDouble() + 0.5) {
|
AbstractEntityFX(world, pos.x.toDouble() + 0.5, pos.y.toDouble() + 1.0, pos.z.toDouble() + 0.5) {
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,11 @@ import net.minecraft.block.material.Material
|
|||||||
import net.minecraft.client.renderer.BlockRendererDispatcher
|
import net.minecraft.client.renderer.BlockRendererDispatcher
|
||||||
import net.minecraft.client.renderer.VertexBuffer
|
import net.minecraft.client.renderer.VertexBuffer
|
||||||
import net.minecraft.util.BlockRenderLayer
|
import net.minecraft.util.BlockRenderLayer
|
||||||
|
import net.minecraftforge.fml.relauncher.Side
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly
|
||||||
import org.apache.logging.log4j.Level.INFO
|
import org.apache.logging.log4j.Level.INFO
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
class RenderAlgae : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
class RenderAlgae : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||||
|
|
||||||
val noise = simplexNoise()
|
val noise = simplexNoise()
|
||||||
|
|||||||
@@ -5,12 +5,9 @@ import mods.betterfoliage.client.Client
|
|||||||
import mods.betterfoliage.client.config.Config
|
import mods.betterfoliage.client.config.Config
|
||||||
import mods.octarinecore.client.render.*
|
import mods.octarinecore.client.render.*
|
||||||
import mods.octarinecore.client.resource.TextureListModelProcessor
|
import mods.octarinecore.client.resource.TextureListModelProcessor
|
||||||
import mods.octarinecore.client.resource.get
|
|
||||||
import mods.octarinecore.client.resource.registerSprite
|
import mods.octarinecore.client.resource.registerSprite
|
||||||
import mods.octarinecore.common.Int3
|
import mods.octarinecore.common.Int3
|
||||||
import mods.octarinecore.common.Rotation
|
import mods.octarinecore.common.Rotation
|
||||||
import mods.octarinecore.common.config.ConfigurableBlockMatcher
|
|
||||||
import mods.octarinecore.common.config.ModelTextureList
|
|
||||||
import mods.octarinecore.common.config.SimpleBlockMatcher
|
import mods.octarinecore.common.config.SimpleBlockMatcher
|
||||||
import mods.octarinecore.common.config.modelTextures
|
import mods.octarinecore.common.config.modelTextures
|
||||||
import net.minecraft.block.BlockCactus
|
import net.minecraft.block.BlockCactus
|
||||||
@@ -21,8 +18,11 @@ import net.minecraft.client.renderer.texture.TextureMap
|
|||||||
import net.minecraft.util.BlockRenderLayer
|
import net.minecraft.util.BlockRenderLayer
|
||||||
import net.minecraft.util.EnumFacing.*
|
import net.minecraft.util.EnumFacing.*
|
||||||
import net.minecraftforge.common.MinecraftForge
|
import net.minecraftforge.common.MinecraftForge
|
||||||
|
import net.minecraftforge.fml.relauncher.Side
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly
|
||||||
import org.apache.logging.log4j.Level
|
import org.apache.logging.log4j.Level
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
class RenderCactus : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
class RenderCactus : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||||
|
|
||||||
val cactusStemRadius = 0.4375
|
val cactusStemRadius = 0.4375
|
||||||
@@ -31,12 +31,12 @@ class RenderCactus : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
|||||||
val iconCross = iconStatic(BetterFoliageMod.LEGACY_DOMAIN, "blocks/better_cactus")
|
val iconCross = iconStatic(BetterFoliageMod.LEGACY_DOMAIN, "blocks/better_cactus")
|
||||||
val iconArm = iconSet(BetterFoliageMod.LEGACY_DOMAIN, "blocks/better_cactus_arm_%d")
|
val iconArm = iconSet(BetterFoliageMod.LEGACY_DOMAIN, "blocks/better_cactus_arm_%d")
|
||||||
|
|
||||||
val cactusTextures: IColumnRegistry = object : TextureListModelProcessor<IColumnTextureResolver>, IColumnRegistry {
|
val cactusTextures: IColumnRegistry = object : TextureListModelProcessor<IColumnTextureInfo>, IColumnRegistry {
|
||||||
|
|
||||||
init { MinecraftForge.EVENT_BUS.register(this) }
|
init { MinecraftForge.EVENT_BUS.register(this) }
|
||||||
|
|
||||||
override var stateToKey = mutableMapOf<IBlockState, List<String>>()
|
override var stateToKey = mutableMapOf<IBlockState, List<String>>()
|
||||||
override var stateToValue = mapOf<IBlockState, IColumnTextureResolver>()
|
override var stateToValue = mapOf<IBlockState, IColumnTextureInfo>()
|
||||||
|
|
||||||
override val logger = BetterFoliageMod.logDetail
|
override val logger = BetterFoliageMod.logDetail
|
||||||
override val logName = "CactusTextures"
|
override val logName = "CactusTextures"
|
||||||
@@ -45,11 +45,11 @@ class RenderCactus : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
|||||||
modelTextures("block/cactus", "top", "bottom", "side")
|
modelTextures("block/cactus", "top", "bottom", "side")
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun processStitch(state: IBlockState, key: List<String>, atlas: TextureMap): IColumnTextureResolver? {
|
override fun processStitch(state: IBlockState, key: List<String>, atlas: TextureMap): IColumnTextureInfo? {
|
||||||
val topTex = atlas.registerSprite(key[0])
|
val topTex = atlas.registerSprite(key[0])
|
||||||
val bottomTex = atlas.registerSprite(key[1])
|
val bottomTex = atlas.registerSprite(key[1])
|
||||||
val sideTex = atlas.registerSprite(key[2])
|
val sideTex = atlas.registerSprite(key[2])
|
||||||
return StaticColumnInfo(topTex, bottomTex, sideTex)
|
return StaticColumnInfo(Axis.Y, topTex, bottomTex, sideTex)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun get(state: IBlockState) = stateToValue[state]
|
override fun get(state: IBlockState) = stateToValue[state]
|
||||||
|
|||||||
@@ -9,7 +9,10 @@ import mods.octarinecore.common.Int3
|
|||||||
import net.minecraft.client.renderer.BlockRendererDispatcher
|
import net.minecraft.client.renderer.BlockRendererDispatcher
|
||||||
import net.minecraft.client.renderer.VertexBuffer
|
import net.minecraft.client.renderer.VertexBuffer
|
||||||
import net.minecraft.util.BlockRenderLayer
|
import net.minecraft.util.BlockRenderLayer
|
||||||
|
import net.minecraftforge.fml.relauncher.Side
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
class RenderConnectedGrass : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
class RenderConnectedGrass : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||||
override fun isEligible(ctx: BlockContext) =
|
override fun isEligible(ctx: BlockContext) =
|
||||||
Config.enabled && Config.connectedGrass.enabled &&
|
Config.enabled && Config.connectedGrass.enabled &&
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ import net.minecraft.client.renderer.BlockRendererDispatcher
|
|||||||
import net.minecraft.client.renderer.VertexBuffer
|
import net.minecraft.client.renderer.VertexBuffer
|
||||||
import net.minecraft.util.BlockRenderLayer
|
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
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
class RenderConnectedGrassLog : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
class RenderConnectedGrassLog : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||||
|
|
||||||
val grassCheckDirs = listOf(EAST, WEST, NORTH, SOUTH)
|
val grassCheckDirs = listOf(EAST, WEST, NORTH, SOUTH)
|
||||||
|
|||||||
@@ -14,8 +14,11 @@ import net.minecraft.client.renderer.VertexBuffer
|
|||||||
import net.minecraft.util.BlockRenderLayer
|
import net.minecraft.util.BlockRenderLayer
|
||||||
import net.minecraft.util.EnumFacing.Axis
|
import net.minecraft.util.EnumFacing.Axis
|
||||||
import net.minecraft.util.EnumFacing.UP
|
import net.minecraft.util.EnumFacing.UP
|
||||||
|
import net.minecraftforge.fml.relauncher.Side
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly
|
||||||
import org.apache.logging.log4j.Level.INFO
|
import org.apache.logging.log4j.Level.INFO
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
class RenderCoral : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
class RenderCoral : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||||
|
|
||||||
val noise = simplexNoise()
|
val noise = simplexNoise()
|
||||||
|
|||||||
@@ -15,8 +15,11 @@ import net.minecraft.client.renderer.VertexBuffer
|
|||||||
import net.minecraft.util.BlockRenderLayer
|
import net.minecraft.util.BlockRenderLayer
|
||||||
import net.minecraft.util.EnumFacing.Axis
|
import net.minecraft.util.EnumFacing.Axis
|
||||||
import net.minecraft.util.EnumFacing.UP
|
import net.minecraft.util.EnumFacing.UP
|
||||||
|
import net.minecraftforge.fml.relauncher.Side
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly
|
||||||
import org.apache.logging.log4j.Level.INFO
|
import org.apache.logging.log4j.Level.INFO
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
class RenderGrass : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
class RenderGrass : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
@@ -17,9 +17,12 @@ import net.minecraft.client.renderer.VertexBuffer
|
|||||||
import net.minecraft.util.BlockRenderLayer
|
import net.minecraft.util.BlockRenderLayer
|
||||||
import net.minecraft.util.EnumFacing.DOWN
|
import net.minecraft.util.EnumFacing.DOWN
|
||||||
import net.minecraft.util.EnumFacing.UP
|
import net.minecraft.util.EnumFacing.UP
|
||||||
|
import net.minecraftforge.fml.relauncher.Side
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly
|
||||||
import java.lang.Math.cos
|
import java.lang.Math.cos
|
||||||
import java.lang.Math.sin
|
import java.lang.Math.sin
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
class RenderLeaves : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
class RenderLeaves : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||||
|
|
||||||
val leavesModel = model {
|
val leavesModel = model {
|
||||||
|
|||||||
@@ -12,8 +12,11 @@ import net.minecraft.client.renderer.VertexBuffer
|
|||||||
import net.minecraft.util.BlockRenderLayer
|
import net.minecraft.util.BlockRenderLayer
|
||||||
import net.minecraft.util.EnumFacing.DOWN
|
import net.minecraft.util.EnumFacing.DOWN
|
||||||
import net.minecraft.util.EnumFacing.UP
|
import net.minecraft.util.EnumFacing.UP
|
||||||
|
import net.minecraftforge.fml.relauncher.Side
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly
|
||||||
import org.apache.logging.log4j.Level
|
import org.apache.logging.log4j.Level
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
class RenderLilypad : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
class RenderLilypad : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||||
|
|
||||||
val rootModel = model {
|
val rootModel = model {
|
||||||
|
|||||||
@@ -2,25 +2,21 @@ package mods.betterfoliage.client.render
|
|||||||
|
|
||||||
import mods.betterfoliage.BetterFoliageMod
|
import mods.betterfoliage.BetterFoliageMod
|
||||||
import mods.betterfoliage.client.config.Config
|
import mods.betterfoliage.client.config.Config
|
||||||
import mods.betterfoliage.client.texture.GrassRegistry
|
|
||||||
import mods.betterfoliage.client.texture.IGrassRegistry
|
|
||||||
import mods.betterfoliage.client.texture.StandardGrassSupport
|
|
||||||
import mods.octarinecore.client.render.BlockContext
|
import mods.octarinecore.client.render.BlockContext
|
||||||
import mods.octarinecore.client.resource.TextureListModelProcessor
|
import mods.octarinecore.client.resource.TextureListModelProcessor
|
||||||
import mods.octarinecore.client.resource.get
|
|
||||||
import mods.octarinecore.client.resource.registerSprite
|
import mods.octarinecore.client.resource.registerSprite
|
||||||
import mods.octarinecore.common.Int3
|
|
||||||
import mods.octarinecore.common.config.ConfigurableBlockMatcher
|
import mods.octarinecore.common.config.ConfigurableBlockMatcher
|
||||||
import mods.octarinecore.common.config.ModelTextureList
|
import mods.octarinecore.common.config.ModelTextureList
|
||||||
import mods.octarinecore.findFirst
|
import mods.octarinecore.findFirst
|
||||||
import mods.octarinecore.tryDefault
|
import mods.octarinecore.tryDefault
|
||||||
import net.minecraft.block.BlockLog
|
import net.minecraft.block.BlockLog
|
||||||
import net.minecraft.block.state.IBlockState
|
import net.minecraft.block.state.IBlockState
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite
|
|
||||||
import net.minecraft.client.renderer.texture.TextureMap
|
import net.minecraft.client.renderer.texture.TextureMap
|
||||||
import net.minecraft.util.EnumFacing.Axis
|
import net.minecraft.util.EnumFacing.Axis
|
||||||
import net.minecraftforge.common.MinecraftForge
|
import net.minecraftforge.common.MinecraftForge
|
||||||
import org.apache.logging.log4j.Logger
|
import net.minecraftforge.fml.relauncher.Side
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly
|
||||||
|
|
||||||
|
|
||||||
class RenderLog : AbstractRenderColumn(BetterFoliageMod.MOD_ID) {
|
class RenderLog : AbstractRenderColumn(BetterFoliageMod.MOD_ID) {
|
||||||
|
|
||||||
@@ -31,17 +27,6 @@ class RenderLog : AbstractRenderColumn(BetterFoliageMod.MOD_ID) {
|
|||||||
ctx.cameraDistance < Config.roundLogs.distance &&
|
ctx.cameraDistance < Config.roundLogs.distance &&
|
||||||
Config.blocks.logClasses.matchesClass(ctx.block)
|
Config.blocks.logClasses.matchesClass(ctx.block)
|
||||||
|
|
||||||
override var axisFunc = { state: IBlockState ->
|
|
||||||
val axis = tryDefault(null) { state.getValue(BlockLog.LOG_AXIS).toString() } ?:
|
|
||||||
state.properties.entries.find { it.key.getName().toLowerCase() == "axis" }?.let { it.value.toString() }
|
|
||||||
when (axis) {
|
|
||||||
"x" -> Axis.X
|
|
||||||
"y" -> Axis.Y
|
|
||||||
"z" -> Axis.Z
|
|
||||||
else -> if (Config.roundLogs.defaultY) Axis.Y else null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override val registry: IColumnRegistry get() = LogRegistry
|
override val registry: IColumnRegistry get() = LogRegistry
|
||||||
|
|
||||||
override val blockPredicate = { state: IBlockState -> Config.blocks.logClasses.matchesClass(state.block) }
|
override val blockPredicate = { state: IBlockState -> Config.blocks.logClasses.matchesClass(state.block) }
|
||||||
@@ -55,29 +40,45 @@ class RenderLog : AbstractRenderColumn(BetterFoliageMod.MOD_ID) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
object LogRegistry : IColumnRegistry {
|
object LogRegistry : IColumnRegistry {
|
||||||
val subRegistries: MutableList<IColumnRegistry> = mutableListOf(StandardLogSupport)
|
val subRegistries: MutableList<IColumnRegistry> = mutableListOf()
|
||||||
override fun get(state: IBlockState) = subRegistries.findFirst { it[state] }
|
override fun get(state: IBlockState) = subRegistries.findFirst { it[state] }
|
||||||
}
|
}
|
||||||
|
|
||||||
object StandardLogSupport : TextureListModelProcessor<IColumnTextureResolver>, IColumnRegistry {
|
@SideOnly(Side.CLIENT)
|
||||||
|
object StandardLogSupport : TextureListModelProcessor<IColumnTextureInfo>, IColumnRegistry {
|
||||||
|
|
||||||
init { MinecraftForge.EVENT_BUS.register(this) }
|
init {
|
||||||
|
LogRegistry.subRegistries.add(this)
|
||||||
|
MinecraftForge.EVENT_BUS.register(this)
|
||||||
|
}
|
||||||
|
|
||||||
override var stateToKey = mutableMapOf<IBlockState, List<String>>()
|
override var stateToKey = mutableMapOf<IBlockState, List<String>>()
|
||||||
override var stateToValue = mapOf<IBlockState, IColumnTextureResolver>()
|
override var stateToValue = mapOf<IBlockState, IColumnTextureInfo>()
|
||||||
|
|
||||||
override val logger = BetterFoliageMod.logDetail
|
override val logger = BetterFoliageMod.logDetail
|
||||||
override val logName = "StandardLogSupport"
|
override val logName = "StandardLogSupport"
|
||||||
override val matchClasses: ConfigurableBlockMatcher get() = Config.blocks.logClasses
|
override val matchClasses: ConfigurableBlockMatcher get() = Config.blocks.logClasses
|
||||||
override val modelTextures: List<ModelTextureList> get() = Config.blocks.logModels.list
|
override val modelTextures: List<ModelTextureList> get() = Config.blocks.logModels.list
|
||||||
|
|
||||||
override fun processStitch(state: IBlockState, key: List<String>, atlas: TextureMap): IColumnTextureResolver? {
|
override fun processStitch(state: IBlockState, key: List<String>, atlas: TextureMap): IColumnTextureInfo? {
|
||||||
val topTex = atlas.registerSprite(key[0])
|
val topTex = atlas.registerSprite(key[0])
|
||||||
val bottomTex = atlas.registerSprite(key[1])
|
val bottomTex = atlas.registerSprite(key[1])
|
||||||
val sideTex = atlas.registerSprite(key[2])
|
val sideTex = atlas.registerSprite(key[2])
|
||||||
return StaticColumnInfo(topTex, bottomTex, sideTex)
|
return StaticColumnInfo(getAxis(state), topTex, bottomTex, sideTex)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun get(state: IBlockState) = stateToValue[state]
|
override fun get(state: IBlockState) = stateToValue[state]
|
||||||
|
|
||||||
|
fun getAxis(state: IBlockState): Axis? {
|
||||||
|
val axis = tryDefault(null) { state.getValue(BlockLog.LOG_AXIS).toString() } ?:
|
||||||
|
state.properties.entries.find { it.key.getName().toLowerCase() == "axis" }?.let { it.value.toString() }
|
||||||
|
return when (axis) {
|
||||||
|
"x" -> Axis.X
|
||||||
|
"y" -> Axis.Y
|
||||||
|
"z" -> Axis.Z
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -13,8 +13,11 @@ import net.minecraft.client.renderer.BlockRendererDispatcher
|
|||||||
import net.minecraft.client.renderer.VertexBuffer
|
import net.minecraft.client.renderer.VertexBuffer
|
||||||
import net.minecraft.init.Blocks
|
import net.minecraft.init.Blocks
|
||||||
import net.minecraft.util.BlockRenderLayer
|
import net.minecraft.util.BlockRenderLayer
|
||||||
|
import net.minecraftforge.fml.relauncher.Side
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly
|
||||||
import org.apache.logging.log4j.Level.INFO
|
import org.apache.logging.log4j.Level.INFO
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
class RenderMycelium : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
class RenderMycelium : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||||
|
|
||||||
val myceliumIcon = iconSet(BetterFoliageMod.LEGACY_DOMAIN, "blocks/better_mycel_%d")
|
val myceliumIcon = iconSet(BetterFoliageMod.LEGACY_DOMAIN, "blocks/better_mycel_%d")
|
||||||
|
|||||||
@@ -12,8 +12,11 @@ import net.minecraft.client.renderer.VertexBuffer
|
|||||||
import net.minecraft.init.Blocks
|
import net.minecraft.init.Blocks
|
||||||
import net.minecraft.util.BlockRenderLayer
|
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
|
||||||
import org.apache.logging.log4j.Level.INFO
|
import org.apache.logging.log4j.Level.INFO
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
class RenderNetherrack : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
class RenderNetherrack : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||||
|
|
||||||
val netherrackIcon = iconSet(BetterFoliageMod.LEGACY_DOMAIN, "blocks/better_netherrack_%d")
|
val netherrackIcon = iconSet(BetterFoliageMod.LEGACY_DOMAIN, "blocks/better_netherrack_%d")
|
||||||
|
|||||||
@@ -13,8 +13,11 @@ import net.minecraft.client.renderer.BlockRendererDispatcher
|
|||||||
import net.minecraft.client.renderer.VertexBuffer
|
import net.minecraft.client.renderer.VertexBuffer
|
||||||
import net.minecraft.util.BlockRenderLayer
|
import net.minecraft.util.BlockRenderLayer
|
||||||
import net.minecraft.util.EnumFacing.UP
|
import net.minecraft.util.EnumFacing.UP
|
||||||
|
import net.minecraftforge.fml.relauncher.Side
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly
|
||||||
import org.apache.logging.log4j.Level
|
import org.apache.logging.log4j.Level
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
class RenderReeds : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
class RenderReeds : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||||
|
|
||||||
val noise = simplexNoise()
|
val noise = simplexNoise()
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class AoData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val black = AoData();
|
val black = AoData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,13 @@ interface ModelProcessor<T1, T2> {
|
|||||||
fun processModelLoad(state: IBlockState, modelLoc: ModelResourceLocation, model: IModel): T1?
|
fun processModelLoad(state: IBlockState, modelLoc: ModelResourceLocation, model: IModel): T1?
|
||||||
fun processStitch(state: IBlockState, key: T1, atlas: TextureMap): T2?
|
fun processStitch(state: IBlockState, key: T1, atlas: TextureMap): T2?
|
||||||
|
|
||||||
|
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||||
|
fun clearBeforeLoadModelData(event: LoadModelDataEvent) {
|
||||||
|
stateToKey.clear()
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
fun handleLoadModelData(event: LoadModelDataEvent) {
|
fun handleLoadModelData(event: LoadModelDataEvent) {
|
||||||
stateToKey.clear()
|
|
||||||
onPostLoad()
|
onPostLoad()
|
||||||
|
|
||||||
val stateMappings = Block.REGISTRY.flatMap { block ->
|
val stateMappings = Block.REGISTRY.flatMap { block ->
|
||||||
@@ -96,7 +100,6 @@ interface TextureMediatedRegistry<T1, T3> : ModelProcessor<T1, TextureAtlasSprit
|
|||||||
var textureToValue: MutableMap<TextureAtlasSprite, T3>
|
var textureToValue: MutableMap<TextureAtlasSprite, T3>
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
// @SubscribeEvent(priority = EventPriority.LOW)
|
|
||||||
override fun handlePreStitch(event: TextureStitchEvent.Pre) {
|
override fun handlePreStitch(event: TextureStitchEvent.Pre) {
|
||||||
textureToValue.clear()
|
textureToValue.clear()
|
||||||
super.handlePreStitch(event)
|
super.handlePreStitch(event)
|
||||||
|
|||||||
@@ -24,3 +24,9 @@ com.bioxx.tfc.Blocks.Flora.BlockLogNatural
|
|||||||
CookingPlus.blocks.CookingPlusPalmLog
|
CookingPlus.blocks.CookingPlusPalmLog
|
||||||
CookingPlus.blocks.CookingPlusTangleLog
|
CookingPlus.blocks.CookingPlusTangleLog
|
||||||
CookingPlus.blocks.CookingPlusTangleHeart
|
CookingPlus.blocks.CookingPlusTangleHeart
|
||||||
|
|
||||||
|
// IC2
|
||||||
|
ic2.core.block.BlockRubWood
|
||||||
|
|
||||||
|
// TechReborn
|
||||||
|
techreborn.blocks.BlockRubberLog
|
||||||
|
|||||||
Reference in New Issue
Block a user