Merge branch 'kotlin-1.10' into kotlin-1.11.2
This commit is contained in:
@@ -6,9 +6,16 @@ import mods.betterfoliage.client.integration.*
|
||||
import mods.betterfoliage.client.render.*
|
||||
import mods.betterfoliage.client.texture.*
|
||||
import mods.octarinecore.client.KeyHandler
|
||||
import mods.octarinecore.client.gui.textComponent
|
||||
import mods.octarinecore.client.resource.CenteringTextureGenerator
|
||||
import mods.octarinecore.client.resource.GeneratorPack
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.state.IBlockState
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.util.text.TextComponentString
|
||||
import net.minecraft.util.text.TextComponentTranslation
|
||||
import net.minecraft.util.text.TextFormatting
|
||||
import net.minecraftforge.fml.client.FMLClientHandler
|
||||
import net.minecraftforge.fml.relauncher.Side
|
||||
import net.minecraftforge.fml.relauncher.SideOnly
|
||||
@@ -71,6 +78,8 @@ object Client {
|
||||
StandardLogSupport // add _after_ all other log registries
|
||||
)
|
||||
|
||||
val suppressRenderErrors = mutableSetOf<IBlockState>()
|
||||
|
||||
fun log(level: Level, msg: String) {
|
||||
BetterFoliageMod.log.log(level, "[BetterFoliage] $msg")
|
||||
BetterFoliageMod.logDetail.log(level, msg)
|
||||
@@ -79,5 +88,19 @@ object Client {
|
||||
fun logDetail(msg: String) {
|
||||
BetterFoliageMod.logDetail.log(Level.DEBUG, msg)
|
||||
}
|
||||
|
||||
fun logRenderError(state: IBlockState, location: BlockPos) {
|
||||
if (state in suppressRenderErrors) return
|
||||
suppressRenderErrors.add(state)
|
||||
|
||||
val blockName = Block.REGISTRY.getNameForObject(state.block).toString()
|
||||
val blockLoc = "${location.x},${location.y},${location.z}"
|
||||
Minecraft.getMinecraft().thePlayer.addChatMessage(TextComponentTranslation(
|
||||
"betterfoliage.rendererror",
|
||||
textComponent(blockName, TextFormatting.GOLD),
|
||||
textComponent(blockLoc, TextFormatting.GOLD)
|
||||
))
|
||||
logDetail("Error rendering block $state at $blockLoc")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ object Config : DelegatingConfig(BetterFoliageMod.MOD_ID, BetterFoliageMod.DOMAI
|
||||
val heightMin by double(min=0.1, max=2.5, default=0.6).lang("heightMin")
|
||||
val heightMax by double(min=0.1, max=2.5, default=0.8).lang("heightMax")
|
||||
val size by double(min=0.5, max=1.5, default=1.0).lang("size")
|
||||
val population by int(max=64, default=64).lang("population")
|
||||
val useGenerated by boolean(false)
|
||||
val shaderWind by boolean(true).lang("shaderWind")
|
||||
val saturationThreshold by double(default=0.1)
|
||||
|
||||
@@ -21,6 +21,7 @@ import mods.octarinecore.common.rotate
|
||||
import mods.octarinecore.metaprog.ClassRef
|
||||
import mods.octarinecore.metaprog.MethodRef
|
||||
import mods.octarinecore.metaprog.allAvailable
|
||||
import mods.octarinecore.tryDefault
|
||||
import net.minecraft.block.properties.PropertyDirection
|
||||
import net.minecraft.block.state.IBlockState
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation
|
||||
@@ -133,7 +134,7 @@ 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 blockLoc = model.modelBlockAndLoc.firstOrNull() ?: return null
|
||||
val type = state.properties.entries.find { it.key.getName() == "state" }?.value?.toString() ?: return null
|
||||
|
||||
// logs with no rubber spot
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mods.betterfoliage.client.render
|
||||
|
||||
import mods.betterfoliage.client.Client
|
||||
import mods.betterfoliage.client.config.Config
|
||||
import mods.betterfoliage.client.integration.OptifineCTM
|
||||
import mods.betterfoliage.client.integration.ShadersModIntegration
|
||||
@@ -140,7 +141,11 @@ 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)] ?: return false
|
||||
val columnTextures = registry[ctx.blockState(Int3.zero)]
|
||||
if (columnTextures == null) {
|
||||
Client.logRenderError(ctx.blockState(Int3.zero), ctx.pos)
|
||||
return renderWorldBlockBase(ctx, dispatcher, renderer, null)
|
||||
}
|
||||
|
||||
// get AO data
|
||||
modelRenderer.updateShading(Int3.zero, allFaces)
|
||||
|
||||
@@ -31,6 +31,8 @@ class RenderGrass : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||
}
|
||||
}
|
||||
|
||||
val noise = simplexNoise()
|
||||
|
||||
val normalIcons = iconSet(BetterFoliageMod.LEGACY_DOMAIN, "blocks/better_grass_long_%d")
|
||||
val snowedIcons = iconSet(BetterFoliageMod.LEGACY_DOMAIN, "blocks/better_grass_snowed_%d")
|
||||
val normalGenIcon = iconStatic(Client.genGrass.generatedResource("minecraft:blocks/tallgrass", "snowed" to false))
|
||||
@@ -57,7 +59,12 @@ class RenderGrass : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||
val isSnowed = ctx.blockState(up1).isSnow
|
||||
val connectedGrass = isConnected && Config.connectedGrass.enabled && (!isSnowed || Config.connectedGrass.snowEnabled)
|
||||
|
||||
val grassInfo = GrassRegistry[ctx, UP]!!
|
||||
val grassInfo = GrassRegistry[ctx, UP]
|
||||
if (grassInfo == null) {
|
||||
// shouldn't happen
|
||||
Client.logRenderError(ctx.blockState(Int3.zero), ctx.pos)
|
||||
return renderWorldBlockBase(ctx, dispatcher, renderer, null)
|
||||
}
|
||||
val blockColor = ctx.blockData(Int3.zero).color
|
||||
|
||||
if (connectedGrass) {
|
||||
@@ -92,6 +99,7 @@ class RenderGrass : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||
if (!Config.shortGrass.grassEnabled) return true
|
||||
if (isSnowed && !Config.shortGrass.snowEnabled) return true
|
||||
if (ctx.blockState(up1).isOpaqueCube) return true
|
||||
if (Config.shortGrass.population < 64 && noise[ctx.pos] >= Config.shortGrass.population) return true
|
||||
|
||||
// render grass quads
|
||||
val iconset = if (isSnowed) snowedIcons else normalIcons
|
||||
|
||||
@@ -1,6 +1,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.ShadersModIntegration
|
||||
import mods.betterfoliage.client.texture.LeafRegistry
|
||||
@@ -50,7 +51,12 @@ class RenderLeaves : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
||||
val isSnowed = ctx.blockState(up1).material.let {
|
||||
it == Material.SNOW || it == Material.CRAFTED_SNOW
|
||||
}
|
||||
val leafInfo = LeafRegistry[ctx, DOWN] ?: return false
|
||||
val leafInfo = LeafRegistry[ctx, DOWN]
|
||||
if (leafInfo == null) {
|
||||
// shouldn't happen
|
||||
Client.logRenderError(ctx.blockState(Int3.zero), ctx.pos)
|
||||
return renderWorldBlockBase(ctx, dispatcher, renderer, null)
|
||||
}
|
||||
val blockColor = ctx.blockData(Int3.zero).color
|
||||
|
||||
renderWorldBlockBase(ctx, dispatcher, renderer, null)
|
||||
|
||||
@@ -20,6 +20,7 @@ import net.minecraftforge.common.MinecraftForge
|
||||
import net.minecraftforge.fml.relauncher.Side
|
||||
import net.minecraftforge.fml.relauncher.SideOnly
|
||||
import org.apache.logging.log4j.Level
|
||||
import java.lang.Math.min
|
||||
|
||||
const val defaultGrassColor = 0
|
||||
|
||||
@@ -93,8 +94,9 @@ object StandardGrassSupport :
|
||||
logger.log(Level.DEBUG, "$logName: texture ${texture.iconName}")
|
||||
val hsb = HSB.fromColor(texture.averageColor ?: defaultGrassColor)
|
||||
val overrideColor = if (hsb.saturation >= Config.shortGrass.saturationThreshold) {
|
||||
logger.log(Level.DEBUG, "$logName: brightness ${hsb.brightness}")
|
||||
logger.log(Level.DEBUG, "$logName: saturation ${hsb.saturation} >= ${Config.shortGrass.saturationThreshold}, using texture color")
|
||||
hsb.copy(brightness = 0.9f).asColor
|
||||
hsb.copy(brightness = min(0.9f, hsb.brightness * 2.0f)).asColor
|
||||
} else {
|
||||
logger.log(Level.DEBUG, "$logName: saturation ${hsb.saturation} < ${Config.shortGrass.saturationThreshold}, using block color")
|
||||
null
|
||||
|
||||
Reference in New Issue
Block a user