diff --git a/CHANGELOG.md b/CHANGELOG.md index 1519760..eac50a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.21.2-2.2.0 + +### Added + +- Brightness adjustment based on in-game fog brightness (you can increase or decrease the brightness calculated by the game) + ## 1.21.2-2.1.0 ### Added diff --git a/README.md b/README.md index d1c786c..aeb57ee 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ Read more about the available features in the [🛠️ Configuration](#-configur
- ⛔️ Disable fog based on the game mode + ⛔️ Disable fog for specific game modes ![no-fog-game-modes.gif](docs/images/no-fog-game-modes.gif) @@ -223,7 +223,10 @@ Preset files are located in the `config/foggypalegarden` directory. Each file co "mode": "FIXED", // (required for FIXED mode) fog brightness level in percent (0.0, 100.0] - "fixedBrightness": 0.0 + "fixedBrightness": 0.0, + + // (optional for BY_GAME_FOG mode) brightness adjustment [-1.0, 1.0] + "adjustment": 0.0 }, // (optional) fog color settings diff --git a/build.gradle.kts b/build.gradle.kts index 1934679..f10d768 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -115,14 +115,8 @@ if (modrinthToken != null) { versionType.set("release") uploadFile.set(File("build/libs/${project.base.archivesName.get()}-${project.version}.jar")) changelog.set(getChangelogForVersion("${project.property("minecraftReleaseVersion")}-${project.property("modVersion")}")) - gameVersions.set( - listOf( - project.property("minecraftFirstSnapshotVersion").toString(), - // TODO check versions - // project.property("minecraftReleaseVersion").toString() - ) - ) - loaders.set(project.property("fabricSupportedLoaders").toString().split(',').map { it.trim().lowercase() }) + gameVersions.set(project.property("fabricModrinthGameVersions").toString().split(',').map { it.trim() }) + loaders.set(project.property("fabricSupportedLoaders").toString().split(',').map { it.trim().lowercase() }.toSet()) additionalFiles.set(listOf(File("build/libs/${project.base.archivesName.get()}-${project.version}-sources.jar"))) } } @@ -136,9 +130,7 @@ if (curseForgeApiKey != null) { releaseType = "release" changelogType = "markdown" changelog = getChangelogForVersion("${project.property("minecraftReleaseVersion")}-${project.property("modVersion")}") - gameVersionStrings.add(project.property("minecraftSnapshotVersion").toString()) - // TODO check versions - // gameVersionStrings.add(project.property("minecraftReleaseVersion").toString()) + gameVersionStrings.addAll(project.property("fabricCurseForgeGameVersions").toString().split(',').map { it.trim() }.toSet()) gameVersionStrings.addAll(project.property("fabricSupportedLoaders").toString().split(',').map { it.trim() }) // TODO side // gameVersionStrings.add("Client") diff --git a/docs/presets/custom/SNOWY_VEIL.v2.json b/docs/presets/custom/SNOWY_VEIL.v2.json new file mode 100644 index 0000000..9e067f0 --- /dev/null +++ b/docs/presets/custom/SNOWY_VEIL.v2.json @@ -0,0 +1,52 @@ +{ + "code": "SNOWY_VEIL", + "bindings": [ + { + "condition": { + "and": [ + { "weatherIn": ["RAIN"] }, + { "dimensionIn": ["minecraft:overworld"] }, + { "biomeTemperature": { "max": 0.0 } } + ] + }, + "startDistance": 2.0, + "skyLightStartLevel": 4, + "endDistance": 15.0, + "surfaceHeightEnd": 128.0, + "opacity": 95.0, + "encapsulationSpeed": 6.0, + "brightness": { + "mode": "BY_GAME_FOG", + "adjustment": 0.5 + }, + "color": { + "mode": "BY_GAME_FOG", + "fixedHex": "E9E7F8" + } + }, + { + "condition": { + "and": [ + { "weatherIn": ["THUNDER"] }, + { "dimensionIn": ["minecraft:overworld"] }, + { "biomeTemperature": { "max": 0.0 } } + ] + }, + "startDistance": 0.0, + "skyLightStartLevel": 4, + "endDistance": 10.0, + "surfaceHeightEnd": 128.0, + "opacity": 100.0, + "encapsulationSpeed": 6.0, + "brightness": { + "mode": "BY_GAME_FOG", + "adjustment": 0.5 + }, + "color": { + "mode": "BY_GAME_FOG", + "fixedHex": "E9E7F8" + } + } + ], + "version": 2 +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 2257579..4376a2a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.parallel=true group=com.naocraftlab modId=foggy-pale-garden modCurseForgeId=1114471 -modVersion=2.1.0 +modVersion=2.2.0 modName=Foggy Pale Garden modDescription=Adds dense fog to the Pale Garden biome. modLicense=MIT @@ -19,9 +19,10 @@ minecraftJavaVersion=21 minecraftFirstSnapshotVersion=24w40a minecraftFirstSnapshotFullVersion=1.21.2-alpha.24.40.a minecraftReleaseVersion=1.21.2 -minecraftSnapshotVersion=1.21.2-Snapshot # fabric fabricSupportedLoaders=Fabric, Quilt fabricYarnMappingsVersion=24w40a+build.11 fabricLoaderMinVersion=0.16.4 +fabricModrinthGameVersions=24w40a,1.21.2-pre1 +fabricCurseForgeGameVersions=1.21.2-Snapshot diff --git a/src/main/java/com/naocraftlab/foggypalegarden/config/FogPresetV2.java b/src/main/java/com/naocraftlab/foggypalegarden/config/FogPresetV2.java index 0a51eb0..f107410 100644 --- a/src/main/java/com/naocraftlab/foggypalegarden/config/FogPresetV2.java +++ b/src/main/java/com/naocraftlab/foggypalegarden/config/FogPresetV2.java @@ -219,7 +219,8 @@ public Predicate toPredicate() { @Builder public record Brightness( BrightnessMode mode, - Float fixedBrightness + Float fixedBrightness, + Float adjustment ) { public enum BrightnessMode { @@ -230,9 +231,13 @@ public enum BrightnessMode { public void validate() { if (mode == BrightnessMode.FIXED && (fixedBrightness == null || fixedBrightness < 0.0f || fixedBrightness > 100.0f)) { throw new FoggyPaleGardenConfigurationException( - "Binding fixedBrightness is not defined or out of range [0.0, 1.0]" + "Binding brightness fixedBrightness is not defined or out of range [0.0, 1.0]" ); } + if (mode == BrightnessMode.BY_GAME_FOG && adjustment != null + && (adjustment < -1.0f || adjustment > 1.0f)) { + throw new FoggyPaleGardenConfigurationException("Binding brightness adjustment is out of range [-1.0, 1.0]"); + } } } @@ -278,7 +283,7 @@ public Float encapsulationSpeed() { @Override public Brightness brightness() { - return brightness == null ? new Brightness(BrightnessMode.BY_GAME_FOG, null) : brightness; + return brightness == null ? new Brightness(BrightnessMode.BY_GAME_FOG, null, null) : brightness; } @Override diff --git a/src/main/java/com/naocraftlab/foggypalegarden/domain/service/FogService.java b/src/main/java/com/naocraftlab/foggypalegarden/domain/service/FogService.java index e1a0bfc..ae693f3 100644 --- a/src/main/java/com/naocraftlab/foggypalegarden/domain/service/FogService.java +++ b/src/main/java/com/naocraftlab/foggypalegarden/domain/service/FogService.java @@ -75,6 +75,30 @@ private static Color calculateColor(Color gameFogColor, FogPresetV2.Binding bind red = Math.min(hexToRed(binding.color().fixedHex()) * brightness, 1.0f); green = Math.min(hexToGreen(binding.color().fixedHex()) * brightness, 1.0f); blue = Math.min(hexToBlue(binding.color().fixedHex()) * brightness, 1.0f); + if (binding.brightness().adjustment() != null) { + float adjustment = binding.brightness().adjustment(); + + if (adjustment >= 0) { + red = red + adjustment * (1.0f - red); + } else { + red = red + adjustment * red; + } + red = Math.max(0.0f, Math.min(red, 1.0f)); + + if (adjustment >= 0) { + green = green + adjustment * (1.0f - green); + } else { + green = green + adjustment * green; + } + green = Math.max(0.0f, Math.min(green, 1.0f)); + + if (adjustment >= 0) { + blue = blue + adjustment * (1.0f - blue); + } else { + blue = blue + adjustment * blue; + } + blue = Math.max(0.0f, Math.min(blue, 1.0f)); + } } else if (brightnessMode == BrightnessMode.FIXED && colorMode == ColorMode.BY_GAME_FOG) { val targetBrightness = binding.brightness().fixedBrightness() / 100.0f; val currentBrightness = calculateBrightness(gameFogColor); @@ -86,6 +110,30 @@ private static Color calculateColor(Color gameFogColor, FogPresetV2.Binding bind red = gameFogColor.red(); green = gameFogColor.green(); blue = gameFogColor.blue(); + if (binding.brightness().adjustment() != null) { + float adjustment = binding.brightness().adjustment(); + + if (adjustment >= 0) { + red = red + adjustment * (1.0f - red); + } else { + red = red + adjustment * red; + } + red = Math.max(0.0f, Math.min(red, 1.0f)); + + if (adjustment >= 0) { + green = green + adjustment * (1.0f - green); + } else { + green = green + adjustment * green; + } + green = Math.max(0.0f, Math.min(green, 1.0f)); + + if (adjustment >= 0) { + blue = blue + adjustment * (1.0f - blue); + } else { + blue = blue + adjustment * blue; + } + blue = Math.max(0.0f, Math.min(blue, 1.0f)); + } } val alpha = (binding.opacity() > 0f) ? fogDensity * (binding.opacity() / 100f - 0.001f) : 0f; return Color.builder()