mirror of
https://github.com/JonasunderscoreJones/nicer-skies.git
synced 2025-10-22 19:29:18 +02:00
add option to disable nebulas in custom dimensions
This commit is contained in:
parent
80ba8c2c9b
commit
9221b83681
7 changed files with 56 additions and 23 deletions
|
@ -14,14 +14,15 @@ import java.io.IOException;
|
|||
|
||||
public class Config {
|
||||
public static final ConfigData DEFAULT_CONFIG = new ConfigData(false,
|
||||
true,
|
||||
true,
|
||||
NebulaType.RAINBOW.getTypeString(),
|
||||
1f,
|
||||
0.5f,
|
||||
1f,
|
||||
128,
|
||||
false);
|
||||
true,
|
||||
true,
|
||||
1f,
|
||||
0.5f,
|
||||
1f,
|
||||
128,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
private static final Gson gson = new Gson();
|
||||
private final File file;
|
||||
|
@ -93,6 +94,10 @@ public class Config {
|
|||
return configData.getNebulaConfig().isRenderDuringDay();
|
||||
}
|
||||
|
||||
public boolean renderInOtherDimensions() {
|
||||
return configData.isNebulasInOtherDimensions();
|
||||
}
|
||||
|
||||
public void updateConfig(ConfigData configData) {
|
||||
this.configData = configData.toBuilder().build();
|
||||
this.configData.setNebulaConfig(configData.getNebulaConfig().toBuilder().build());
|
||||
|
@ -110,7 +115,7 @@ public class Config {
|
|||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Builder(toBuilder=true)
|
||||
@Builder(toBuilder = true)
|
||||
public final static class ConfigData {
|
||||
private boolean lightmapTweaked;
|
||||
private boolean twinklingStars;
|
||||
|
@ -119,19 +124,19 @@ public class Config {
|
|||
|
||||
private NebulaConfigData nebulaConfig;
|
||||
|
||||
private ConfigData(boolean tweakedLigthmap, boolean twinklingStars, boolean nebulas, String nebulaType, float nebulaStrength, float nebulaNoiseAmount, float nebulaNoiseScale, int baseColourAmount, boolean renderDuringDay) {
|
||||
private ConfigData(boolean tweakedLigthmap, boolean twinklingStars, boolean nebulas, float nebulaStrength, float nebulaNoiseAmount, float nebulaNoiseScale, int baseColourAmount, boolean renderDuringDay, boolean renderInOtherDimensions) {
|
||||
this.lightmapTweaked = tweakedLigthmap;
|
||||
this.twinklingStars = twinklingStars;
|
||||
this.renderNebulas = nebulas;
|
||||
this.nebulasInOtherDimensions = renderInOtherDimensions;
|
||||
|
||||
this.nebulaConfig = new NebulaConfigData(nebulaType, nebulaStrength, nebulaNoiseAmount, nebulaNoiseScale, baseColourAmount, renderDuringDay);
|
||||
this.nebulaConfig = new NebulaConfigData(nebulaStrength, nebulaNoiseAmount, nebulaNoiseScale, baseColourAmount, renderDuringDay);
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Builder(toBuilder=true)
|
||||
@Builder(toBuilder = true)
|
||||
public static final class NebulaConfigData {
|
||||
private String nebulaType;
|
||||
private float nebulaStrength;
|
||||
private float nebulaNoiseAmount;
|
||||
private float nebulaNoiseScale;
|
||||
|
|
|
@ -8,16 +8,13 @@ import codes.ztereohype.nicerskies.gui.widget.TooltippedCheckbox;
|
|||
import codes.ztereohype.nicerskies.gui.widget.TooltippedSliderButton;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.AbstractSliderButton;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.Checkbox;
|
||||
import net.minecraft.client.gui.components.Tooltip;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraft.network.chat.Style;
|
||||
|
||||
import javax.tools.Tool;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@ -50,6 +47,7 @@ public class ConfigScreen extends Screen {
|
|||
|
||||
// initial values
|
||||
boolean renderNebulas = newConfig.isRenderNebulas();
|
||||
boolean dimensionalNebulas = newConfig.isNebulasInOtherDimensions();
|
||||
boolean twinkleStars = newConfig.isTwinklingStars();
|
||||
boolean lightmapTweaked = newConfig.isLightmapTweaked();
|
||||
|
||||
|
@ -66,6 +64,17 @@ public class ConfigScreen extends Screen {
|
|||
invalidated = true;
|
||||
}, null));
|
||||
|
||||
addRenderableWidget(new TooltippedCheckbox(40, (Y += btnDst), 20, 20, Component.translatable("nicer_skies.option.dimensional_nebulas"), dimensionalNebulas, (selected) -> {
|
||||
newConfig.setNebulasInOtherDimensions(selected);
|
||||
invalidated = true;
|
||||
}, null) {
|
||||
@Override
|
||||
public void render(GuiGraphics g, int mouseX, int mouseY, float partialTick) {
|
||||
this.active = newConfig.isRenderNebulas();
|
||||
super.render(g, mouseX, mouseY, partialTick);
|
||||
}
|
||||
});
|
||||
|
||||
addRenderableWidget(new TooltippedCheckbox(20, (Y += btnDst), 20, 20, Component.translatable("nicer_skies.option.twinkle_stars"), twinkleStars, (selected) -> {
|
||||
newConfig.setTwinklingStars(selected);
|
||||
invalidated = true;
|
||||
|
@ -177,8 +186,8 @@ public class ConfigScreen extends Screen {
|
|||
g.drawCenteredString(this.font, Component.translatable("nicer_skies.menu.subtitle.nebula_settings"),
|
||||
3 * this.width / 4, 36, 16777215);
|
||||
|
||||
drawWrappedComponent(g, Component.translatable("nicer_skies.menu.compatibility_warning"), 20, 150,
|
||||
this.width / 2 - 40, 0xFFFF00);
|
||||
drawWrappedComponent(g, Component.translatable("nicer_skies.menu.compatibility_warning"), 20, 160,
|
||||
this.width / 2 - 40);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -198,14 +207,14 @@ public class ConfigScreen extends Screen {
|
|||
return newConfig.getNebulaConfig().equals(Config.DEFAULT_CONFIG.getNebulaConfig());
|
||||
}
|
||||
|
||||
private void drawWrappedComponent(GuiGraphics g, FormattedText component, int x, int y, int wrapWidth, int color) {
|
||||
private void drawWrappedComponent(GuiGraphics g, FormattedText component, int x, int y, int wrapWidth) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
List<FormattedText> lines = mc.font.getSplitter().splitLines(component, wrapWidth, Style.EMPTY);
|
||||
|
||||
int amount = lines.size();
|
||||
for (int i = 0; i < amount; i++) {
|
||||
FormattedText renderable = lines.get(i);
|
||||
g.drawString(font, renderable.getString(), x, y + i * 9, color);
|
||||
g.drawString(font, renderable.getString(), x, y + i * 9, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
package codes.ztereohype.nicerskies.gui.widget;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Checkbox;
|
||||
import net.minecraft.client.gui.components.Tooltip;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
@ -22,4 +27,10 @@ public class TooltippedCheckbox extends Checkbox {
|
|||
super.onPress();
|
||||
onPress.accept(this.selected());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) {
|
||||
this.setAlpha(this.active ? 1.0F : 0.5F);
|
||||
super.renderWidget(guiGraphics, i, j, f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.mojang.blaze3d.vertex.BufferBuilder;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexBuffer;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
|
@ -31,6 +32,9 @@ public abstract class LevelRendererMixin {
|
|||
@Shadow
|
||||
private ClientLevel level;
|
||||
|
||||
@Shadow
|
||||
private Minecraft minecraft;
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "createStars", cancellable = true)
|
||||
private void generateStars(CallbackInfo ci) {
|
||||
Config config = NicerSkies.getInstance().getConfig();
|
||||
|
@ -73,6 +77,8 @@ public abstract class LevelRendererMixin {
|
|||
Config config = NicerSkies.getInstance().getConfig();
|
||||
SkyManager skyManager = NicerSkies.getInstance().getSkyManager();
|
||||
|
||||
if (!config.renderInOtherDimensions() && minecraft.level.dimension() != ClientLevel.OVERWORLD) return;
|
||||
|
||||
if (!config.areNebulasEnabled() || skyManager.getSkybox() == null) return;
|
||||
|
||||
skyManager.getSkybox().render(poseStack, matrix4f);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"nicer_skies.menu.subtitle.feature_toggles": "Eigenschaften ein-/ausschalten",
|
||||
"nicer_skies.menu.subtitle.nebula_settings": "Nebel Einstellungen",
|
||||
|
||||
"nicer_skies.menu.compatibility_warning": "§lAchtung:§r \n\nUm Kompabilität mit anderen mods (wie z.B. Custom Stars) herzustellen, muss \"Twinkle Stars\" deaktiviert werden",
|
||||
"nicer_skies.menu.compatibility_warning": "§l§e§nAchtung:§r \nUm Kompabilität mit anderen mods (wie z.B. Custom Stars) herzustellen, muss \"Twinkle Stars\" deaktiviert werden",
|
||||
|
||||
"nicer_skies.option.render_nebulas": "Nebel Rendern",
|
||||
"nicer_skies.option.twinkle_stars": "Funkelnde Sterne",
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
"nicer_skies.menu.subtitle.feature_toggles": "Toggle Features",
|
||||
"nicer_skies.menu.subtitle.nebula_settings": "Nebula Settings",
|
||||
|
||||
"nicer_skies.menu.compatibility_warning": "§lNote:§r \n\nDisable \"Twinkle Stars\" for compatibility with other mods.\n(e.g. Custom Stars)",
|
||||
"nicer_skies.menu.compatibility_warning": "§l§eNote:§r \nDisable \"Twinkle Stars\" for compatibility with other mods.\n(e.g. Custom Stars)",
|
||||
|
||||
"nicer_skies.option.render_nebulas": "Render Nebulas",
|
||||
"nicer_skies.option.dimensional_nebulas": "In custom dimensions",
|
||||
"nicer_skies.option.twinkle_stars": "Twinkle Stars",
|
||||
"nicer_skies.option.custom_lightmap": "Customize Light Color",
|
||||
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
"nicer_skies.menu.subtitle.feature_toggles": "Attiva features",
|
||||
"nicer_skies.menu.subtitle.nebula_settings": "Impostazioni nebule",
|
||||
|
||||
"nicer_skies.menu.compatibility_warning": "§lNota:§r \n\nDisattiva \"Stelle Scintillanti\" per essere compatibile con altre mod. (e.g. Custom Stars)",
|
||||
"nicer_skies.menu.compatibility_warning": "§l§e§nNota:§r \nDisattiva \"Stelle Scintillanti\" per essere compatibile con altre mod. (e.g. Custom Stars)",
|
||||
|
||||
"nicer_skies.option.render_nebulas": "Renderizza nebule",
|
||||
"nicer_skies.option.dimensional_nebulas": "In dimensioni custom",
|
||||
"nicer_skies.option.twinkle_stars": "Stelle scintillanti",
|
||||
"nicer_skies.option.custom_lightmap": "Luce saturata",
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue