new: render during day and fix compelmentary reimagined

This commit is contained in:
ZtereoHYPE 2022-12-14 01:58:45 +01:00
parent e48d12819b
commit cd6a74609d
4 changed files with 31 additions and 13 deletions

View file

@ -4,12 +4,12 @@ import lombok.Data;
@Data
public class Config {
public Config(boolean tweakedLigthmap, boolean twinklingStars, boolean nebulas, String nebulaType, float nebulaStrength, float nebulaNoiseAmount, float nebulaNoiseScale, int baseColourAmount) {
public Config(boolean tweakedLigthmap, boolean twinklingStars, boolean nebulas, String nebulaType, float nebulaStrength, float nebulaNoiseAmount, float nebulaNoiseScale, int baseColourAmount, boolean renderDuringDay) {
this.tweakedLigthmap = tweakedLigthmap;
this.twinklingStars = twinklingStars;
this.nebulas = nebulas;
this.nebulaConfig = new NebulaConfig(nebulaType, nebulaStrength, nebulaNoiseAmount, nebulaNoiseScale, baseColourAmount);
this.nebulaConfig = new NebulaConfig(nebulaType, nebulaStrength, nebulaNoiseAmount, nebulaNoiseScale, baseColourAmount, renderDuringDay);
}
private boolean tweakedLigthmap;
@ -20,12 +20,13 @@ public class Config {
@Data
public static final class NebulaConfig {
public NebulaConfig(String nebulaType, float nebulaStrength, float nebulaNoiseAmount, float nebulaNoiseScale, int baseColourAmount) {
public NebulaConfig(String nebulaType, float nebulaStrength, float nebulaNoiseAmount, float nebulaNoiseScale, int baseColourAmount, boolean renderDuringDay) {
this.nebulaType = nebulaType;
this.nebulaStrength = nebulaStrength;
this.nebulaNoiseAmount = nebulaNoiseAmount;
this.nebulaNoiseScale = nebulaNoiseScale;
this.baseColourAmount = baseColourAmount;
this.renderDuringDay = renderDuringDay;
}
private String nebulaType;
@ -33,5 +34,6 @@ public class Config {
private float nebulaNoiseAmount;
private float nebulaNoiseScale;
private int baseColourAmount;
private boolean renderDuringDay;
}
}

View file

@ -8,7 +8,7 @@ import java.io.FileWriter;
import java.io.IOException;
public class ConfigManager {
public static final Config DEFAULT_CONFIG = new Config(false, true, true, NebulaType.RAINBOW.getTypeString(), 1f, 0.5f, 1f, 128);
public static final Config DEFAULT_CONFIG = new Config(false, true, true, NebulaType.RAINBOW.getTypeString(), 1f, 0.5f, 1f, 128, false);
private static final Gson gson = new Gson();
private final Config config;
@ -78,6 +78,10 @@ public class ConfigManager {
return config.getNebulaConfig().getBaseColourAmount();
}
public boolean getRenderDuringDay() {
return config.getNebulaConfig().isRenderDuringDay();
}
public void setLightmapTweaked(boolean tweaked) {
config.setTweakedLigthmap(tweaked);
save(file);
@ -117,6 +121,10 @@ public class ConfigManager {
config.getNebulaConfig().setBaseColourAmount(amount);
save(file);
}
public void setRenderDuringDay(boolean bl) {
config.getNebulaConfig().setRenderDuringDay(bl);
save(file);
}
public void save(File file) {
try (FileWriter writer = new FileWriter(file)) {

View file

@ -65,8 +65,16 @@ public class ConfigScreen extends Screen {
//
// addRenderableWidget(nebulaType);
addRenderableWidget(new Checkbox(this.width / 2 + (this.width / 2 - 150) / 2, 60, 20, 20, Component.literal("Render During Day"), cm.getRenderDuringDay()) {
@Override
public void onPress() {
super.onPress();
cm.setRenderDuringDay(!cm.getRenderDuringDay());
}
});
float strength = cm.getNebulaStrength();
addRenderableWidget(new AbstractSliderButton(this.width / 2 + (this.width / 2 - 150) / 2, 60, 150, 20, Component.literal("Nebula Strength: " + (int) (strength * 100) + "%"), strength) {
addRenderableWidget(new AbstractSliderButton(this.width / 2 + (this.width / 2 - 150) / 2, 84, 150, 20, Component.literal("Nebula Strength: " + (int) (strength * 100) + "%"), strength) {
@Override
protected void updateMessage() {
this.setMessage(Component.literal("Nebula Strength: " + (int) (this.value * 100) + "%"));
@ -79,7 +87,7 @@ public class ConfigScreen extends Screen {
});
float noiseAmount = cm.getNebulaNoiseAmount();
addRenderableWidget(new AbstractSliderButton(this.width / 2 + (this.width / 2 - 150) / 2, 84, 150, 20, Component.literal("Nebula Amount: " + (int) (noiseAmount * 100) + "%"), noiseAmount) {
addRenderableWidget(new AbstractSliderButton(this.width / 2 + (this.width / 2 - 150) / 2, 108, 150, 20, Component.literal("Nebula Amount: " + (int) (noiseAmount * 100) + "%"), noiseAmount) {
@Override
protected void updateMessage() {
invalidated = true;
@ -93,7 +101,7 @@ public class ConfigScreen extends Screen {
});
int baseColourAmount = cm.getNebulaBaseColourAmount();
addRenderableWidget(new AbstractSliderButton(this.width / 2 + (this.width / 2 - 150) / 2, 108, 150, 20, Component.literal("Background Strength: " + baseColourAmount), baseColourAmount / 255f) {
addRenderableWidget(new AbstractSliderButton(this.width / 2 + (this.width / 2 - 150) / 2, 132, 150, 20, Component.literal("Background Strength: " + baseColourAmount), baseColourAmount / 255f) {
@Override
protected void updateMessage() {
invalidated = true;
@ -107,7 +115,7 @@ public class ConfigScreen extends Screen {
});
float nebulaNoiseScale = cm.getNebulaNoiseScale();
addRenderableWidget(new AbstractSliderButton(this.width / 2 + (this.width / 2 - 150) / 2, 132, 150, 20, Component.literal("Nebula Scale: " + nebulaNoiseScale), Math.round((nebulaNoiseScale - 0.5f) / 1.5f * 100) / 100f) {
addRenderableWidget(new AbstractSliderButton(this.width / 2 + (this.width / 2 - 150) / 2, 156, 150, 20, Component.literal("Nebula Scale: " + nebulaNoiseScale), Math.round((nebulaNoiseScale - 0.5f) / 1.5f * 100) / 100f) {
@Override
protected void updateMessage() {
invalidated = true;
@ -125,7 +133,7 @@ public class ConfigScreen extends Screen {
});
//reload nebula button
addRenderableWidget(new Button(this.width / 2 + (this.width / 2 - 150) / 2, 156, 74, 20, Component.literal("Apply"), (button) -> {
addRenderableWidget(new Button(this.width / 2 + (this.width / 2 - 150) / 2, 180, 74, 20, Component.literal("Apply"), (button) -> {
NicerSkies.skyManager.generateSky(NebulaSeedManager.getSeed());
invalidated = false;
}, null) {
@ -137,7 +145,7 @@ public class ConfigScreen extends Screen {
});
//reset to default
addRenderableWidget(new Button(this.width / 2 + (this.width / 2 - 150) / 2 + 76, 156, 74, 20, Component.literal("Reset"), (button) -> {
addRenderableWidget(new Button(this.width / 2 + (this.width / 2 - 150) / 2 + 76, 180, 74, 20, Component.literal("Reset"), (button) -> {
cm.resetNebulaSettings();
this.clearWidgets();
this.init();

View file

@ -31,7 +31,7 @@ public class Skybox {
float alpha = getSkyboxBrightness(Minecraft.getInstance().level);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, alpha);
RenderSystem.setShaderColor(alpha, alpha, alpha, 1F);
this.skyboxBuffer.bind();
this.skyboxBuffer.drawWithShader(poseStack.last()
@ -164,8 +164,8 @@ public class Skybox {
float config = NicerSkies.config.getNebulaStrength();
float timeOfDay = level.getTimeOfDay(0);
float nightness = 1.0F - (Mth.cos(timeOfDay * (float) (Math.PI * 2)) * 4.0F + 0.5F);
nightness = Mth.clamp(nightness, 0.0F, 1.0F);
float nightness = 1F - (Mth.cos(timeOfDay * (float) (Math.PI * 2)) * 4.0F + 0.5F);
nightness = Mth.clamp(nightness, (NicerSkies.config.getRenderDuringDay() ? 1f : 0f), 1.0F);
float rain = level.getRainLevel(0);