Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fog shape control (available options: SPHERE and CYLINDER)
Browse files Browse the repository at this point in the history
NaoCraftLab committed Oct 9, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent ba04ba6 commit 7eadd7b
Showing 6 changed files with 23 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

- Condition for applying fog based on the dimension the player is in
- Condition for applying fog based on the temperature of the biome the player is in
- Fog shape control (available options: SPHERE and CYLINDER)

## 1.21.2-2.0.0

16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -98,6 +98,7 @@ Read more about the available features in the [🛠️ Configuration](#-configur
- Speed of fog dispersal when entering or leaving it
- Sky light brightness below which the fog disperses (allows excluding fog in caves)
- Player's height above the surface after which the fog disperses (allows excluding fog while flying)
- Fog shape (available options: SPHERE and CYLINDER)

### Fog Conditions

@@ -147,10 +148,10 @@ Preset files are located in the `config/foggypalegarden` directory. Each file co
// incorrect - { "biomeIdIn": ["minecraft:desert"], "difficultyIn": ["HARD"] }
"condition": {

// (optional) list of dimensions where this binding is applied
// (optional) list of dimensions where this binding is applied (for example, "minecraft:overworld")
"dimensionIn": [""],

// (optional) list of biomes where this binding is applied
// (optional) list of biomes where this binding is applied (for example, "minecraft:desert")
"biomeIdIn": [""],

// (optional) biome temperature range where this binding is applied
@@ -163,10 +164,10 @@ Preset files are located in the `config/foggypalegarden` directory. Each file co
"max": 0.0
},

// (optional) list of difficulty levels where this binding is applied
// (optional) list of difficulty levels where this binding is applied ("PEACEFUL", "EASY", "NORMAL", "HARD")
"difficultyIn": [""],

// (optional) list of weather conditions where this binding is applied
// (optional) list of weather conditions where this binding is applied ("CLEAR", "RAIN", "THUNDER")
"weatherIn": [""],

// (optional) time range during which this binding is applied (start can be greater than end)
@@ -223,7 +224,10 @@ Preset files are located in the `config/foggypalegarden` directory. Each file co

// (required for FIXED mode) fog color in HEX format (without #)
"fixedHex": "f0f0f0"
}
},

// (optional) fog shape ("SPHERE", "CYLINDER")
"shape": "CYLINDER"
},
{
// another binding
@@ -249,8 +253,8 @@ If you encounter compatibility issues between Foggy Pale Garden and other mods,
✅ Add configurations<br/>
✅ Apply fog conditions depending on player’s current dimension<br/>
✅ Apply fog conditions based on biome temperature<br/>
✅ Control the shape of fog<br/>
🚀 Disable fog based on game mode<br/>
🚀 Control the shape of fog<br/>
🚀 (After the Winter Drop release) Port to NeoForge<br/>
🚀 (After the Winter Drop release) Add visual configuration<br/>
🚀 Port to previous game versions and add support for mods backporting the Pale Garden
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.val;
import net.minecraft.client.render.FogShape;
import net.minecraft.world.Difficulty;

import java.util.List;
@@ -48,7 +49,8 @@ public record Binding(
Float opacity,
Float encapsulationSpeed,
Brightness brightness,
Color color
Color color,
FogShape shape
) {

@Builder
@@ -284,6 +286,11 @@ public Color color() {
return color == null ? new Color(ColorMode.BY_GAME_FOG, null) : color;
}

@Override
public FogShape shape() {
return shape == null ? FogShape.SPHERE : shape;
}

public void validate() {
if (condition == null) {
throw new FoggyPaleGardenConfigurationException("Binding condition is not defined");
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.naocraftlab.foggypalegarden.domain.model;

import lombok.Builder;
import net.minecraft.client.render.FogShape;

@Builder
public record FogCharacteristics(
float startDistance,
float endDistance,
Color color,
FogShape shape,
float fogDensity
) {
}
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@ && isSkyLightLevelValid(currentBinding, environment)
.startDistance(currentBinding.startDistance())
.endDistance(currentBinding.endDistance())
.color(calculateColor(environment.gameFogColor(), currentBinding, fogDensity))
.shape(currentBinding.shape())
.fogDensity(fogDensity)
.build();
}
Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@
import static com.naocraftlab.foggypalegarden.domain.model.Weather.CLEAR;
import static com.naocraftlab.foggypalegarden.domain.model.Weather.RAIN;
import static com.naocraftlab.foggypalegarden.domain.model.Weather.THUNDER;
import static net.minecraft.client.render.FogShape.SPHERE;
import static net.minecraft.world.LightType.SKY;
import static net.minecraft.world.RaycastContext.FluidHandling.NONE;
import static net.minecraft.world.RaycastContext.ShapeType.COLLIDER;
@@ -109,7 +108,7 @@ private static Fog fogOf(FogCharacteristics fogCharacteristics) {
return new Fog(
fogCharacteristics.startDistance(),
fogCharacteristics.endDistance(),
SPHERE,
fogCharacteristics.shape(),
fogCharacteristics.color().red(),
fogCharacteristics.color().green(),
fogCharacteristics.color().blue(),

0 comments on commit 7eadd7b

Please sign in to comment.