diff --git a/common/src/main/java/com/seibel/lod/common/Config.java b/common/src/main/java/com/seibel/lod/common/Config.java index cc613fc73..7451fb5b4 100644 --- a/common/src/main/java/com/seibel/lod/common/Config.java +++ b/common/src/main/java/com/seibel/lod/common/Config.java @@ -101,7 +101,6 @@ public class Config extends ConfigGui @ConfigAnnotations.Entry(minValue = 2, maxValue = 32) public static int horizontalScale = IQuality.HORIZONTAL_SCALE_MIN_DEFAULT_MAX.defaultValue; - //@ConfigAnnotations.Category("client.graphics.quality") @ConfigAnnotations.Entry public static HorizontalQuality horizontalQuality = IQuality.HORIZONTAL_QUALITY_DEFAULT; } diff --git a/common/src/main/java/com/seibel/lod/common/clouds/CloudTexture.java b/common/src/main/java/com/seibel/lod/common/clouds/CloudTexture.java index 0da3f309e..d66ca9045 100644 --- a/common/src/main/java/com/seibel/lod/common/clouds/CloudTexture.java +++ b/common/src/main/java/com/seibel/lod/common/clouds/CloudTexture.java @@ -22,12 +22,9 @@ public class CloudTexture { this.resourceLocation = resourceLocation; } - public void updateImage(long time) { - Random random = new Random(time); - - // Comment to clear sky - SkyCoverGenerators.cloudySkyUpdate(random, this.noise, this.cloudsTexture.getPixels(), pixels, this.cloudiness); - + public void updateImage() { + // Comment to not update the sky +// SkyCoverGenerators.cloudySkyUpdate(random, this.noise, this.cloudsTexture.getPixels(), pixels, this.cloudiness); } public void updatePixels() { @@ -58,22 +55,18 @@ public class CloudTexture { this.cloudsTexture = texture; } + /** Generates the noise at the start of the game */ public void initNoise(Random random) { // this.noise = new SimplexNoise(new WorldgenRandom(random.nextLong())); this.noise = new SimplexNoise(new LegacyRandomSource(random.nextLong())); } public DynamicTexture getNativeImage() { - NativeImage image = new NativeImage(256, 256, false); - - Random random = new Random(); - - this.cloudiness = random.nextDouble(); + NativeImage image = new NativeImage(SkyCoverGenerators.CLOUD_TEXTURE.getWidth(), SkyCoverGenerators.CLOUD_TEXTURE.getHeight(), false); // Switch these out to clear sky // Never comment both or something weird will happen -// SkyCoverGenerators.clearSkyGenerator(this.noise, image, this.cloudiness); - SkyCoverGenerators.cloudySkyGenerator(this.noise, image, this.cloudiness); + SkyCoverGenerators.normalSkyGenerator(image); return new DynamicTexture(image); } diff --git a/common/src/main/java/com/seibel/lod/common/clouds/NoiseCloudHandler.java b/common/src/main/java/com/seibel/lod/common/clouds/NoiseCloudHandler.java index 366373a11..bde85efc0 100644 --- a/common/src/main/java/com/seibel/lod/common/clouds/NoiseCloudHandler.java +++ b/common/src/main/java/com/seibel/lod/common/clouds/NoiseCloudHandler.java @@ -27,7 +27,7 @@ public final class NoiseCloudHandler { timeIdx = update; for (CloudTexture cloudTexture : cloudTextures) { if (cloudTexture.cloudsTexture.getPixels() != null) { - cloudTexture.updateImage(time); + cloudTexture.updateImage(); } } } diff --git a/common/src/main/java/com/seibel/lod/common/clouds/SkyCoverGenerators.java b/common/src/main/java/com/seibel/lod/common/clouds/SkyCoverGenerators.java index 712cade67..ac5b91103 100644 --- a/common/src/main/java/com/seibel/lod/common/clouds/SkyCoverGenerators.java +++ b/common/src/main/java/com/seibel/lod/common/clouds/SkyCoverGenerators.java @@ -1,29 +1,62 @@ package com.seibel.lod.common.clouds; import com.mojang.blaze3d.platform.NativeImage; -import net.minecraft.world.level.levelgen.synth.SimplexNoise; +import com.seibel.lod.core.ModInfo; -import java.util.List; -import java.util.Random; +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.*; public class SkyCoverGenerators { public static final int COLOR = NativeImage.combine(255, 255, 255, 255); + public static final BufferedImage CLOUD_TEXTURE = accessFile("/assets/lod/textures/environment/clouds_small.png"); // Where the generator for clouds could be made // TODO: Try to implement this https://www.reddit.com/r/Minecraft/comments/e7xol/this_is_how_clouds_should_work_gif_simulation/ - public static void clearSkyGenerator(SimplexNoise noiseSampler, NativeImage image, double cloudiness) { - for (int x = 0; x < 256; x++) { - for (int z = 0; z < 256; z++) { - if (noiseSampler.getValue(x / 16.0, 0, z / 16.0) * 2.5 < cloudiness || image.getPixelRGBA(x, z) != 0) { - image.setPixelRGBA(x, z, 0); - } + /** Generates clear sky */ + public static void clearSkyGenerator(NativeImage image) { + for (int x = 0; x < CLOUD_TEXTURE.getWidth(); x++) { + for (int z = 0; z < CLOUD_TEXTURE.getHeight(); z++) { + image.setPixelRGBA(x, z, 0); } } } - public static void cloudySkyGenerator(SimplexNoise noiseSampler, NativeImage image, double cloudiness) { + /** Generates the sky texture according to the texture */ + public static void normalSkyGenerator(NativeImage image) { + for (int x = 0; x < CLOUD_TEXTURE.getWidth(); x++) { + for (int z = 0; z < CLOUD_TEXTURE.getHeight(); z++) { + image.setPixelRGBA(x, z, ((CLOUD_TEXTURE.getRGB(x, z) & 0x000000ff) > 130 ? COLOR : 0)); + } + } + } + + /** Acsess an image file from the jar */ + public static BufferedImage accessFile(String resource) { + + // this is the path within the jar file + InputStream input = ModInfo.class.getResourceAsStream(resource); + if (input == null) { + // this is how we load file within editor (eg eclipse) + input = ModInfo.class.getClassLoader().getResourceAsStream(resource); + } + + // Turn it into an image + BufferedImage image; + try { + image = ImageIO.read(input); + } catch (Exception e) { + image = null; + } + + return image; + } + + // Old code + /* + public static void noiseSkyGenerator(SimplexNoise noiseSampler, NativeImage image, double cloudiness) { for (int x = 0; x < 256; x++) { for (int z = 0; z < 256; z++) { image.setPixelRGBA(x, z, COLOR); @@ -36,7 +69,7 @@ public class SkyCoverGenerators { } } - public static void cloudySkyUpdate(Random random, SimplexNoise noiseSampler, NativeImage image, List pixels, double cloudiness) { + public static void noiseSkyUpdate(Random random, SimplexNoise noiseSampler, NativeImage image, List pixels, double cloudiness) { int count = random.nextInt(4000) + 4000; for (int i = 0; i < count; i++) { @@ -65,4 +98,5 @@ public class SkyCoverGenerators { } return false; } + */ } diff --git a/core b/core index 3b475886e..44bcc5ae0 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 3b475886efa6e57255795baf8a32fb09ce5e9a15 +Subproject commit 44bcc5ae01f3e4d5382c11cc7f5e5063db12b23d