minor code cleanup
This commit is contained in:
@@ -134,7 +134,7 @@ object ForestryLogSupport : ModelProcessor<List<String>, IColumnTextureInfo>, IC
|
||||
|
||||
init { MinecraftForge.EVENT_BUS.register(this) }
|
||||
|
||||
override fun processModelLoad1(state: IBlockState, modelLoc: ModelResourceLocation, model: IModel) {
|
||||
override fun processModelLoad(state: IBlockState, modelLoc: ModelResourceLocation, model: IModel) {
|
||||
// respect class list to avoid triggering on fences, stairs, etc.
|
||||
if (!Config.blocks.logClasses.matchesClass(state.block)) return
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ abstract class RubberLogSupportBase : ModelProcessor<RubberLogModelInfo, IColumn
|
||||
@SideOnly(Side.CLIENT)
|
||||
object IC2LogSupport : RubberLogSupportBase() {
|
||||
|
||||
override fun processModelLoad1(state: IBlockState, modelLoc: ModelResourceLocation, model: IModel) {
|
||||
override fun processModelLoad(state: IBlockState, modelLoc: ModelResourceLocation, model: IModel) {
|
||||
// check for proper block class, existence of ModelBlock, and "state" blockstate property
|
||||
if (!IC2Integration.BlockRubWood.isInstance(state.block)) return
|
||||
val blockLoc = model.modelBlockAndLoc.firstOrNull() ?: return
|
||||
@@ -172,7 +172,7 @@ object IC2LogSupport : RubberLogSupportBase() {
|
||||
@SideOnly(Side.CLIENT)
|
||||
object TechRebornLogSupport : RubberLogSupportBase() {
|
||||
|
||||
override fun processModelLoad1(state: IBlockState, modelLoc: ModelResourceLocation, model: IModel) {
|
||||
override fun processModelLoad(state: IBlockState, modelLoc: ModelResourceLocation, model: IModel) {
|
||||
// check for proper block class, existence of ModelBlock
|
||||
if (!TechRebornIntegration.BlockRubberLog.isInstance(state.block)) return
|
||||
|
||||
@@ -210,7 +210,7 @@ object TechRebornLeafSupport : ModelProcessor<Nothing, Nothing> {
|
||||
override var variantToValue = mapOf<ModelVariant, Nothing>()
|
||||
override val logger: Logger get() = BetterFoliageMod.logDetail
|
||||
|
||||
override fun processModelLoad1(state: IBlockState, modelLoc: ModelResourceLocation, model: IModel) {
|
||||
override fun processModelLoad(state: IBlockState, modelLoc: ModelResourceLocation, model: IModel) {
|
||||
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()}")
|
||||
|
||||
@@ -7,7 +7,6 @@ import mods.octarinecore.common.config.ModelTextureList
|
||||
import mods.octarinecore.filterValuesNotNull
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.state.IBlockState
|
||||
import net.minecraft.client.renderer.block.model.ModelBlock
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation
|
||||
import net.minecraft.client.renderer.block.statemap.DefaultStateMapper
|
||||
import net.minecraft.client.renderer.block.statemap.IStateMapper
|
||||
@@ -27,7 +26,6 @@ class LoadModelDataEvent(val loader: ModelLoader) : Event()
|
||||
|
||||
data class ModelVariant(
|
||||
val state: IBlockState,
|
||||
var modelBlock: ModelBlock?,
|
||||
val modelLocation: ResourceLocation?,
|
||||
val weight: Int
|
||||
)
|
||||
@@ -41,7 +39,7 @@ interface ModelProcessor<T1, T2> {
|
||||
fun addVariant(state: IBlockState, variant: ModelVariant) { variants.getOrPut(state) { mutableListOf() }.add(variant) }
|
||||
fun getVariant(state: IBlockState, rand: Int) = variants[state]?.let { it[rand % it.size] }
|
||||
fun putKeySingle(state: IBlockState, key: T1) {
|
||||
val variant = ModelVariant(state, null, null, 1)
|
||||
val variant = ModelVariant(state, null, 1)
|
||||
variants[state] = mutableListOf(variant)
|
||||
variantToKey[variant] = key
|
||||
}
|
||||
@@ -49,8 +47,7 @@ interface ModelProcessor<T1, T2> {
|
||||
fun onPostLoad() { }
|
||||
fun onPreStitch() { }
|
||||
|
||||
fun processModelLoad1(state: IBlockState, modelLoc: ModelResourceLocation, model: IModel)
|
||||
|
||||
fun processModelLoad(state: IBlockState, modelLoc: ModelResourceLocation, model: IModel)
|
||||
fun processStitch(variant: ModelVariant, key: T1, atlas: TextureMap): T2?
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||
@@ -71,7 +68,7 @@ interface ModelProcessor<T1, T2> {
|
||||
|
||||
stateMappings.forEach { mapping ->
|
||||
if (mapping.key.block != null) stateModels[mapping.value]?.let { model ->
|
||||
processModelLoad1(mapping.key, mapping.value, model)
|
||||
processModelLoad(mapping.key, mapping.value, model)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,7 +86,7 @@ interface TextureListModelProcessor<T2> : ModelProcessor<List<String>, T2> {
|
||||
val matchClasses: IBlockMatcher
|
||||
val modelTextures: List<ModelTextureList>
|
||||
|
||||
override fun processModelLoad1(state: IBlockState, modelLoc: ModelResourceLocation, model: IModel) {
|
||||
override fun processModelLoad(state: IBlockState, modelLoc: ModelResourceLocation, model: IModel) {
|
||||
val matchClass = matchClasses.matchingClass(state.block) ?: return
|
||||
logger?.log(Level.DEBUG, "$logName: block state ${state.toString()}")
|
||||
logger?.log(Level.DEBUG, "$logName: class ${state.block.javaClass.name} matches ${matchClass.name}")
|
||||
@@ -111,7 +108,7 @@ interface TextureListModelProcessor<T2> : ModelProcessor<List<String>, T2> {
|
||||
|
||||
if (textures.all { it.second != "missingno" }) {
|
||||
// found a valid variant (all required textures exist)
|
||||
val variant = ModelVariant(state, blockLoc.first, blockLoc.second, 1)
|
||||
val variant = ModelVariant(state, blockLoc.second, 1)
|
||||
addVariant(state, variant)
|
||||
variantToKey[variant] = textures.map { it.second }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user