mirror of
https://github.com/JonasunderscoreJones/nicer-skies.git
synced 2025-10-22 19:29:18 +02:00
cleanup: fixed logging errors, cleaned up comments and unused code
This commit is contained in:
parent
efe418e3bb
commit
7d45460af4
5 changed files with 17 additions and 42 deletions
|
@ -6,13 +6,18 @@ import net.fabricmc.api.ModInitializer;
|
|||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class NicerSkies implements ModInitializer {
|
||||
public static final Logger LOGGER = LogManager.getLogManager().getLogger("NicerSkies");
|
||||
|
||||
public static ConfigManager config = ConfigManager.fromFile(new File(FabricLoader.getInstance()
|
||||
.getConfigDir()
|
||||
.toFile(), "nicerskies.json"));
|
||||
public static SkyManager skyManager = new SkyManager();
|
||||
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
}
|
||||
|
|
|
@ -4,6 +4,12 @@ import lombok.Data;
|
|||
|
||||
@Data
|
||||
public class Config {
|
||||
private boolean tweakedLigthmap;
|
||||
private boolean twinklingStars;
|
||||
private boolean nebulas;
|
||||
|
||||
private final NebulaConfig nebulaConfig;
|
||||
|
||||
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;
|
||||
|
@ -12,12 +18,6 @@ public class Config {
|
|||
this.nebulaConfig = new NebulaConfig(nebulaType, nebulaStrength, nebulaNoiseAmount, nebulaNoiseScale, baseColourAmount, renderDuringDay);
|
||||
}
|
||||
|
||||
private boolean tweakedLigthmap;
|
||||
private boolean twinklingStars;
|
||||
private boolean nebulas;
|
||||
|
||||
private final NebulaConfig nebulaConfig;
|
||||
|
||||
@Data
|
||||
public static final class NebulaConfig {
|
||||
public NebulaConfig(String nebulaType, float nebulaStrength, float nebulaNoiseAmount, float nebulaNoiseScale, int baseColourAmount, boolean renderDuringDay) {
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package codes.ztereohype.nicerskies.config;
|
||||
|
||||
import codes.ztereohype.nicerskies.NicerSkies;
|
||||
import com.google.gson.Gson;
|
||||
import net.fabricmc.loader.impl.util.log.LogHandler;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.LogManager;
|
||||
|
||||
public class ConfigManager {
|
||||
public static final Config DEFAULT_CONFIG = new Config(false, true, true, NebulaType.RAINBOW.getTypeString(), 1f, 0.5f, 1f, 128, false);
|
||||
|
@ -32,7 +35,7 @@ public class ConfigManager {
|
|||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// todo setup logger properly
|
||||
NicerSkies.LOGGER.warning("Failed to read config file, falling back to default config");
|
||||
e.printStackTrace();
|
||||
config = cloneConfig(DEFAULT_CONFIG);
|
||||
}
|
||||
|
@ -129,11 +132,9 @@ public class ConfigManager {
|
|||
public void save(File file) {
|
||||
try (FileWriter writer = new FileWriter(file)) {
|
||||
writer.write(gson.toJson(config));
|
||||
// System.out.println("Saved config " + );
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
// todo setup logger properly
|
||||
// LogManager.getLogManager().getLogger("NicerSkies").warning("Failed to save config file!");
|
||||
NicerSkies.LOGGER.warning("Failed to save config file!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ public class SkyManager {
|
|||
|
||||
private final Gradient starGradient = new Gradient();
|
||||
private final Gradient nebulaGradient = new Gradient();
|
||||
// private final Gradient starryGradient = new Gradient();
|
||||
|
||||
public void generateSky(long seed) {
|
||||
ConfigManager cm = NicerSkies.config;
|
||||
|
@ -30,13 +29,11 @@ public class SkyManager {
|
|||
|
||||
buildGradients();
|
||||
|
||||
RandomSource randomSource = RandomSource.create(seed); //todo: world seed/hash server ip
|
||||
RandomSource randomSource = RandomSource.create(seed);
|
||||
|
||||
PerlinNoise perlinNoise = PerlinNoise.create(randomSource, IntStream.of(1, 2, 3, 4, 5));
|
||||
NebulaSkyboxPainter painter = new NebulaSkyboxPainter(perlinNoise, nebulaGradient, cm.getNebulaNoiseScale(), cm.getNebulaNoiseAmount(), cm.getNebulaBaseColourAmount());
|
||||
|
||||
// StarSkyboxPainter painter = new StarSkyboxPainter(perlinNoise, starryGradient);
|
||||
|
||||
this.starbox = new Starbox(randomSource, starGradient);
|
||||
this.skybox = new Skybox(painter);
|
||||
}
|
||||
|
@ -51,20 +48,10 @@ public class SkyManager {
|
|||
starGradient.add(0.2f, 255, 249, 253);
|
||||
starGradient.add(1.0f, 175, 199, 255);
|
||||
|
||||
// nebulaGradient.add(0.21f, 255, 0, 0);
|
||||
|
||||
nebulaGradient.add(0.2f, 41, 98, 146);
|
||||
// nebulaGradient.add(0.2f, 0, 0, 0);
|
||||
nebulaGradient.add(0.5f, 120, 59, 93);
|
||||
nebulaGradient.add(0.7f, 209, 72, 103);
|
||||
nebulaGradient.add(0.8f, 255, 200, 123);
|
||||
// nebulaGradient.add(1.0f, 30, 20, 20);
|
||||
nebulaGradient.add(1.0f, 253, 243, 220);
|
||||
|
||||
// starryGradient.add(0.0f, 128, 128, 200);
|
||||
// nebula_gradient.add(0.4f, 128, 0, 0);
|
||||
// nebula_gradient.add(0.5f, 128, 0, 0);
|
||||
// nebula_gradient.add(0.7f, 128, 0, 0);
|
||||
// nebula_gradient.add(1.0f, 128, 128, 128);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,28 +23,10 @@ public class StarSkyboxPainter extends SkyboxPainter {
|
|||
y = projCoords[1];
|
||||
z = projCoords[2];
|
||||
|
||||
// float offset = (float) noise.getValue(x * SCALING_FACTOR * 3, y * SCALING_FACTOR * 3, z * SCALING_FACTOR * 3);
|
||||
//
|
||||
// x += offset/10f;
|
||||
// y += offset/10f;
|
||||
// z += offset/10f;
|
||||
|
||||
// 0..1
|
||||
double noiseValue = Mth.clamp(noise.getValue(x * SCALING_FACTOR, y * SCALING_FACTOR, z * SCALING_FACTOR) + 0.5, 0D, 1D);
|
||||
|
||||
// 0..1
|
||||
// double subtractionValue = Mth.clamp(noise.getOctaveNoise(1).noise(x * SCALING_FACTOR, y * SCALING_FACTOR, z * SCALING_FACTOR) + 0.5, 0D, 1D);
|
||||
|
||||
// double[] derivates = new double[3];
|
||||
// noise.getOctaveNoise(0).noiseWithDerivative(x * SCALING_FACTOR, y * SCALING_FACTOR, z * SCALING_FACTOR, derivates);
|
||||
// double maxDerivative = Mth.clamp(Math.max(Math.max(derivates[0], derivates[1]), derivates[2]) * 0.5 + 0.5, 0, 0);
|
||||
|
||||
int alpha = (int) (Mth.clamp((noiseValue * (1D / BASE_NOISE_AMOUNT) - (1D / BASE_NOISE_AMOUNT - 1)) * 35D, 1D, 255.99D)); // otherwise death occurs
|
||||
|
||||
// alpha = (int) Mth.clamp(alpha - subtractionValue * 128, 0, 255); //todo subtract colour channels separately
|
||||
|
||||
double colourValue = Mth.clamp((alpha / 255D), 0D, 1D);
|
||||
|
||||
int[] color = starryGradient.getAt(colourValue);
|
||||
|
||||
return FastColor.ARGB32.color(alpha, color[2], color[1], color[0]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue