Skip to content

Commit 6601fd2

Browse files
committed
Small changes
1 parent a81869c commit 6601fd2

5 files changed

Lines changed: 43 additions & 40 deletions

File tree

src/main/java/btw/lowercase/skyboxify/config/SkyboxifyConfigScreen.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import net.minecraft.network.chat.CommonComponents;
3737
import net.minecraft.network.chat.Component;
3838
import net.minecraft.util.ARGB;
39+
import org.jspecify.annotations.NonNull;
3940
import org.visuals.legacy.lightconfig.lib.v1.Translations;
4041
import org.visuals.legacy.lightconfig.lib.v1.screen.InternalConfigScreen;
4142

@@ -86,7 +87,7 @@ protected void init() {
8687
}
8788

8889
@Override
89-
public void render(final GuiGraphics guiGraphics, final int mouseX, final int mouseY, final float tickDelta) {
90+
public void render(@NonNull final GuiGraphics guiGraphics, final int mouseX, final int mouseY, final float tickDelta) {
9091
super.render(guiGraphics, mouseX, mouseY, tickDelta);
9192
this.versionText.render(guiGraphics, mouseX, mouseY);
9293
}

src/main/java/btw/lowercase/skyboxify/skybox/SkyboxRenderer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import btw.lowercase.skyboxify.Skyboxify;
2727
import btw.lowercase.skyboxify.api.SkyboxifyImpl;
28+
import btw.lowercase.skyboxify.skybox.components.Weather;
2829
import btw.lowercase.skyboxify.utils.CommonUtils;
2930
import com.mojang.blaze3d.systems.RenderSystem;
3031
import com.mojang.blaze3d.vertex.*;
@@ -149,7 +150,7 @@ public void render(final Skybox skybox, final Matrix4f modelViewMatrix, final Cl
149150
}
150151

151152
private void renderLayer(final SkyLayer skyLayer, final Matrix4f modelViewMatrix, final Level level, final int timeOfDay, final float skyAngle, float rainLevel, float thunderLevel, float conditionAlpha) {
152-
final float weatherAlpha = CommonUtils.getWeatherAlpha(skyLayer.weatherConditions(), rainLevel, thunderLevel);
153+
final float weatherAlpha = Weather.getAlpha(skyLayer.weatherConditions(), rainLevel, thunderLevel);
153154
final float fadeAlpha = skyLayer.fade().getAlpha(timeOfDay);
154155
final float finalAlpha = Mth.clamp(conditionAlpha * weatherAlpha * fadeAlpha, 0.0F, 1.0F);
155156
if (!(finalAlpha < 1.0E-4F)) {

src/main/java/btw/lowercase/skyboxify/skybox/SkyboxResourceHelper.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,24 @@ public Identifier getFabricId() {
114114
if (SkyboxifyImpl.config().enabled.isEnabled()) {
115115
SkyboxifyImpl.skyboxManager().clearSkyboxes();
116116
theResourceManager.listPacks().forEach(pack -> {
117-
final List<Identifier> optifineSkies = new ArrayList<>();
118-
pack.listResources(PackType.CLIENT_RESOURCES, Identifier.DEFAULT_NAMESPACE, OPTIFINE_SKY_PARENT, filterResource(optifineSkies));
119-
optifineSkies.sort(compareLocations(OPTIFINE_SKY_PATTERN));
117+
final List<Identifier> optiFineSkies = new ArrayList<>();
118+
pack.listResources(PackType.CLIENT_RESOURCES, Identifier.DEFAULT_NAMESPACE, OPTIFINE_SKY_PARENT, filterResource(optiFineSkies));
119+
optiFineSkies.sort(compareLocations(OPTIFINE_SKY_PATTERN));
120120

121-
final List<Identifier> mcpatcherSkies = new ArrayList<>();
122-
pack.listResources(PackType.CLIENT_RESOURCES, Identifier.DEFAULT_NAMESPACE, MCPATCHER_SKY_PARENT, filterResource(mcpatcherSkies));
123-
mcpatcherSkies.sort(compareLocations(MCPATCHER_SKY_PATTERN));
121+
final List<Identifier> mcPatcherSkies = new ArrayList<>();
122+
pack.listResources(PackType.CLIENT_RESOURCES, Identifier.DEFAULT_NAMESPACE, MCPATCHER_SKY_PARENT, filterResource(mcPatcherSkies));
123+
mcPatcherSkies.sort(compareLocations(MCPATCHER_SKY_PATTERN));
124124

125125
Pattern skyPattern = OPTIFINE_SKY_PATTERN;
126-
if (optifineSkies.isEmpty()) {
126+
if (optiFineSkies.isEmpty()) {
127127
if (SkyboxifyImpl.config().debug.isEnabled()) {
128128
LOGGER.info("Couldn't find any skies inside \"{}\" under \"optifine\", searching for skies under \"mcpatcher\" instead...", pack.packId());
129129
}
130130

131131
skyPattern = MCPATCHER_SKY_PATTERN;
132132
}
133133

134-
final List<Identifier> skies = (skyPattern == OPTIFINE_SKY_PATTERN ? optifineSkies : mcpatcherSkies);
134+
final List<Identifier> skies = (skyPattern == OPTIFINE_SKY_PATTERN ? optiFineSkies : mcPatcherSkies);
135135
if (!skies.isEmpty()) {
136136
final int count = this.parseSkyboxesInPack(pack, skies, skyPattern);
137137
if (count > 0 && SkyboxifyImpl.config().debug.isEnabled()) {

src/main/java/btw/lowercase/skyboxify/skybox/components/Weather.java

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,41 @@
2424
package btw.lowercase.skyboxify.skybox.components;
2525

2626
import com.mojang.serialization.Codec;
27+
import net.minecraft.util.Mth;
2728
import net.minecraft.util.StringRepresentable;
2829
import org.jetbrains.annotations.NotNull;
2930

31+
import java.util.List;
32+
3033
public enum Weather implements StringRepresentable {
31-
CLEAR,
32-
RAIN,
33-
THUNDER;
34+
CLEAR,
35+
RAIN,
36+
THUNDER;
37+
38+
public static final Codec<Weather> CODEC = StringRepresentable.fromEnum(Weather::values);
39+
40+
public static float getAlpha(final List<Weather> weatherConditions, final float rainStrength, final float thunderStrength) {
41+
final float alpha = 1.0F - rainStrength;
42+
final float calculatedRainStrength = rainStrength - thunderStrength;
43+
44+
float weatherAlpha = 0.0F;
45+
if (weatherConditions.contains(Weather.CLEAR)) {
46+
weatherAlpha += alpha;
47+
}
48+
49+
if (weatherConditions.contains(Weather.RAIN)) {
50+
weatherAlpha += calculatedRainStrength;
51+
}
52+
53+
if (weatherConditions.contains(Weather.THUNDER)) {
54+
weatherAlpha += thunderStrength;
55+
}
3456

35-
public static final Codec<Weather> CODEC = StringRepresentable.fromEnum(Weather::values);
57+
return Mth.clamp(weatherAlpha, 0.0F, 1.0F);
58+
}
3659

37-
@Override
38-
public @NotNull String getSerializedName() {
39-
return this.name().toLowerCase();
40-
}
60+
@Override
61+
public @NotNull String getSerializedName() {
62+
return this.name().toLowerCase();
63+
}
4164
}

src/main/java/btw/lowercase/skyboxify/utils/CommonUtils.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
package btw.lowercase.skyboxify.utils;
2525

26-
import btw.lowercase.skyboxify.skybox.components.Weather;
2726
import lombok.experimental.UtilityClass;
2827
import net.minecraft.util.Mth;
2928
import org.joml.AxisAngle4f;
@@ -32,7 +31,6 @@
3231
import org.joml.Vector3fc;
3332

3433
import java.text.DecimalFormat;
35-
import java.util.List;
3634

3735
@UtilityClass
3836
public final class CommonUtils {
@@ -69,26 +67,6 @@ public static float calculateConditionAlphaValue(final float maxAlpha, final flo
6967
}
7068
}
7169

72-
public static float getWeatherAlpha(final List<Weather> weatherConditions, final float rainStrength, final float thunderStrength) {
73-
final float alpha = 1.0F - rainStrength;
74-
final float calculatedRainStrength = rainStrength - thunderStrength;
75-
76-
float weatherAlpha = 0.0F;
77-
if (weatherConditions.contains(Weather.CLEAR)) {
78-
weatherAlpha += alpha;
79-
}
80-
81-
if (weatherConditions.contains(Weather.RAIN)) {
82-
weatherAlpha += calculatedRainStrength;
83-
}
84-
85-
if (weatherConditions.contains(Weather.THUNDER)) {
86-
weatherAlpha += thunderStrength;
87-
}
88-
89-
return Mth.clamp(weatherAlpha, 0.0F, 1.0F);
90-
}
91-
9270
// This method replicates the old Mojang-made Quaternion mulPose method, which was
9371
// used for the initial sky transformations which did not have any bobbing issues.
9472
// See https://github.com/sp614x/optifine/issues/7235#issuecomment-1581930719

0 commit comments

Comments
 (0)