biomes: add sky color (just the base color), blocks: fix tint color

This commit is contained in:
Bixilon 2021-03-24 16:47:42 +01:00
parent 40edfdffcc
commit 172651ce17
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 14 additions and 5 deletions

View File

@ -33,10 +33,11 @@ object BiomeGenerator : Generator(
BIOME_SKY_COLOR_FIELD?.getInt(biome)?.let {
biomeData.addProperty("sky_color", it)
} ?: let {
biomeData.addProperty("sky_color", SKY_COLOR_FUNCTION!!.invoke(biome, 0.0f) as Int)
}
getField(Biome::class.java, "specialEffects")?.get(biome)?.let {
FOG_COLOR_SPECIAL_EFFECTS_FIELD?.getInt(it)?.let {
biomeData.addProperty("fog_color", it)
@ -73,6 +74,12 @@ object BiomeGenerator : Generator(
}
}
private val SKY_COLOR_FUNCTION = try {
Biome::class.java.getDeclaredMethod("getSkyColor", Float::class.java)
} catch (exception: Exception) {
null
}
private val SPECIAL_EFFECTS_CLASS = getClass("net.minecraft.world.level.biome.BiomeSpecialEffects")
private val CLIMATE_SETTINGS_CLASS = getClass("net.minecraft.world.level.biome.Biome\$ClimateSettings", "net.minecraft.world.level.biome.Biome", "net.minecraft.world.biome.Biome")!!

View File

@ -127,7 +127,8 @@ object BlockGenerator : Generator(
}
val hasColorProperties = (TINT_PROPERTIES_METHOD?.invoke(DEFAULT_BLOCK_COLORS, block) as Set<*>?)?.size?.let { it > 0 } ?: let {
true
val blockColorProviderList = BLOCK_COLORS_PROVIDERS_ID_LIST!!.get(DEFAULT_BLOCK_COLORS) as IdList<Any>
blockColorProviderList.get(Registry.BLOCK.getRawId(block)) != null
}
val states = JsonObject()
@ -199,10 +200,9 @@ object BlockGenerator : Generator(
try {
if (hasColorProperties) {
val tintColor = DEFAULT_BLOCK_COLORS.getColor(state, null, null)
if (tintColor == -1) {
throw IllegalStateException()
if (tintColor != -1 && tintColor != 0) {
stateData.addProperty("tint_color", tintColor)
}
stateData.addProperty("tint_color", tintColor)
}
} catch (exception: Exception) {
}
@ -332,6 +332,8 @@ object BlockGenerator : Generator(
}
}
private val BLOCK_COLORS_PROVIDERS_ID_LIST = getField(BlockColors::class.java, "providers")
private val TINT_PROPERTIES_METHOD = try {
BlockColors::class.java.getDeclaredMethod("method_21592")
} catch (exception: Exception) {