Skip to content

Commit 97504f7

Browse files
committed
Added height render condition and moving skybox
1 parent 94796a2 commit 97504f7

File tree

16 files changed

+132
-27
lines changed

16 files changed

+132
-27
lines changed

changelog.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# Sky Aesthetics 2.0.8-BETA Changelog
1+
# Sky Aesthetics 2.0.9-BETA Changelog
22

3-
## Changes
4-
- Update exo config to fix a crash when joining a world.
3+
## Features
4+
- Added new render condition : player height
5+
- The Skybox can now be rotated (see the wiki for more information)
6+
7+
## Change
8+
- Change default skybox from saturn to milky way (- 7Mb of size 💀)

common/src/main/java/fr/tathan/sky_aesthetics/client/DimensionRenderer.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
import java.util.List;
2222
import java.util.UUID;
2323

24+
/**
25+
* The class handling the rendering of a custom sky
26+
*/
2427
public class DimensionRenderer {
2528

2629
public final List<SkyObject> skyObjects;
@@ -68,7 +71,6 @@ public boolean canRenderSky() {
6871

6972
public void render(ClientLevel level, PoseStack poseStack, Matrix4f projectionMatrix, float partialTick, Camera camera, Runnable fogCallback) {
7073

71-
7274
Tesselator tesselator = Tesselator.getInstance();
7375
float dayAngle = level.getTimeOfDay(partialTick) * 360f % 360f;
7476
float nightAngle = dayAngle + 180;
@@ -83,7 +85,6 @@ public void render(ClientLevel level, PoseStack poseStack, Matrix4f projectionMa
8385
this.skyColor.setSkyColor(level, camera, partialTick);
8486

8587
SkyHelper.drawSky(poseStack.last().pose(), projectionMatrix);
86-
SkyAesthetics.LOG.error("rotation {}", dayAngle);
8788

8889
if(this.skyBoxSetting != null) {
8990
this.skyBoxSetting.renderSkyBox(poseStack, projectionMatrix, camera,dayAngle);
@@ -138,10 +139,14 @@ public static class Builder {
138139
public List<SkyObject> skyObjects = new ArrayList<>();
139140
// Default cloud settings: show clouds and set height to 192
140141
public CloudSettings cloudSettings = CloudSettings.createDefaultSettings();
142+
//No sun and moon by default
141143
public CustomVanillaObject.Sun sun = null;
142144
public CustomVanillaObject.Moon moon = null;
145+
143146
public FogSettings fogSettings = FogSettings.createDefaultSettings();
144147
public StarSettings star = StarSettings.createDefaultStars();
148+
149+
//Always render sky by default
145150
public SkyProperties.RenderCondition renderCondition = null;
146151
public SkyColorSettings skyColor = SkyColorSettings.createDefaultSettings();
147152
public boolean weather = true; // Default to true

common/src/main/java/fr/tathan/sky_aesthetics/client/data/SkiesRegistry.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
import java.util.HashMap;
1818
import java.util.Map;
1919

20+
/**
21+
* The registry handling the loading of custom skies from data packs
22+
*/
2023
public class SkiesRegistry extends SimpleJsonResourceReloadListener {
2124

2225
public static final Map<ResourceLocation, DimensionSky> SKY_PROPERTIES = new HashMap<>();
@@ -54,6 +57,12 @@ protected void apply(Map<ResourceLocation, JsonElement> object, @Nullable Resour
5457
});
5558
}
5659

60+
/**
61+
* Allow to register sky.
62+
* Can be used to register skies from code/at runtime.
63+
* @param id the id of the sky to register
64+
* @param sky the sky to register
65+
*/
5766
public static void registerSky(ResourceLocation id, DimensionSky sky) {
5867
if(SKY_PROPERTIES.containsKey(id)) {
5968
SkyAesthetics.LOG.warn("Sky with id {} already exists, overwriting it", id);

common/src/main/java/fr/tathan/sky_aesthetics/client/screens/SkiesComponents.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,29 @@ public static CollapsibleContainer createSkyBoxSettings(Optional<SkyBoxSetting>
103103
.tooltip(Component.literal("The Sphere rotation"))
104104
.id("rotation"));
105105

106+
container.child(createDynamicRotation(setting.dynamicRotation).id("dynamic_rotation"));
107+
108+
return container;
109+
}
110+
public static CollapsibleContainer createDynamicRotation(Optional<Rotation> settings) {
111+
CollapsibleContainer container = (CollapsibleContainer) Containers.collapsible(Sizing.content(), Sizing.content(0), Component.literal("Dynamic Rotation (Optionnal)"), settings.isPresent()).id("dynamic_rotation");
112+
113+
if(settings.isEmpty() && container.expanded()) container.toggleExpansion();
114+
115+
Rotation rotation = settings.orElseGet(Rotation::createDefaultSettings);
116+
117+
container.child(textBox(Sizing.fill(40))
118+
.text(rotation.axis().getSerializedName())
119+
.id("axis")
120+
.tooltip(Component.literal("The rotation axis.").append("\nPossible Values : XP, ZP, YP"))
121+
);
122+
container.child(textBox(Sizing.fill(40))
123+
.text(rotation.rotationType())
124+
.id("rotation_type")
125+
.tooltip(Component.literal("The rotation type.").append("\nPossible Values : DAY, NIGHT, STATIC"))
126+
127+
);
128+
106129
return container;
107130
}
108131

@@ -266,6 +289,8 @@ public static CollapsibleContainer createLightSettings(Optional<LightSettings> s
266289
}
267290

268291

292+
293+
269294
public static TextBoxComponent textBox(Sizing horizontalSizing) {
270295
TextBoxComponent component = Components.textBox(horizontalSizing);
271296
component.setMaxLength(600);

common/src/main/java/fr/tathan/sky_aesthetics/client/screens/SkyModificationScreen.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,25 @@ public static SkyProperties fromComponent(FlowLayout component) {
278278

279279
CollapsibleContainer skyBoxSetting = component.childById(CollapsibleContainer.class, "skybox_settings");
280280

281+
Optional<Rotation> rotation = Optional.empty();
282+
283+
if(skyBoxSetting.expanded()) {
284+
CollapsibleContainer dynamicRotationSettings = skyBoxSetting.childById(CollapsibleContainer.class, "dynamic_rotation");
285+
286+
rotation = !dynamicRotationSettings.expanded() ? Optional.empty() :
287+
Optional.of(new Rotation(
288+
Rotation.Axis.valueOf(dynamicRotationSettings.childById(TextBoxComponent.class, "axis").getValue()),
289+
getRotationType(dynamicRotationSettings.childById(TextBoxComponent.class, "rotation_type").getValue())
290+
));
291+
292+
}
293+
281294
Optional<SkyBoxSetting> skyBox = !skyBoxSetting.expanded() ? Optional.empty() :
282295
Optional.of(new SkyBoxSetting(
283296
(int) skyBoxSetting.childById(DiscreteSliderComponent.class, "gradation").discreteValue(),
284297
ResourceLocation.parse(skyBoxSetting.childById(TextBoxComponent.class, "texture").getValue()),
285298
getVec3fFromComponent(skyBoxSetting.childById(FlowLayout.class, "rotation")).orElseGet(Vector3f::new),
286-
Optional.of(Rotation.createDefaultSettings()))
299+
rotation)
287300
);
288301

289302
CollapsibleContainer lightSettings = component.childById(CollapsibleContainer.class, "light_settings");
@@ -314,8 +327,9 @@ public static SkyProperties fromComponent(FlowLayout component) {
314327

315328
public static String getRotationType(String str) {
316329
return switch (str.toLowerCase()) {
317-
case "static" -> "STATIC";
318330
case "day" -> "DAY";
331+
case "night" -> "NIGHT";
332+
319333
default -> "STATIC";
320334
};
321335
}

common/src/main/java/fr/tathan/sky_aesthetics/client/skies/settings/CloudSettings.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
public record CloudSettings(boolean showCloud, Integer cloudHeight) {
99

10-
1110
public static CloudSettings createDefaultSettings() {
1211
return new CloudSettings(true, 192);
1312
}

common/src/main/java/fr/tathan/sky_aesthetics/client/skies/settings/Constellation.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
import java.util.Optional;
1010

1111
public record Constellation(
12-
String id, float scale, Vec3 color, Vec3 firstPoint, List<Vec3> points, Optional<ResourceLocation> starTexture
13-
) {
12+
String id, float scale, Vec3 color, Vec3 firstPoint, List<Vec3> points, Optional<ResourceLocation> starTexture) {
1413

1514
public static final Codec<Constellation> CODEC = RecordCodecBuilder.create(instance -> instance.group(
1615
Codec.STRING.fieldOf("id").forGetter(Constellation::id),

common/src/main/java/fr/tathan/sky_aesthetics/client/skies/settings/CustomVanillaObject.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
import net.minecraft.client.multiplayer.ClientLevel;
1111
import net.minecraft.resources.ResourceLocation;
1212

13+
/**
14+
* Custom vanilla objects like sun and moon with custom textures, sizes and heights.
15+
*/
1316
public class CustomVanillaObject{
1417

1518
public record Sun(ResourceLocation sunTexture, Float sunHeight, Float sunSize) {

common/src/main/java/fr/tathan/sky_aesthetics/client/skies/settings/FogSettings.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
import java.util.List;
1111
import java.util.Optional;
1212

13+
/**
14+
* The class containing information about fog settings
15+
* @param fog Whether fog is enabled
16+
* @param customFogColor The custom RGB color of the fog
17+
* @param fogDensity The density settings of the fog (near, far)
18+
*/
1319
public record FogSettings(Boolean fog, Optional<Vector3i> customFogColor, Optional<Vector2f> fogDensity) {
1420

1521
public static Codec<Vector2f> VEC2F = Codec.FLOAT.listOf().comapFlatMap((list) -> Util.fixedSize(list, 2).map((listx) -> new Vector2f(listx.getFirst(), listx.getLast())), (vector2f) -> List.of(vector2f.x, vector2f.y));

common/src/main/java/fr/tathan/sky_aesthetics/client/skies/settings/LightSettings.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
import com.mojang.serialization.Codec;
44
import com.mojang.serialization.codecs.RecordCodecBuilder;
55

6+
/**
7+
* Settings related to lighting in the sky.
8+
*
9+
* @param forceBrightLightmap If true, forces a bright lightmap regardless of time of day.
10+
* @param constantAmbientLight If true, maintains constant ambient light levels.
11+
*/
612
public record LightSettings(
713
boolean forceBrightLightmap,
814
boolean constantAmbientLight) {

0 commit comments

Comments
 (0)