replace BiomePrecipitation.NONE ang GrassColorModifiers.NONE with null

This commit is contained in:
Moritz Zwerger 2023-10-10 20:14:07 +02:00
parent 4ffd4b6470
commit f9d9325384
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
6 changed files with 12 additions and 12 deletions

View File

@ -59,6 +59,8 @@ abstract class RegistryLoadingTest(val versionName: String) {
fun biome() { fun biome() {
if (version >= V_1_17) throw SkipException("Biomes are datapack only") if (version >= V_1_17) throw SkipException("Biomes are datapack only")
assertNotNull(registries.biome[minecraft("plains")]?.identifier) val plains = registries.biome[minecraft("plains")]!!
assertEquals(plains.temperature, 0.8f)
assertEquals(plains.downfall, 0.4f)
} }
} }

View File

@ -32,9 +32,9 @@ data class Biome(
val fogColor: RGBColor? = null, val fogColor: RGBColor? = null,
val waterColor: RGBColor?, val waterColor: RGBColor?,
val waterFogColor: RGBColor?, val waterFogColor: RGBColor?,
val precipitation: BiomePrecipitation, val precipitation: BiomePrecipitation?,
) : RegistryItem() { ) : RegistryItem() {
val grassColorModifier = GrassColorModifiers.BIOME_MAP[identifier] ?: GrassColorModifiers.NONE val grassColorModifier = GrassColorModifiers.BIOME_MAP[identifier]
val temperatureColorMapCoordinate = getColorMapCoordinate(temperature) val temperatureColorMapCoordinate = getColorMapCoordinate(temperature)
val downfallColorMapCoordinate = getColorMapCoordinate(downfall * temperature) val downfallColorMapCoordinate = getColorMapCoordinate(downfall * temperature)
val colorMapPixelIndex = downfallColorMapCoordinate shl 8 or temperatureColorMapCoordinate val colorMapPixelIndex = downfallColorMapCoordinate shl 8 or temperatureColorMapCoordinate
@ -70,7 +70,7 @@ data class Biome(
fogColor = fogColor, fogColor = fogColor,
waterColor = waterColor, waterColor = waterColor,
waterFogColor = waterFogColor, waterFogColor = waterFogColor,
precipitation = data["precipitation"]?.let { BiomePrecipitation[it] } ?: BiomePrecipitation.NONE, precipitation = data["precipitation"]?.let { BiomePrecipitation[it] },
) )
} }
} }

View File

@ -1,6 +1,6 @@
/* /*
* Minosoft * Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger * Copyright (C) 2020-2023 Moritz Zwerger
* *
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* *
@ -17,7 +17,6 @@ import de.bixilon.kutil.enums.EnumUtil
import de.bixilon.kutil.enums.ValuesEnum import de.bixilon.kutil.enums.ValuesEnum
enum class BiomePrecipitation { enum class BiomePrecipitation {
NONE,
RAIN, RAIN,
SNOW, SNOW,
; ;

View File

@ -1,6 +1,6 @@
/* /*
* Minosoft * Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger * Copyright (C) 2020-2023 Moritz Zwerger
* *
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* *
@ -17,7 +17,6 @@ import de.bixilon.kutil.enums.EnumUtil
import de.bixilon.kutil.enums.ValuesEnum import de.bixilon.kutil.enums.ValuesEnum
enum class GrassColorModifiers { enum class GrassColorModifiers {
NONE,
DARK_FOREST, DARK_FOREST,
SWAMP, SWAMP,
; ;

View File

@ -35,16 +35,16 @@ class WeatherOverlay(private val context: RenderContext) : Overlay {
private val config = context.connection.profiles.rendering.overlay.weather private val config = context.connection.profiles.rendering.overlay.weather
private val rain = context.textures.staticTextures.createTexture(RAIN) private val rain = context.textures.staticTextures.createTexture(RAIN)
private val snow = context.textures.staticTextures.createTexture(SNOW) private val snow = context.textures.staticTextures.createTexture(SNOW)
private val precipitation get() = context.connection.player.physics.positionInfo.biome?.precipitation ?: BiomePrecipitation.NONE private val precipitation get() = context.connection.player.physics.positionInfo.biome?.precipitation
override val render: Boolean override val render: Boolean
get() = world.dimension.effects.weather && world.weather.raining && when (precipitation) { // ToDo: Check if exposed to the sky get() = world.dimension.effects.weather && world.weather.raining && when (precipitation) { // ToDo: Check if exposed to the sky
BiomePrecipitation.NONE -> false null -> false
BiomePrecipitation.RAIN -> config.rain BiomePrecipitation.RAIN -> config.rain
BiomePrecipitation.SNOW -> config.snow BiomePrecipitation.SNOW -> config.snow
} }
private val texture: Texture? private val texture: Texture?
get() = when (precipitation) { get() = when (precipitation) {
BiomePrecipitation.NONE -> null null -> null
BiomePrecipitation.RAIN -> rain BiomePrecipitation.RAIN -> rain
BiomePrecipitation.SNOW -> snow BiomePrecipitation.SNOW -> snow
} }

View File

@ -54,7 +54,7 @@ class GrassTintCalculator : TintProvider {
val color = getColor(biome.colorMapPixelIndex) val color = getColor(biome.colorMapPixelIndex)
return when (biome.grassColorModifier) { return when (biome.grassColorModifier) {
GrassColorModifiers.NONE -> color null -> color
GrassColorModifiers.SWAMP -> 0x6A7039 // ToDo: Biome noise is applied here GrassColorModifiers.SWAMP -> 0x6A7039 // ToDo: Biome noise is applied here
GrassColorModifiers.DARK_FOREST -> (color and 0xFEFEFE) + 0x28340A shr 1 GrassColorModifiers.DARK_FOREST -> (color and 0xFEFEFE) + 0x28340A shr 1
} }