Removed clouds

This commit is contained in:
coolGi2007
2022-02-05 09:41:53 +00:00
parent dda3c7636b
commit 213d70f2d1
9 changed files with 14 additions and 906 deletions
@@ -27,7 +27,6 @@ import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IAdvanced.*;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IGraphics.*;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IWorldGenerator;
import net.minecraft.client.renderer.DimensionSpecialEffects;
/**
* This handles any configuration the user has access to.
@@ -85,9 +84,6 @@ public class Config extends ConfigGui
@ConfigAnnotations.ScreenEntry
public static FogQuality fogQuality;
@ConfigAnnotations.ScreenEntry
public static CloudQuality cloudQuality;
@ConfigAnnotations.ScreenEntry
public static AdvancedGraphics advancedGraphics;
@@ -149,34 +145,7 @@ public class Config extends ConfigGui
public static boolean disableVanillaFog = IFogQuality.DISABLE_VANILLA_FOG_DEFAULT;
}
public static class CloudQuality
{
@ConfigAnnotations.Comment
public static ConfigAnnotations.Comment cloudWarning;
@ConfigAnnotations.FileComment
public static String _customClouds = ICloudQuality.CUSTOM_CLOUDS_DESC;
@ConfigAnnotations.Entry
public static boolean customClouds = ICloudQuality.CUSTOM_CLOUDS_DEFAULT;
@ConfigAnnotations.FileComment
public static String _coolClouds = ICloudQuality.COOL_CLOUDS_DESC;
@ConfigAnnotations.Entry
public static boolean coolClouds = ICloudQuality.COOL_CLOUDS_DEFAULT;
@ConfigAnnotations.FileComment
public static String _extendClouds = ICloudQuality.EXTEND_CLOUDS_DESC;
@ConfigAnnotations.Entry
public static boolean extendClouds = ICloudQuality.EXTEND_CLOUDS_DEFAULT;
@ConfigAnnotations.FileComment
public static String _cloudHeight = ICloudQuality.CLOUD_HEIGHT_DESC;
@ConfigAnnotations.Entry
public static double cloudHeight = DimensionSpecialEffects.OverworldEffects.CLOUD_LEVEL;
}
public static class AdvancedGraphics
{
@ConfigAnnotations.FileComment
@@ -1,22 +0,0 @@
package com.seibel.lod.common.clouds;
import org.lwjgl.system.MemoryUtil;
import java.nio.FloatBuffer;
//I'm not sure if there is a better place to put these, if there is feel free to move them.
/**
* This exists because creating a new Floatbuffer every tick to simply store floats seems to be a bad idea.
*/
public class CloudBufferSingleton
{
public static final CloudBufferSingleton INSTANCE = new CloudBufferSingleton();
public FloatBuffer customBuffer = MemoryUtil.memAllocFloat(16);
public FloatBuffer mcBuffer = MemoryUtil.memAllocFloat(16);
public CloudBufferSingleton(){
}
}
@@ -1,84 +0,0 @@
package com.seibel.lod.common.clouds;
import com.mojang.blaze3d.platform.NativeImage;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.levelgen.LegacyRandomSource;
import net.minecraft.world.level.levelgen.synth.SimplexNoise;
import java.util.*;
public class CloudTexture {
public List<PixelCoordinate> pixels = new LinkedList<PixelCoordinate>() {};
public SimplexNoise noise;
public DynamicTexture cloudsTexture;
public ResourceLocation resourceLocation;
public double cloudiness;
public CloudTexture(ResourceLocation resourceLocation) {
this.resourceLocation = resourceLocation;
}
public void updateImage() {
// Comment to not update the sky
// SkyCoverGenerators.cloudySkyUpdate(random, this.noise, this.cloudsTexture.getPixels(), pixels, this.cloudiness);
}
public void updatePixels() {
pixels.removeIf(pixel -> !fadePixel(Objects.requireNonNull(this.cloudsTexture.getPixels()), pixel.posX, pixel.posZ, pixel.fading));
this.cloudsTexture.upload();
}
public boolean fadePixel(NativeImage image, int x, int z, boolean fading) {
int color = image.getPixelRGBA(x, z);
int alpha = (color >> 24) & 0xFF;
//int alpha = image.getLuminanceOrAlpha(x, z) + 128;
if (fading) alpha -= 5;
else alpha += 5;
int newColor = alpha << 24 | 255 << 16 | 255 << 8 | 255;
//int newColor = NativeImage.combine(alpha, 255, 255, 255);
image.setPixelRGBA(x, z, newColor);
if (alpha <= 0) {
image.setPixelRGBA(x, z, 0);
return false;
} else return alpha < 255;
}
public void setTexture(DynamicTexture texture) {
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(SkyCoverGenerators.CLOUD_TEXTURE.getWidth(), SkyCoverGenerators.CLOUD_TEXTURE.getHeight(), false);
// Switch these out to clear sky
// Never comment both or something weird will happen
SkyCoverGenerators.normalSkyGenerator(image);
return new DynamicTexture(image);
}
public static class PixelCoordinate {
public int posX;
public int posZ;
public boolean fading;
public PixelCoordinate(int posX, int posZ, boolean fading) {
this.posX = posX;
this.posZ = posZ;
this.fading = fading;
}
}
}
@@ -1,56 +0,0 @@
package com.seibel.lod.common.clouds;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import java.util.LinkedList;
import java.util.List;
public final class NoiseCloudHandler {
public static List<CloudTexture> cloudTextures = new LinkedList<CloudTexture>() {};
private static long cloudIdx = -1;
private static long timeIdx = -1;
private static long lastTime = -1;
public static void update() {
Minecraft client = Minecraft.getInstance();
assert client.level != null;
long time = client.level.getGameTime();
if (time > lastTime) {
lastTime = time;
updateSkyCover(time);
long update = time / 600;
if (update > timeIdx) {
timeIdx = update;
for (CloudTexture cloudTexture : cloudTextures) {
if (cloudTexture.cloudsTexture.getPixels() != null) {
cloudTexture.updateImage();
}
}
}
for (CloudTexture cloudTexture : cloudTextures) {
if (cloudTexture.cloudsTexture.getPixels() != null) {
cloudTexture.updatePixels();
}
}
}
}
public static void updateSkyCover(long time) {
long idx = time / 12000;
if (idx > cloudIdx) {
cloudIdx = idx;
}
}
public static void initCloudTextures(ResourceLocation defaultCloud) {
CloudTexture defaultCloudTexture = new CloudTexture(defaultCloud);
cloudTextures.add(defaultCloudTexture);
}
}
@@ -1,102 +0,0 @@
package com.seibel.lod.common.clouds;
import com.mojang.blaze3d.platform.NativeImage;
import com.seibel.lod.core.ModInfo;
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/
/** Generates clear sky */
public static void clearSkyGenerator(NativeImage image) {
for (int x = 0; x < image.getWidth(); x++) {
for (int z = 0; z < image.getHeight(); z++) {
image.setPixelRGBA(x, z, 0);
}
}
}
/** 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) & 0x0000ff) > 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);
if (noiseSampler.getValue(x / 16.0, 0, z / 16.0) * 2.5 >= cloudiness || image.getPixelRGBA(x, z) != 0) {
if ((int) (noiseSampler.getValue(x / 16.0, 0, z / 16.0) * 2.5) != 0) {
image.setPixelRGBA(x, z, 0);
}
}
}
}
}
public static void noiseSkyUpdate(Random random, SimplexNoise noiseSampler, NativeImage image, List<CloudTexture.PixelCoordinate> pixels, double cloudiness) {
int count = random.nextInt(4000) + 4000;
for (int i = 0; i < count; i++) {
int x = random.nextInt(256);
int z = random.nextInt(256);
if (!updatingPixel(x, z, pixels)) {
if (noiseSampler.getValue(x / 16.0, 0, z / 16.0) * 2.5 < cloudiness && image.getPixelRGBA(x, z) == 0) {
if ((int) (noiseSampler.getValue(x / 16.0, 0, z / 16.0) * 2.5) != 0) {
pixels.add(new CloudTexture.PixelCoordinate(x, z, true));
} else {
pixels.add(new CloudTexture.PixelCoordinate(x, z, false));
}
} else {
pixels.add(new CloudTexture.PixelCoordinate(x, z, false));
}
}
}
}
public static boolean updatingPixel(int x, int z, List<CloudTexture.PixelCoordinate> pixels) {
for (CloudTexture.PixelCoordinate pixel : pixels) {
if (pixel.posX == x && pixel.posZ == z) {
return true;
}
}
return false;
}
*/
}
@@ -81,7 +81,6 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
{
public final IQuality quality;
public final IFogQuality fogQuality;
public final ICloudQuality cloudQuality;
public final IAdvancedGraphics advancedGraphics;
@@ -98,12 +97,6 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
return fogQuality;
}
@Override
public ICloudQuality cloudQuality()
{
return cloudQuality;
}
@Override
public IAdvancedGraphics advancedGraphics()
{
@@ -115,7 +108,6 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
{
quality = new Quality();
fogQuality = new FogQuality();
cloudQuality = new CloudQuality();
advancedGraphics = new AdvancedGraphics();
}
@@ -255,61 +247,6 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
}
public static class CloudQuality implements ICloudQuality
{
@Override
public boolean getCustomClouds()
{
return Config.Client.Graphics.CloudQuality.customClouds;
}
@Override
public void setCustomClouds(boolean newCustomClouds)
{
ConfigGui.editSingleOption.getEntry("client.graphics.cloudQuality.customClouds").value = newCustomClouds;
ConfigGui.editSingleOption.saveOption("client.graphics.cloudQuality.customClouds");
}
@Override
public boolean getCoolClouds()
{
return Config.Client.Graphics.CloudQuality.coolClouds;
}
@Override
public void setCoolClouds(boolean newCoolClouds)
{
ConfigGui.editSingleOption.getEntry("client.graphics.cloudQuality.coolClouds").value = newCoolClouds;
ConfigGui.editSingleOption.saveOption("client.graphics.cloudQuality.coolClouds");
}
@Override
public boolean getExtendClouds()
{
return Config.Client.Graphics.CloudQuality.extendClouds;
}
@Override
public void setExtendClouds(boolean newExtendClouds)
{
ConfigGui.editSingleOption.getEntry("client.graphics.cloudQuality.extendClouds").value = newExtendClouds;
ConfigGui.editSingleOption.saveOption("client.graphics.cloudQuality.extendClouds");
}
@Override
public double getCloudHeight()
{
return Config.Client.Graphics.CloudQuality.cloudHeight;
}
@Override
public void setCloudHeight(double newCloudHeight)
{
ConfigGui.editSingleOption.getEntry("client.graphics.cloudQuality.cloudHeight").value = newCloudHeight;
ConfigGui.editSingleOption.saveOption("client.graphics.cloudQuality.cloudHeight");
}
}
public static class AdvancedGraphics implements IAdvancedGraphics
{
@Override