grass, foliage: fix gray particle color

This commit is contained in:
Bixilon 2022-12-14 15:41:32 +01:00
parent 0964368375
commit f59fb270db
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
3 changed files with 30 additions and 6 deletions

View File

@ -30,7 +30,7 @@ class FoliageTintCalculator : TintProvider {
colorMap = assetsManager["minecraft:colormap/foliage".toResourceLocation().texture()].readRGBArray()
}
override fun getBlockColor(blockState: BlockState, biome: Biome?, x: Int, y: Int, z: Int, tintIndex: Int): Int {
fun getBlockColor(biome: Biome?, y: Int): Int {
if (biome == null) {
return FALLBACK_COLOR
}
@ -38,6 +38,14 @@ class FoliageTintCalculator : TintProvider {
return colorMap[biome.downfallColorMapCoordinate shl 8 or biome.getClampedTemperature(y)]
}
override fun getBlockColor(blockState: BlockState, biome: Biome?, x: Int, y: Int, z: Int, tintIndex: Int): Int {
return getBlockColor(biome, y)
}
override fun getParticleColor(blockState: BlockState, biome: Biome?, x: Int, y: Int, z: Int): Int {
return getBlockColor(biome, y)
}
override fun getItemColor(item: Item, tintIndex: Int): Int {
return FALLBACK_COLOR
}

View File

@ -18,6 +18,7 @@ import de.bixilon.minosoft.assets.util.FileUtil.readRGBArray
import de.bixilon.minosoft.data.registries.biomes.Biome
import de.bixilon.minosoft.data.registries.biomes.GrassColorModifiers
import de.bixilon.minosoft.data.registries.blocks.BlockState
import de.bixilon.minosoft.data.registries.blocks.MinecraftBlocks
import de.bixilon.minosoft.data.text.formatting.color.Colors
import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture
import de.bixilon.minosoft.util.KUtil.toResourceLocation
@ -45,7 +46,7 @@ class GrassTintCalculator : TintProvider {
return color
}
override fun getBlockColor(blockState: BlockState, biome: Biome?, x: Int, y: Int, z: Int, tintIndex: Int): Int {
fun getBlockColor(biome: Biome?): Int {
if (biome == null) {
return getColor(127, 127)
}
@ -58,7 +59,14 @@ class GrassTintCalculator : TintProvider {
}
}
override fun getBlockColor(blockState: BlockState, biome: Biome?, x: Int, y: Int, z: Int, tintIndex: Int): Int {
return getBlockColor(biome)
}
override fun getParticleColor(blockState: BlockState, biome: Biome?, x: Int, y: Int, z: Int): Int {
return Colors.WHITE
if (blockState.block.resourceLocation == MinecraftBlocks.GRASS_BLOCK) {
return Colors.WHITE
}
return getBlockColor(biome)
}
}

View File

@ -20,11 +20,19 @@ import de.bixilon.minosoft.data.registries.blocks.properties.Halves
class TallGrassTintCalculator(val grassTintCalculator: GrassTintCalculator) : TintProvider {
override fun getBlockColor(blockState: BlockState, biome: Biome?, x: Int, y: Int, z: Int, tintIndex: Int): Int {
fun getColor(blockState: BlockState, biome: Biome?): Int {
return if (blockState.properties[BlockProperties.STAIR_HALF] == Halves.UPPER) {
grassTintCalculator.getBlockColor(blockState, biome, x, y - 1, z, tintIndex)
grassTintCalculator.getBlockColor(biome)
} else {
grassTintCalculator.getBlockColor(blockState, biome, x, y, z, tintIndex)
grassTintCalculator.getBlockColor(biome)
}
}
override fun getBlockColor(blockState: BlockState, biome: Biome?, x: Int, y: Int, z: Int, tintIndex: Int): Int {
return getColor(blockState, biome)
}
override fun getParticleColor(blockState: BlockState, biome: Biome?, x: Int, y: Int, z: Int): Int {
return getColor(blockState, biome)
}
}