Updated everything

This commit is contained in:
coolGi2007
2022-01-07 07:15:29 +00:00
parent 4da96d094e
commit ae820320de
20 changed files with 426 additions and 212 deletions
@@ -20,7 +20,6 @@
package com.seibel.lod.common;
import com.seibel.lod.common.wrappers.config.ConfigGui;
import com.seibel.lod.common.wrappers.world.DimensionTypeWrapper;
import com.seibel.lod.core.config.*;
import com.seibel.lod.core.enums.config.*;
import com.seibel.lod.core.enums.rendering.*;
@@ -57,8 +56,11 @@ public class Config extends ConfigGui
@ConfigAnnotations.ScreenEntry
public static Client client;
// I know this option should be in Client
// This is a hacky method to not show the button in the options screen but show it in the mod menu
// Tough it is in client in the wrapper singleton
@ConfigAnnotations.Entry
public static boolean ShowButton = true;
public static boolean optionsButton = true;
public static class Client
{
@@ -101,7 +103,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;
}
@@ -0,0 +1,22 @@
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(){
}
}
@@ -3,7 +3,7 @@ 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.WorldgenRandom;
import net.minecraft.world.level.levelgen.LegacyRandomSource;
import net.minecraft.world.level.levelgen.synth.SimplexNoise;
import java.util.*;
@@ -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()));
// 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);
}
@@ -27,7 +27,7 @@ public final class NoiseCloudHandler {
timeIdx = update;
for (CloudTexture cloudTexture : cloudTextures) {
if (cloudTexture.cloudsTexture.getPixels() != null) {
cloudTexture.updateImage(time);
cloudTexture.updateImage();
}
}
}
@@ -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 < image.getWidth(); x++) {
for (int z = 0; z < image.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) & 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);
@@ -36,7 +69,7 @@ public class SkyCoverGenerators {
}
}
public static void cloudySkyUpdate(Random random, SimplexNoise noiseSampler, NativeImage image, List<CloudTexture.PixelCoordinate> pixels, double cloudiness) {
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++) {
@@ -65,4 +98,5 @@ public class SkyCoverGenerators {
}
return false;
}
*/
}
@@ -60,7 +60,7 @@ import net.minecraft.client.gui.narration.NarratableEntry; // Remove in 1.16
* Credits to Motschen
*
* @author coolGi2007
* @version 12-28-2021
* @version 1-6-2022
*/
@SuppressWarnings("unchecked")
public abstract class ConfigGui
@@ -68,6 +68,7 @@ public abstract class ConfigGui
/*
TODO list
Fix floats not working
Make a wiki
Make it so you can enable and disable buttons from showing
Make min and max not final
@@ -85,6 +86,7 @@ public abstract class ConfigGui
private static final Pattern DECIMAL_ONLY_REGEX = Pattern.compile("-?([\\d]+\\.?[\\d]*|[\\d]*\\.?[\\d]+|\\.)");
private static final List<EntryInfo> entries = new ArrayList<>();
public static final Map<String,EntryInfo> entryMap = new HashMap<>();
// Change these to your own mod
private static final String MOD_NAME = ModInfo.NAME; // For file saving and identifying
@@ -107,7 +109,7 @@ public abstract class ConfigGui
public static final int ResetButtonWidth = 40;
}
protected static class EntryInfo<T>
public static class EntryInfo<T>
{
Field field;
Object widget;
@@ -169,6 +171,7 @@ public abstract class ConfigGui
if (field.isAnnotationPresent(ConfigAnnotations.Entry.class))
{
entryMap.put((!category.isEmpty() ? category + "." : "") + field.getName(), info);
info.varClass = field.getType();
try
{
@@ -324,6 +327,7 @@ public abstract class ConfigGui
for (EntryInfo info : entries) {
if (info.field.isAnnotationPresent(ConfigAnnotations.Entry.class)) {
// editSingleOption.saveOption(info);
config.set((info.category.isEmpty() ? "" : info.category + ".") + info.field.getName(), info.value);
}
}
@@ -352,6 +356,7 @@ public abstract class ConfigGui
// Puts everything into its variable
for (EntryInfo info : entries) {
if (info.field.isAnnotationPresent(ConfigAnnotations.Entry.class)) {
// editSingleOption.loadOption(info);
String itemPath = (info.category.isEmpty() ? "" : info.category + ".") + info.field.getName();
if (config.contains(itemPath)) {
if (info.field.getType().isEnum())
@@ -363,13 +368,59 @@ public abstract class ConfigGui
try {
info.field.set(null, info.value);
} catch (IllegalAccessException ignored) {}
} catch (IllegalAccessException ignored) {
}
}
}
config.close();
}
public static class editSingleOption {
public static EntryInfo getEntry(String name) {
return entryMap.get(name);
}
public static void saveOption(String name) {
saveOption(entryMap.get(name));
}
public static void saveOption(EntryInfo info) {
CommentedFileConfig config = CommentedFileConfig.builder(configFilePath.toFile()).build();
config.load();
config.set((info.category.isEmpty() ? "" : info.category + ".") + info.field.getName(), info.value);
config.save();
config.close();
}
public static void loadOption(String name) {
loadOption(entryMap.get(name));
}
public static void loadOption(EntryInfo info) {
CommentedFileConfig config = CommentedFileConfig.builder(configFilePath.toFile()).autosave().build();
config.load();
String itemPath = (info.category.isEmpty() ? "" : info.category + ".") + info.field.getName();
if (config.contains(itemPath)) {
if (info.field.getType().isEnum())
info.value = config.getEnum(itemPath, info.varClass);
else
info.value = config.get(itemPath);
} else
config.set(itemPath, info.value);
try {
info.field.set(null, info.value);
} catch (IllegalAccessException ignored) {
}
config.close();
}
}
public static Screen getScreen(Screen parent, String category)
{
@@ -627,10 +678,10 @@ public abstract class ConfigGui
// Only for 1.17 and over
// Remove in 1.16 and below
@Override
public List<? extends NarratableEntry> narratables()
{
return children;
}
@Override
public List<? extends NarratableEntry> narratables()
{
return children;
}
}
}
@@ -50,6 +50,18 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
}
@Override
public boolean getOptionsButton()
{
return Config.optionsButton;
}
@Override
public void setOptionsButton(boolean newOptionsButton)
{
ConfigGui.editSingleOption.getEntry("optionsButton").value = newOptionsButton;
ConfigGui.editSingleOption.saveOption("optionsButton");
}
//================//
// Client Configs //
@@ -118,7 +130,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setDrawResolution(HorizontalResolution newHorizontalResolution)
{
Config.Client.Graphics.Quality.drawResolution = newHorizontalResolution;
ConfigGui.editSingleOption.getEntry("client.graphics.quality.drawResolution").value = newHorizontalResolution;
ConfigGui.editSingleOption.saveOption("client.graphics.quality.drawResolution");
}
@@ -130,7 +143,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setLodChunkRenderDistance(int newLodChunkRenderDistance)
{
Config.Client.Graphics.Quality.lodChunkRenderDistance = newLodChunkRenderDistance;
ConfigGui.editSingleOption.getEntry("client.graphics.quality.lodChunkRenderDistance").value = newLodChunkRenderDistance;
ConfigGui.editSingleOption.saveOption("client.graphics.quality.lodChunkRenderDistance");
}
@@ -142,7 +156,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setVerticalQuality(VerticalQuality newVerticalQuality)
{
Config.Client.Graphics.Quality.verticalQuality = newVerticalQuality;
ConfigGui.editSingleOption.getEntry("client.graphics.quality.verticalQuality").value = newVerticalQuality;
ConfigGui.editSingleOption.saveOption("client.graphics.quality.verticalQuality");
}
@@ -154,7 +169,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setHorizontalScale(int newHorizontalScale)
{
Config.Client.Graphics.Quality.horizontalScale = newHorizontalScale;
ConfigGui.editSingleOption.getEntry("client.graphics.quality.horizontalScale").value = newHorizontalScale;
ConfigGui.editSingleOption.saveOption("client.graphics.quality.horizontalScale");
}
@@ -166,7 +182,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setHorizontalQuality(HorizontalQuality newHorizontalQuality)
{
Config.Client.Graphics.Quality.horizontalQuality = newHorizontalQuality;
ConfigGui.editSingleOption.getEntry("client.graphics.quality.horizontalQuality").value = newHorizontalQuality;
ConfigGui.editSingleOption.saveOption("client.graphics.quality.horizontalQuality");
}
}
@@ -181,7 +198,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setFogDistance(FogDistance newFogDistance)
{
Config.Client.Graphics.FogQuality.fogDistance = newFogDistance;
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.fogDistance").value = newFogDistance;
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.fogDistance");
}
@@ -194,7 +212,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setFogDrawMode(FogDrawMode setFogDrawMode)
{
Config.Client.Graphics.FogQuality.fogDrawMode = setFogDrawMode;
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.fogDrawMode").value = setFogDrawMode;
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.fogDrawMode");
}
@@ -207,7 +226,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setFogColorMode(FogColorMode newFogColorMode)
{
Config.Client.Graphics.FogQuality.fogColorMode = newFogColorMode;
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.fogColorMode").value = newFogColorMode;
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.fogColorMode");
}
@@ -219,7 +239,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setDisableVanillaFog(boolean newDisableVanillaFog)
{
Config.Client.Graphics.FogQuality.disableVanillaFog = newDisableVanillaFog;
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.disableVanillaFog").value = newDisableVanillaFog;
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.disableVanillaFog");
}
}
@@ -234,7 +255,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setCustomClouds(boolean newCustomClouds)
{
Config.Client.Graphics.CloudQuality.customClouds = newCustomClouds;
ConfigGui.editSingleOption.getEntry("client.graphics.cloudQuality.customClouds").value = newCustomClouds;
ConfigGui.editSingleOption.saveOption("client.graphics.cloudQuality.customClouds");
}
@@ -246,7 +268,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setFabulousClouds(boolean newFabulousClouds)
{
Config.Client.Graphics.CloudQuality.fabulousClouds = newFabulousClouds;
ConfigGui.editSingleOption.getEntry("client.graphics.cloudQuality.fabulousClouds").value = newFabulousClouds;
ConfigGui.editSingleOption.saveOption("client.graphics.cloudQuality.fabulousClouds");
}
@@ -258,7 +281,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setExtendClouds(boolean newExtendClouds)
{
Config.Client.Graphics.CloudQuality.extendClouds = newExtendClouds;
ConfigGui.editSingleOption.getEntry("client.graphics.cloudQuality.extendClouds").value = newExtendClouds;
ConfigGui.editSingleOption.saveOption("client.graphics.cloudQuality.extendClouds");
}
@@ -270,7 +294,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setCloudHeight(double newCloudHeight)
{
Config.Client.Graphics.CloudQuality.cloudHeight = newCloudHeight;
ConfigGui.editSingleOption.getEntry("client.graphics.cloudQuality.cloudHeight").value = newCloudHeight;
ConfigGui.editSingleOption.saveOption("client.graphics.cloudQuality.cloudHeight");
}
}
@@ -285,7 +310,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setDisableDirectionalCulling(boolean newDisableDirectionalCulling)
{
Config.Client.Graphics.AdvancedGraphics.disableDirectionalCulling = newDisableDirectionalCulling;
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.disableDirectionalCulling").value = newDisableDirectionalCulling;
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.disableDirectionalCulling");
}
@@ -297,7 +323,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setAlwaysDrawAtMaxQuality(boolean newAlwaysDrawAtMaxQuality)
{
Config.Client.Graphics.AdvancedGraphics.alwaysDrawAtMaxQuality = newAlwaysDrawAtMaxQuality;
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.alwaysDrawAtMaxQuality").value = newAlwaysDrawAtMaxQuality;
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.alwaysDrawAtMaxQuality");
}
@@ -309,7 +336,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setVanillaOverdraw(VanillaOverdraw newVanillaOverdraw)
{
Config.Client.Graphics.AdvancedGraphics.vanillaOverdraw = newVanillaOverdraw;
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.vanillaOverdraw").value = newVanillaOverdraw;
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.vanillaOverdraw");
}
@Override
@@ -318,9 +346,10 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
return Config.Client.Graphics.AdvancedGraphics.backsideCullingRange;
}
@Override
public void setBacksideCullingRange(int backsideCullingRange)
public void setBacksideCullingRange(int newBacksideCullingRange)
{
Config.Client.Graphics.AdvancedGraphics.backsideCullingRange = backsideCullingRange;
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.backsideCullingRange").value = newBacksideCullingRange;
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.backsideCullingRange");
}
@Override
@@ -331,7 +360,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setUseExtendedNearClipPlane(boolean newUseExtendedNearClipPlane)
{
Config.Client.Graphics.AdvancedGraphics.useExtendedNearClipPlane = newUseExtendedNearClipPlane;
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.useExtendedNearClipPlane").value = newUseExtendedNearClipPlane;
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.useExtendedNearClipPlane");
}
}
}
@@ -352,7 +382,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setGenerationPriority(GenerationPriority newGenerationPriority)
{
Config.Client.WorldGenerator.generationPriority = newGenerationPriority;
ConfigGui.editSingleOption.getEntry("client.worldGenerator.generationPriority").value = newGenerationPriority;
ConfigGui.editSingleOption.saveOption("client.worldGenerator.generationPriority");
}
@@ -364,7 +395,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setDistanceGenerationMode(DistanceGenerationMode newDistanceGenerationMode)
{
Config.Client.WorldGenerator.distanceGenerationMode = newDistanceGenerationMode;
ConfigGui.editSingleOption.getEntry("client.worldGenerator.distanceGenerationMode").value = newDistanceGenerationMode;
ConfigGui.editSingleOption.saveOption("client.worldGenerator.distanceGenerationMode");
}
@@ -376,7 +408,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setAllowUnstableFeatureGeneration(boolean newAllowUnstableFeatureGeneration)
{
Config.Client.WorldGenerator.allowUnstableFeatureGeneration = newAllowUnstableFeatureGeneration;
ConfigGui.editSingleOption.getEntry("client.worldGenerator.allowUnstableFeatureGeneration").value = newAllowUnstableFeatureGeneration;
ConfigGui.editSingleOption.saveOption("client.worldGenerator.allowUnstableFeatureGeneration");
}
@@ -388,7 +421,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setBlockToAvoid(BlocksToAvoid newBlockToAvoid)
{
Config.Client.WorldGenerator.blocksToAvoid = newBlockToAvoid;
ConfigGui.editSingleOption.getEntry("client.worldGenerator.blocksToAvoid").value = newBlockToAvoid;
ConfigGui.editSingleOption.saveOption("client.worldGenerator.blocksToAvoid");
}
}
@@ -443,7 +477,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setNumberOfWorldGenerationThreads(int newNumberOfWorldGenerationThreads)
{
Config.Client.Advanced.Threading.numberOfWorldGenerationThreads = newNumberOfWorldGenerationThreads;
ConfigGui.editSingleOption.getEntry("client.advanced.threading.numberOfWorldGenerationThreads").value = newNumberOfWorldGenerationThreads;
ConfigGui.editSingleOption.saveOption("client.advanced.threading.numberOfWorldGenerationThreads");
}
@@ -455,7 +490,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setNumberOfBufferBuilderThreads(int newNumberOfWorldBuilderThreads)
{
Config.Client.Advanced.Threading.numberOfBufferBuilderThreads = newNumberOfWorldBuilderThreads;
ConfigGui.editSingleOption.getEntry("client.advanced.threading.numberOfBufferBuilderThreads").value = newNumberOfWorldBuilderThreads;
ConfigGui.editSingleOption.saveOption("client.advanced.threading.numberOfBufferBuilderThreads");
}
}
@@ -475,7 +511,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setDrawLods(boolean newDrawLods)
{
Config.Client.Advanced.Debugging.drawLods = newDrawLods;
ConfigGui.editSingleOption.getEntry("client.advanced.debugging.drawLods").value = newDrawLods;
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.drawLods");
}
@@ -487,7 +524,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setDebugMode(DebugMode newDebugMode)
{
Config.Client.Advanced.Debugging.debugMode = newDebugMode;
ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugMode").value = newDebugMode;
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugMode");
}
@@ -499,7 +537,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setDebugKeybindingsEnabled(boolean newEnableDebugKeybindings)
{
Config.Client.Advanced.Debugging.enableDebugKeybindings = newEnableDebugKeybindings;
ConfigGui.editSingleOption.getEntry("client.advanced.debugging.enableDebugKeybindings").value = newEnableDebugKeybindings;
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.enableDebugKeybindings");
}
}
@@ -515,7 +554,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setGpuUploadMethod(GpuUploadMethod newDisableVanillaFog)
{
Config.Client.Advanced.Buffers.gpuUploadMethod = newDisableVanillaFog;
ConfigGui.editSingleOption.getEntry("client.advanced.buffers.gpuUploadMethod").value = newDisableVanillaFog;
ConfigGui.editSingleOption.saveOption("client.advanced.buffers.gpuUploadMethod");
}
@@ -526,7 +566,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
}
@Override
public void setGpuUploadPerMegabyteInMilliseconds(int newMilliseconds) {
Config.Client.Advanced.Buffers.gpuUploadPerMegabyteInMilliseconds = newMilliseconds;
ConfigGui.editSingleOption.getEntry("client.advanced.buffers.gpuUploadPerMegabyteInMilliseconds").value = newMilliseconds;
ConfigGui.editSingleOption.saveOption("client.advanced.buffers.gpuUploadPerMegabyteInMilliseconds");
}
@@ -538,7 +579,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public void setRebuildTimes(BufferRebuildTimes newBufferRebuildTimes)
{
Config.Client.Advanced.Buffers.rebuildTimes = newBufferRebuildTimes;
ConfigGui.editSingleOption.getEntry("client.advanced.buffers.newBufferRebuildTimes").value = newBufferRebuildTimes;
ConfigGui.editSingleOption.saveOption("client.advanced.buffers.newBufferRebuildTimes");
}
}
}
+1 -1
Submodule core updated: 219ad9c45a...5ac51dd2a5
@@ -19,20 +19,28 @@
package com.seibel.lod.fabric;
import com.seibel.lod.common.Config;
import com.seibel.lod.core.api.ClientApi;
import com.seibel.lod.core.api.EventApi;
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
import com.seibel.lod.common.wrappers.world.DimensionTypeWrapper;
import com.seibel.lod.common.wrappers.world.WorldWrapper;
import com.seibel.lod.core.util.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.fabric.mixins.events.MixinClientLevel;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientChunkEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents;
import net.fabricmc.fabric.mixin.event.lifecycle.client.ClientChunkManagerMixin;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientChunkCache;
import net.minecraft.core.BlockPos;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.Level;
@@ -43,7 +51,7 @@ import org.lwjgl.glfw.GLFW;
/**
* This handles all events sent to the client,
* and is the starting point for most of the mod.
*
*
* @author coolGi2007
* @author Ran
* @version 11-23-2021
@@ -61,16 +69,19 @@ public class ClientProxy
// TODO: Fix this if it's wrong
/* World Events */
ServerTickEvents.START_SERVER_TICK.register(this::serverTickEvent);
//ServerTickEvents.START_SERVER_TICK.register(this::serverTickEvent);
ServerTickEvents.END_SERVER_TICK.register(this::serverTickEvent);
/* World Events */
ServerChunkEvents.CHUNK_LOAD.register(this::chunkLoadEvent);
//ServerChunkEvents.CHUNK_LOAD.register(this::chunkLoadEvent);
ClientChunkEvents.CHUNK_LOAD.register(this::chunkLoadEvent);
/* World Events */
ServerWorldEvents.LOAD.register((server, level) -> this.worldLoadEvent(level));
ServerWorldEvents.UNLOAD.register((server, level) -> this.worldUnloadEvent());
ServerWorldEvents.UNLOAD.register((server, level) -> this.worldUnloadEvent(level));
/* The Client World Events are in the mixins
Client world load event is in MixinClientLevel
Client world unload event is in MixinMinecraft */
@@ -106,9 +117,11 @@ public class ClientProxy
}
}
public void worldUnloadEvent()
public void worldUnloadEvent(Level level)
{
eventApi.worldUnloadEvent();
if (level != null) {
eventApi.worldUnloadEvent(WorldWrapper.getWorldWrapper(level));
}
}
/**
@@ -152,17 +165,17 @@ public class ClientProxy
boolean PreDebugToggle = false;
boolean PreDrawToggle = false;
public void onKeyInput() {
if (Config.Client.Advanced.Debugging.enableDebugKeybindings)
ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
if (CONFIG.client().advanced().debugging().getDebugKeybindingsEnabled())
{
// Only activates when you press the key
if (DebugToggle.isDown() && DebugToggle.isDown() != PreDebugToggle)
Config.Client.Advanced.Debugging.debugMode = Config.Client.Advanced.Debugging.debugMode.getNext();
CONFIG.client().advanced().debugging().setDebugMode(CONFIG.client().advanced().debugging().getDebugMode().getNext());
if (DrawToggle.isDown() && DrawToggle.isDown() != PreDebugToggle)
Config.Client.Advanced.Debugging.drawLods = !Config.Client.Advanced.Debugging.drawLods;
CONFIG.client().advanced().debugging().setDrawLods(!CONFIG.client().advanced().debugging().getDrawLods());
}
PreDebugToggle = DebugToggle.isDown();
PreDrawToggle = DrawToggle.isDown();
}
}
@@ -19,9 +19,7 @@
package com.seibel.lod.fabric;
import com.seibel.lod.common.Config;
import com.seibel.lod.common.LodCommonMain;
import com.seibel.lod.common.wrappers.config.ConfigGui;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.core.api.ClientApi;
import com.seibel.lod.fabric.wrappers.DependencySetup;
@@ -32,7 +30,7 @@ import net.fabricmc.api.ClientModInitializer;
* Initialize and setup the Mod. <br>
* If you are looking for the real start of the mod
* check out the ClientProxy.
*
*
* @author coolGi2007
* @author Ran
* @version 12-1-2021
@@ -52,7 +50,7 @@ public class Main implements ClientModInitializer
// no.
}
// This loads the mod after minecraft loads which doesn't causes a lot of issues (client sided)
// This loads the mod after minecraft loads which doesn't causes a lot of issues
public static void init() {
LodCommonMain.initConfig();
LodCommonMain.startup(null, false);
@@ -1,9 +1,10 @@
package com.seibel.lod.fabric.mixins;
import com.seibel.lod.common.Config;
import com.seibel.lod.common.wrappers.config.ConfigGui;
import com.seibel.lod.common.wrappers.config.TexturedButtonWidget;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.core.util.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import net.minecraft.client.gui.screens.OptionsScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
@@ -21,7 +22,7 @@ import java.util.Objects;
*
* @author coolGi2007
* @version 12-02-2021
*/
*/
@Mixin(OptionsScreen.class)
public class MixinOptionsScreen extends Screen {
// Get the texture for the button
@@ -32,20 +33,20 @@ public class MixinOptionsScreen extends Screen {
@Inject(at = @At("HEAD"),method = "init")
private void lodconfig$init(CallbackInfo ci) {
if (Config.ShowButton)
if (SingletonHandler.get(ILodConfigWrapperSingleton.class).client().getOptionsButton())
this.addRenderableWidget(new TexturedButtonWidget(
// Where the button is on the screen
this.width / 2 - 180, this.height / 6 - 12,
// Width and height of the button
20, 20,
// Offset
0, 0,
// Some textuary stuff
20, ICON_TEXTURE, 20, 40,
// Create the button and tell it where to go
// For now it goes to the client option by default
// Where the button is on the screen
this.width / 2 - 180, this.height / 6 - 12,
// Width and height of the button
20, 20,
// Offset
0, 0,
// Some textuary stuff
20, ICON_TEXTURE, 20, 40,
// Create the button and tell it where to go
// For now it goes to the client option by default
(buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(ConfigGui.getScreen(this, "client")),
// Add a title to the screen
new TranslatableComponent("text.autoconfig." + ModInfo.ID + ".title")));
// Add a title to the screen
new TranslatableComponent("text.autoconfig." + ModInfo.ID + ".title")));
}
}
@@ -21,10 +21,14 @@ package com.seibel.lod.fabric.mixins;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f;
import com.seibel.lod.common.Config;
import com.seibel.lod.common.clouds.CloudBufferSingleton;
import com.seibel.lod.common.clouds.CloudTexture;
import com.seibel.lod.common.clouds.NoiseCloudHandler;
import com.seibel.lod.common.wrappers.McObjectConverter;
import com.seibel.lod.common.wrappers.config.LodConfigWrapperSingleton;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.util.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import net.minecraft.client.renderer.LevelRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -51,6 +55,7 @@ import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.*;
import java.nio.FloatBuffer;
import java.util.Random;
/**
@@ -88,15 +93,17 @@ public class MixinWorldRenderer
}
@Inject(method = "renderClouds", at = @At("HEAD"), cancellable = true)
public void renderClouds(PoseStack poseStack, Matrix4f model, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) {
if (Config.Client.Graphics.CloudQuality.customClouds) {
public void renderClouds(PoseStack poseStack, Matrix4f projectionMatrix, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) {
ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
if (CONFIG.client().graphics().cloudQuality().getCustomClouds()) {
TextureManager textureManager = Minecraft.getInstance().getTextureManager();
registerClouds(textureManager);
NoiseCloudHandler.update();
// Only use when needed since it causes lag
// NoiseCloudHandler.update();
if (minecraft.level.dimension() == ClientLevel.OVERWORLD) {
CloudTexture cloudTexture = NoiseCloudHandler.cloudTextures.get(NoiseCloudHandler.cloudTextures.size() - 1);
renderCloudLayer(poseStack, model, tickDelta, cameraX, cameraY, cameraZ, (float) (Config.Client.Graphics.CloudQuality.cloudHeight + 0.01 /* Make clouds a bit higher so it dosnt do janky stuff */), 0, 1, 1, cloudTexture.resourceLocation);
renderCloudLayer(poseStack, projectionMatrix, tickDelta, cameraX, cameraY, cameraZ, (float) (CONFIG.client().graphics().cloudQuality().getCloudHeight() + 0.01 /* Make clouds a bit higher so it dosnt do janky stuff */), 1, 1, cloudTexture.resourceLocation);
}
ci.cancel();
@@ -149,7 +156,7 @@ public class MixinWorldRenderer
}
}
private void renderCloudLayer(PoseStack poseStack, Matrix4f model, float tickDelta, double cameraX, double cameraY, double cameraZ, float cloudHeight, float cloudOffset, float cloudScale, float speedMod, ResourceLocation resourceLocation) {
private void renderCloudLayer(PoseStack poseStack, Matrix4f projectionMatrix, float tickDelta, double cameraX, double cameraY, double cameraZ, float cloudHeight, float cloudScale, float speedMod, ResourceLocation resourceLocation) {
RenderSystem.disableCull();
RenderSystem.enableBlend();
RenderSystem.enableDepthTest();
@@ -158,7 +165,7 @@ public class MixinWorldRenderer
float scale = 12.0F * cloudScale;
double speed = ((this.ticks + tickDelta) * (0.03F * speedMod));
double posX = (cameraX + speed) / scale;
double posY = (cloudHeight - (float) cameraY + cloudOffset) / cloudScale;
double posY = (cloudHeight - (float) cameraY) / cloudScale;
double posZ = cameraZ / scale + 0.33000001311302185D;
posX -= Math.floor(posX / 2048.0D) * 2048;
posZ -= Math.floor(posZ / 2048.0D) * 2048;
@@ -179,6 +186,29 @@ public class MixinWorldRenderer
}
RenderSystem.setShader(GameRenderer::getPositionTexColorNormalShader);
//Setup custom projection matrix and override minecraft's.
//create needed objects
ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
FloatBuffer customBuffer = CloudBufferSingleton.INSTANCE.customBuffer;
FloatBuffer mcBuffer = CloudBufferSingleton.INSTANCE.mcBuffer;
//create clip values.
//far clip is our clip plane value
float farClip = (CONFIG.client().graphics().quality().getLodChunkRenderDistance() * LodUtil.CHUNK_WIDTH) * LodUtil.CHUNK_WIDTH / 2;
//near clip is mc clip plane value
float nearClip = 0.05f;
float matNearClip = -((farClip + nearClip) / (farClip - nearClip));
float matFarClip = -((2 * farClip * nearClip) / (farClip - nearClip));
//store ProjectionMatrix values to buffers
projectionMatrix.store(customBuffer);
projectionMatrix.store(mcBuffer);
//change values on our custom buffer
customBuffer.put(10, matNearClip);
customBuffer.put(14, matFarClip);
//load values from our buffer to the projection matrix
projectionMatrix.load(customBuffer);
if (this.generateClouds) {
this.generateClouds = false;
Tesselator tessellator = Tesselator.getInstance();
@@ -186,7 +216,7 @@ public class MixinWorldRenderer
if (this.cloudBuffer != null) this.cloudBuffer.close();
this.cloudBuffer = new VertexBuffer();
this.buildCloudLayer(bufferBuilder, posX, posY, posZ, cloudOffset, cloudScale, cloudColor);
this.buildCloudLayer(bufferBuilder, posX, posY, posZ, cloudScale, cloudColor);
bufferBuilder.end();
this.cloudBuffer.upload(bufferBuilder);
}
@@ -207,17 +237,18 @@ public class MixinWorldRenderer
}
ShaderInstance shader = RenderSystem.getShader();
this.cloudBuffer.drawWithShader(poseStack.last().pose(), model, shader);
this.cloudBuffer.drawWithShader(poseStack.last().pose(), projectionMatrix, shader);
}
}
//reset the projection matrix to original values
projectionMatrix.load(mcBuffer);
poseStack.popPose();
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.enableCull();
RenderSystem.disableBlend();
}
private void buildCloudLayer(BufferBuilder bufferBuilder, double cloudX, double cloudY, double cloudZ, float offset, float scale, Vec3 color) {
private void buildCloudLayer(BufferBuilder bufferBuilder, double cloudX, double cloudY, double cloudZ, float scale, Vec3 color) {
float lowpFracAccur = (float) Math.pow(2.0, -8);
float mediumpFracAccur = (float) Math.pow(2.0, -10);
float viewDistance = 8;
@@ -237,23 +268,27 @@ public class MixinWorldRenderer
float greenNS = greenTop * 0.8f;
float blueNS = blueTop * 0.8f;
bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
float adjustedCloudY = (float)Math.floor(cloudY / cloudThickness) * cloudThickness;
float adjustedCloudY = (float) Math.floor(cloudY / cloudThickness) * cloudThickness;
// Where the actual rendering happens
ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
if (this.prevCloudsType == CloudStatus.FANCY) {
int scaledViewDistance = (int) (((Config.Client.Graphics.CloudQuality.extendClouds ? Config.Client.Graphics.Quality.lodChunkRenderDistance : minecraft.options.renderDistance) / 2) / scale) / 2;
int scaledViewDistance = (int) (((CONFIG.client().graphics().cloudQuality().getExtendClouds() ? CONFIG.client().graphics().quality().getLodChunkRenderDistance() : minecraft.options.renderDistance) / 2) / scale) / 2;
for (int x = -scaledViewDistance - 1; x <= scaledViewDistance; ++x) {
for (int z = -scaledViewDistance - 1; z <= scaledViewDistance; ++z) {
int n3;
float scaledX = x * viewDistance;
float scaledZ = z * viewDistance;
if (adjustedCloudY > -5.0f) {
if (adjustedCloudY >= -4.0f) {
// Render cloud bottom
bufferBuilder.vertex(scaledX + 0.0f, adjustedCloudY + 0.0f, scaledZ + 8.0f).uv((scaledX + 0.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + 8.0f) * lowpFracAccur + adjustedCloudZ).color(redBottom, greenBottom, blueBottom, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
bufferBuilder.vertex(scaledX + 8.0f, adjustedCloudY + 0.0f, scaledZ + 8.0f).uv((scaledX + 8.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + 8.0f) * lowpFracAccur + adjustedCloudZ).color(redBottom, greenBottom, blueBottom, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
bufferBuilder.vertex(scaledX + 8.0f, adjustedCloudY + 0.0f, scaledZ + 0.0f).uv((scaledX + 8.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + 0.0f) * lowpFracAccur + adjustedCloudZ).color(redBottom, greenBottom, blueBottom, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
bufferBuilder.vertex(scaledX + 0.0f, adjustedCloudY + 0.0f, scaledZ + 0.0f).uv((scaledX + 0.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + 0.0f) * lowpFracAccur + adjustedCloudZ).color(redBottom, greenBottom, blueBottom, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
}
if (adjustedCloudY <= 5.0f) {
if (adjustedCloudY < 0.0f) {
// Render cloud top
bufferBuilder.vertex(scaledX + 0.0f, adjustedCloudY + cloudThickness - mediumpFracAccur, scaledZ + 8.0f).uv((scaledX + 0.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + 8.0f) * lowpFracAccur + adjustedCloudZ).color(redTop, greenTop, blueTop, 0.8f).normal(0.0f, 1.0f, 0.0f).endVertex();
bufferBuilder.vertex(scaledX + 8.0f, adjustedCloudY + cloudThickness - mediumpFracAccur, scaledZ + 8.0f).uv((scaledX + 8.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + 8.0f) * lowpFracAccur + adjustedCloudZ).color(redTop, greenTop, blueTop, 0.8f).normal(0.0f, 1.0f, 0.0f).endVertex();
bufferBuilder.vertex(scaledX + 8.0f, adjustedCloudY + cloudThickness - mediumpFracAccur, scaledZ + 0.0f).uv((scaledX + 8.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + 0.0f) * lowpFracAccur + adjustedCloudZ).color(redTop, greenTop, blueTop, 0.8f).normal(0.0f, 1.0f, 0.0f).endVertex();
@@ -267,7 +302,7 @@ public class MixinWorldRenderer
bufferBuilder.vertex(scaledX + (float)n3 + 0.0f, adjustedCloudY + 0.0f, scaledZ + 0.0f).uv((scaledX + (float)n3 + 0.5f) * lowpFracAccur + adjustedCloudX, (scaledZ + 0.0f) * lowpFracAccur + adjustedCloudZ).color(redEW, greenEW, blueEW, 0.8f).normal(-1.0f, 0.0f, 0.0f).endVertex();
}
}
if (x <= 1) {
if (x <= 0) { // FIX.ME is doing to big of an area
for (n3 = 0; n3 < 8; ++n3) {
bufferBuilder.vertex(scaledX + (float)n3 + 1.0f - mediumpFracAccur, adjustedCloudY + 0.0f, scaledZ + 8.0f).uv((scaledX + (float)n3 + 0.5f) * lowpFracAccur + adjustedCloudX, (scaledZ + 8.0f) * lowpFracAccur + adjustedCloudZ).color(redEW, greenEW, blueEW, 0.8f).normal(1.0f, 0.0f, 0.0f).endVertex();
bufferBuilder.vertex(scaledX + (float)n3 + 1.0f - mediumpFracAccur, adjustedCloudY + cloudThickness, scaledZ + 8.0f).uv((scaledX + (float)n3 + 0.5f) * lowpFracAccur + adjustedCloudX, (scaledZ + 8.0f) * lowpFracAccur + adjustedCloudZ).color(redEW, greenEW, blueEW, 0.8f).normal(1.0f, 0.0f, 0.0f).endVertex();
@@ -283,17 +318,18 @@ public class MixinWorldRenderer
bufferBuilder.vertex(scaledX + 0.0f, adjustedCloudY + 0.0f, scaledZ + (float)n3 + 0.0f).uv((scaledX + 0.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + (float)n3 + 0.5f) * lowpFracAccur + adjustedCloudZ).color(redNS, greenNS, blueNS, 0.8f).normal(0.0f, 0.0f, -1.0f).endVertex();
}
}
if (z > 1) continue;
for (n3 = 0; n3 < 8; ++n3) {
bufferBuilder.vertex(scaledX + 0.0f, adjustedCloudY + cloudThickness, scaledZ + (float)n3 + 1.0f - mediumpFracAccur).uv((scaledX + 0.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + (float)n3 + 0.5f) * lowpFracAccur + adjustedCloudZ).color(redNS, greenNS, blueNS, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
bufferBuilder.vertex(scaledX + 8.0f, adjustedCloudY + cloudThickness, scaledZ + (float)n3 + 1.0f - mediumpFracAccur).uv((scaledX + 8.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + (float)n3 + 0.5f) * lowpFracAccur + adjustedCloudZ).color(redNS, greenNS, blueNS, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
bufferBuilder.vertex(scaledX + 8.0f, adjustedCloudY + 0.0f, scaledZ + (float)n3 + 1.0f - mediumpFracAccur).uv((scaledX + 8.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + (float)n3 + 0.5f) * lowpFracAccur + adjustedCloudZ).color(redNS, greenNS, blueNS, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
bufferBuilder.vertex(scaledX + 0.0f, adjustedCloudY + 0.0f, scaledZ + (float)n3 + 1.0f - mediumpFracAccur).uv((scaledX + 0.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + (float)n3 + 0.5f) * lowpFracAccur + adjustedCloudZ).color(redNS, greenNS, blueNS, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
if (z < 1) { // FIX.ME is doing to big of an area
for (n3 = 0; n3 < 8; ++n3) {
bufferBuilder.vertex(scaledX + 0.0f, adjustedCloudY + cloudThickness, scaledZ + (float) n3 + 1.0f - mediumpFracAccur).uv((scaledX + 0.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + (float) n3 + 0.5f) * lowpFracAccur + adjustedCloudZ).color(redNS, greenNS, blueNS, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
bufferBuilder.vertex(scaledX + 8.0f, adjustedCloudY + cloudThickness, scaledZ + (float) n3 + 1.0f - mediumpFracAccur).uv((scaledX + 8.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + (float) n3 + 0.5f) * lowpFracAccur + adjustedCloudZ).color(redNS, greenNS, blueNS, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
bufferBuilder.vertex(scaledX + 8.0f, adjustedCloudY + 0.0f, scaledZ + (float) n3 + 1.0f - mediumpFracAccur).uv((scaledX + 8.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + (float) n3 + 0.5f) * lowpFracAccur + adjustedCloudZ).color(redNS, greenNS, blueNS, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
bufferBuilder.vertex(scaledX + 0.0f, adjustedCloudY + 0.0f, scaledZ + (float) n3 + 1.0f - mediumpFracAccur).uv((scaledX + 0.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + (float) n3 + 0.5f) * lowpFracAccur + adjustedCloudZ).color(redNS, greenNS, blueNS, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
}
}
}
}
} else {
int scaledRenderDistance = (int) ((Config.Client.Graphics.CloudQuality.extendClouds ? Config.Client.Graphics.Quality.lodChunkRenderDistance : minecraft.options.renderDistance) / scale);
int scaledRenderDistance = (int) ((CONFIG.client().graphics().cloudQuality().getExtendClouds() ? CONFIG.client().graphics().quality().getLodChunkRenderDistance() : minecraft.options.renderDistance) / scale);
for (int x = -scaledRenderDistance; x < scaledRenderDistance; x += scaledRenderDistance) {
for (int z = -scaledRenderDistance; z < scaledRenderDistance; z += scaledRenderDistance) {
@@ -4,6 +4,8 @@ import com.seibel.lod.fabric.Main;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.server.level.ServerLevel;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -21,11 +23,11 @@ public class MixinMinecraft {
@Inject(method = "setLevel", at = @At("HEAD"))
private void unloadWorldEvent_sL(ClientLevel clientLevel, CallbackInfo ci) {
if (level != null) Main.client_proxy.worldUnloadEvent();
if (level != null) Main.client_proxy.worldUnloadEvent(level);
}
@Inject(method = "clearLevel(Lnet/minecraft/client/gui/screens/Screen;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;updateScreenAndTick(Lnet/minecraft/client/gui/screens/Screen;)V", shift = At.Shift.AFTER))
@Inject(method = "clearLevel(Lnet/minecraft/client/gui/screens/Screen;)V", at = @At("HEAD"))
private void unloadWorldEvent_cL(Screen screen, CallbackInfo ci) {
if (this.level != null) Main.client_proxy.worldUnloadEvent();
if (this.level != null) Main.client_proxy.worldUnloadEvent(this.level);
}
}
@@ -1,8 +1,6 @@
package com.seibel.lod.fabric.wrappers.config;
import com.seibel.lod.common.wrappers.config.ConfigGui;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.common.Config;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import net.fabricmc.api.EnvType;
@@ -19,6 +17,6 @@ public class ModMenuIntegration implements ModMenuApi {
// For the custom config code
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> Config.getScreen(parent, "");
return parent -> ConfigGui.getScreen(parent, "");
}
}
@@ -35,34 +35,34 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
/**
* This handles all events sent to the client,
* and is the starting point for most of the mod.
*
*
* @author James_Seibel
* @version 11-12-2021
*/
public class ForgeClientProxy
{
private final EventApi eventApi = EventApi.INSTANCE;
@SubscribeEvent
public void serverTickEvent(TickEvent.ServerTickEvent event)
{
eventApi.serverTickEvent();
}
@SubscribeEvent
public void chunkLoadEvent(ChunkEvent.Load event)
{
eventApi.chunkLoadEvent(new ChunkWrapper(event.getChunk()), DimensionTypeWrapper.getDimensionTypeWrapper(event.getWorld().dimensionType()));
}
@SubscribeEvent
public void worldSaveEvent(WorldEvent.Save event)
{
eventApi.worldSaveEvent();
}
/** This is also called when a new dimension loads */
@SubscribeEvent
public void worldLoadEvent(WorldEvent.Load event)
@@ -71,13 +71,13 @@ public class ForgeClientProxy
eventApi.worldLoadEvent(WorldWrapper.getWorldWrapper(event.getWorld()));
}
}
@SubscribeEvent
public void worldUnloadEvent(WorldEvent.Unload event)
{
eventApi.worldUnloadEvent();
eventApi.worldUnloadEvent(WorldWrapper.getWorldWrapper(event.getWorld()));
}
@SubscribeEvent
public void blockChangeEvent(BlockEvent event)
{
@@ -90,18 +90,18 @@ public class ForgeClientProxy
{
IChunkWrapper chunk = new ChunkWrapper(event.getWorld().getChunk(event.getPos()));
DimensionTypeWrapper dimType = DimensionTypeWrapper.getDimensionTypeWrapper(event.getWorld().dimensionType());
// recreate the LOD where the blocks were changed
eventApi.blockChangeEvent(chunk, dimType);
}
}
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event)
{
eventApi.onKeyInput(event.getKey(), event.getAction());
}
}
@@ -19,7 +19,6 @@
package com.seibel.lod.forge;
import com.seibel.lod.common.Config;
import com.seibel.lod.common.LodCommonMain;
import com.seibel.lod.common.forge.LodForgeMethodCaller;
import com.seibel.lod.common.wrappers.config.ConfigGui;
@@ -33,17 +32,13 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.data.ModelDataMap;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLEnvironment;
import net.minecraftforge.fml.loading.FMLLoader;
import net.minecraftforge.fmlclient.ConfigGuiHandler;
import net.minecraftforge.fmlserverevents.FMLServerStartedEvent;
import java.util.List;
import java.util.Random;
@@ -52,7 +47,7 @@ import java.util.Random;
* Initialize and setup the Mod. <br>
* If you are looking for the real start of the mod
* check out the ClientProxy.
*
*
* @author James Seibel
* @version 11-21-2021
*/
@@ -60,7 +55,7 @@ import java.util.Random;
public class ForgeMain implements LodForgeMethodCaller
{
public static ForgeClientProxy forgeClientProxy;
private void init(final FMLCommonSetupEvent event)
{
// make sure the dependencies are set up before the mod needs them
@@ -68,33 +63,25 @@ public class ForgeMain implements LodForgeMethodCaller
LodCommonMain.startup(this, !FMLLoader.getDist().isClient());
ForgeDependencySetup.createInitialBindings();
}
public ForgeMain()
{
// Register the methods
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::init);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onClientStart);
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
}
private void onClientStart(final FMLClientSetupEvent event)
{
ModLoadingContext.get().registerExtensionPoint(ConfigGuiHandler.ConfigGuiFactory.class,
() -> new ConfigGuiHandler.ConfigGuiFactory((client, parent) -> Config.getScreen(parent, "")));
() -> new ConfigGuiHandler.ConfigGuiFactory((client, parent) -> ConfigGui.getScreen(parent, "")));
forgeClientProxy = new ForgeClientProxy();
MinecraftForge.EVENT_BUS.register(forgeClientProxy);
}
@SubscribeEvent
public void onServerStarting(FMLServerStartedEvent event)
{
// this is called when the server starts
}
private ModelDataMap dataMap = new ModelDataMap.Builder().build();
@Override
@@ -1,15 +1,8 @@
package com.seibel.lod.forge.mixins;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.mojang.blaze3d.systems.RenderSystem;
import com.seibel.lod.common.wrappers.minecraft.MinecraftRenderWrapper;
import com.seibel.lod.core.util.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import net.minecraft.client.Camera;
import net.minecraft.client.renderer.FogRenderer;
import net.minecraft.client.renderer.FogRenderer.FogMode;
@@ -17,6 +10,10 @@ import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.material.FogType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(FogRenderer.class)
public class MixinFogRenderer {
@@ -1,8 +1,10 @@
package com.seibel.lod.forge.mixins;
import com.seibel.lod.common.Config;
import com.seibel.lod.common.wrappers.config.ConfigGui;
import com.seibel.lod.common.wrappers.config.TexturedButtonWidget;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.core.util.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import net.minecraft.client.gui.screens.OptionsScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
@@ -31,20 +33,20 @@ public class MixinOptionsScreen extends Screen {
@Inject(at = @At("HEAD"),method = "init")
private void lodconfig$init(CallbackInfo ci) {
if (Config.ShowButton)
if (SingletonHandler.get(ILodConfigWrapperSingleton.class).client().getOptionsButton())
this.addRenderableWidget(new TexturedButtonWidget(
// Where the button is on the screen
this.width / 2 - 180, this.height / 6 - 12,
// Width and height of the button
20, 20,
// Offset
0, 0,
// Some textuary stuff
20, ICON_TEXTURE, 20, 40,
// Create the button and tell it where to go
// For now it goes to the client option by default
(buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(Config.getScreen(this, "client")),
// Add a title to the screen
new TranslatableComponent("text.autoconfig." + ModInfo.ID + ".title")));
// Where the button is on the screen
this.width / 2 - 180, this.height / 6 - 12,
// Width and height of the button
20, 20,
// Offset
0, 0,
// Some textuary stuff
20, ICON_TEXTURE, 20, 40,
// Create the button and tell it where to go
// For now it goes to the client option by default
(buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(ConfigGui.getScreen(this, "client")),
// Add a title to the screen
new TranslatableComponent("text.autoconfig." + ModInfo.ID + ".title")));
}
}
@@ -21,10 +21,14 @@ package com.seibel.lod.forge.mixins;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f;
import com.seibel.lod.common.Config;
import com.seibel.lod.common.clouds.CloudBufferSingleton;
import com.seibel.lod.common.clouds.CloudTexture;
import com.seibel.lod.common.clouds.NoiseCloudHandler;
import com.seibel.lod.common.wrappers.McObjectConverter;
import com.seibel.lod.common.wrappers.config.LodConfigWrapperSingleton;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.util.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import net.minecraft.client.renderer.LevelRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -51,6 +55,7 @@ import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.*;
import java.nio.FloatBuffer;
import java.util.Random;
/**
@@ -88,15 +93,17 @@ public class MixinWorldRenderer
}
@Inject(method = "renderClouds", at = @At("HEAD"), cancellable = true)
public void renderClouds(PoseStack poseStack, Matrix4f model, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) {
if (Config.Client.Graphics.CloudQuality.customClouds) {
public void renderClouds(PoseStack poseStack, Matrix4f projectionMatrix, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) {
ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
if (CONFIG.client().graphics().cloudQuality().getCustomClouds()) {
TextureManager textureManager = Minecraft.getInstance().getTextureManager();
registerClouds(textureManager);
NoiseCloudHandler.update();
// Only use when needed since it causes lag
// NoiseCloudHandler.update();
if (minecraft.level.dimension() == ClientLevel.OVERWORLD) {
CloudTexture cloudTexture = NoiseCloudHandler.cloudTextures.get(NoiseCloudHandler.cloudTextures.size() - 1);
renderCloudLayer(poseStack, model, tickDelta, cameraX, cameraY, cameraZ, (float) (Config.Client.Graphics.CloudQuality.cloudHeight + 0.01 /* Make clouds a bit higher so it dosnt do janky stuff */), 0, 1, 1, cloudTexture.resourceLocation);
renderCloudLayer(poseStack, projectionMatrix, tickDelta, cameraX, cameraY, cameraZ, (float) (CONFIG.client().graphics().cloudQuality().getCloudHeight() + 0.01 /* Make clouds a bit higher so it dosnt do janky stuff */), 1, 1, cloudTexture.resourceLocation);
}
ci.cancel();
@@ -149,7 +156,7 @@ public class MixinWorldRenderer
}
}
private void renderCloudLayer(PoseStack poseStack, Matrix4f model, float tickDelta, double cameraX, double cameraY, double cameraZ, float cloudHeight, float cloudOffset, float cloudScale, float speedMod, ResourceLocation resourceLocation) {
private void renderCloudLayer(PoseStack poseStack, Matrix4f projectionMatrix, float tickDelta, double cameraX, double cameraY, double cameraZ, float cloudHeight, float cloudScale, float speedMod, ResourceLocation resourceLocation) {
RenderSystem.disableCull();
RenderSystem.enableBlend();
RenderSystem.enableDepthTest();
@@ -158,7 +165,7 @@ public class MixinWorldRenderer
float scale = 12.0F * cloudScale;
double speed = ((this.ticks + tickDelta) * (0.03F * speedMod));
double posX = (cameraX + speed) / scale;
double posY = (cloudHeight - (float) cameraY + cloudOffset) / cloudScale;
double posY = (cloudHeight - (float) cameraY) / cloudScale;
double posZ = cameraZ / scale + 0.33000001311302185D;
posX -= Math.floor(posX / 2048.0D) * 2048;
posZ -= Math.floor(posZ / 2048.0D) * 2048;
@@ -179,6 +186,29 @@ public class MixinWorldRenderer
}
RenderSystem.setShader(GameRenderer::getPositionTexColorNormalShader);
//Setup custom projection matrix and override minecraft's.
//create needed objects
ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
FloatBuffer customBuffer = CloudBufferSingleton.INSTANCE.customBuffer;
FloatBuffer mcBuffer = CloudBufferSingleton.INSTANCE.mcBuffer;
//create clip values.
//far clip is our clip plane value
float farClip = (CONFIG.client().graphics().quality().getLodChunkRenderDistance() * LodUtil.CHUNK_WIDTH) * LodUtil.CHUNK_WIDTH / 2;
//near clip is mc clip plane value
float nearClip = 0.05f;
float matNearClip = -((farClip + nearClip) / (farClip - nearClip));
float matFarClip = -((2 * farClip * nearClip) / (farClip - nearClip));
//store ProjectionMatrix values to buffers
projectionMatrix.store(customBuffer);
projectionMatrix.store(mcBuffer);
//change values on our custom buffer
customBuffer.put(10, matNearClip);
customBuffer.put(14, matFarClip);
//load values from our buffer to the projection matrix
projectionMatrix.load(customBuffer);
if (this.generateClouds) {
this.generateClouds = false;
Tesselator tessellator = Tesselator.getInstance();
@@ -186,7 +216,7 @@ public class MixinWorldRenderer
if (this.cloudBuffer != null) this.cloudBuffer.close();
this.cloudBuffer = new VertexBuffer();
this.buildCloudLayer(bufferBuilder, posX, posY, posZ, cloudOffset, cloudScale, cloudColor);
this.buildCloudLayer(bufferBuilder, posX, posY, posZ, cloudScale, cloudColor);
bufferBuilder.end();
this.cloudBuffer.upload(bufferBuilder);
}
@@ -207,17 +237,18 @@ public class MixinWorldRenderer
}
ShaderInstance shader = RenderSystem.getShader();
this.cloudBuffer.drawWithShader(poseStack.last().pose(), model, shader);
this.cloudBuffer.drawWithShader(poseStack.last().pose(), projectionMatrix, shader);
}
}
//reset the projection matrix to original values
projectionMatrix.load(mcBuffer);
poseStack.popPose();
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.enableCull();
RenderSystem.disableBlend();
}
private void buildCloudLayer(BufferBuilder bufferBuilder, double cloudX, double cloudY, double cloudZ, float offset, float scale, Vec3 color) {
private void buildCloudLayer(BufferBuilder bufferBuilder, double cloudX, double cloudY, double cloudZ, float scale, Vec3 color) {
float lowpFracAccur = (float) Math.pow(2.0, -8);
float mediumpFracAccur = (float) Math.pow(2.0, -10);
float viewDistance = 8;
@@ -237,23 +268,27 @@ public class MixinWorldRenderer
float greenNS = greenTop * 0.8f;
float blueNS = blueTop * 0.8f;
bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
float adjustedCloudY = (float)Math.floor(cloudY / cloudThickness) * cloudThickness;
float adjustedCloudY = (float) Math.floor(cloudY / cloudThickness) * cloudThickness;
// Where the actual rendering happens
ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
if (this.prevCloudsType == CloudStatus.FANCY) {
int scaledViewDistance = (int) (((Config.Client.Graphics.CloudQuality.extendClouds ? Config.Client.Graphics.Quality.lodChunkRenderDistance : minecraft.options.renderDistance) / 2) / scale) / 2;
int scaledViewDistance = (int) (((CONFIG.client().graphics().cloudQuality().getExtendClouds() ? CONFIG.client().graphics().quality().getLodChunkRenderDistance() : minecraft.options.renderDistance) / 2) / scale) / 2;
for (int x = -scaledViewDistance - 1; x <= scaledViewDistance; ++x) {
for (int z = -scaledViewDistance - 1; z <= scaledViewDistance; ++z) {
int n3;
float scaledX = x * viewDistance;
float scaledZ = z * viewDistance;
if (adjustedCloudY > -5.0f) {
if (adjustedCloudY >= -4.0f) {
// Render cloud bottom
bufferBuilder.vertex(scaledX + 0.0f, adjustedCloudY + 0.0f, scaledZ + 8.0f).uv((scaledX + 0.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + 8.0f) * lowpFracAccur + adjustedCloudZ).color(redBottom, greenBottom, blueBottom, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
bufferBuilder.vertex(scaledX + 8.0f, adjustedCloudY + 0.0f, scaledZ + 8.0f).uv((scaledX + 8.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + 8.0f) * lowpFracAccur + adjustedCloudZ).color(redBottom, greenBottom, blueBottom, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
bufferBuilder.vertex(scaledX + 8.0f, adjustedCloudY + 0.0f, scaledZ + 0.0f).uv((scaledX + 8.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + 0.0f) * lowpFracAccur + adjustedCloudZ).color(redBottom, greenBottom, blueBottom, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
bufferBuilder.vertex(scaledX + 0.0f, adjustedCloudY + 0.0f, scaledZ + 0.0f).uv((scaledX + 0.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + 0.0f) * lowpFracAccur + adjustedCloudZ).color(redBottom, greenBottom, blueBottom, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
}
if (adjustedCloudY <= 5.0f) {
if (adjustedCloudY < 0.0f) {
// Render cloud top
bufferBuilder.vertex(scaledX + 0.0f, adjustedCloudY + cloudThickness - mediumpFracAccur, scaledZ + 8.0f).uv((scaledX + 0.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + 8.0f) * lowpFracAccur + adjustedCloudZ).color(redTop, greenTop, blueTop, 0.8f).normal(0.0f, 1.0f, 0.0f).endVertex();
bufferBuilder.vertex(scaledX + 8.0f, adjustedCloudY + cloudThickness - mediumpFracAccur, scaledZ + 8.0f).uv((scaledX + 8.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + 8.0f) * lowpFracAccur + adjustedCloudZ).color(redTop, greenTop, blueTop, 0.8f).normal(0.0f, 1.0f, 0.0f).endVertex();
bufferBuilder.vertex(scaledX + 8.0f, adjustedCloudY + cloudThickness - mediumpFracAccur, scaledZ + 0.0f).uv((scaledX + 8.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + 0.0f) * lowpFracAccur + adjustedCloudZ).color(redTop, greenTop, blueTop, 0.8f).normal(0.0f, 1.0f, 0.0f).endVertex();
@@ -267,7 +302,7 @@ public class MixinWorldRenderer
bufferBuilder.vertex(scaledX + (float)n3 + 0.0f, adjustedCloudY + 0.0f, scaledZ + 0.0f).uv((scaledX + (float)n3 + 0.5f) * lowpFracAccur + adjustedCloudX, (scaledZ + 0.0f) * lowpFracAccur + adjustedCloudZ).color(redEW, greenEW, blueEW, 0.8f).normal(-1.0f, 0.0f, 0.0f).endVertex();
}
}
if (x <= 1) {
if (x <= 0) { // FIX.ME is doing to big of an area
for (n3 = 0; n3 < 8; ++n3) {
bufferBuilder.vertex(scaledX + (float)n3 + 1.0f - mediumpFracAccur, adjustedCloudY + 0.0f, scaledZ + 8.0f).uv((scaledX + (float)n3 + 0.5f) * lowpFracAccur + adjustedCloudX, (scaledZ + 8.0f) * lowpFracAccur + adjustedCloudZ).color(redEW, greenEW, blueEW, 0.8f).normal(1.0f, 0.0f, 0.0f).endVertex();
bufferBuilder.vertex(scaledX + (float)n3 + 1.0f - mediumpFracAccur, adjustedCloudY + cloudThickness, scaledZ + 8.0f).uv((scaledX + (float)n3 + 0.5f) * lowpFracAccur + adjustedCloudX, (scaledZ + 8.0f) * lowpFracAccur + adjustedCloudZ).color(redEW, greenEW, blueEW, 0.8f).normal(1.0f, 0.0f, 0.0f).endVertex();
@@ -283,17 +318,18 @@ public class MixinWorldRenderer
bufferBuilder.vertex(scaledX + 0.0f, adjustedCloudY + 0.0f, scaledZ + (float)n3 + 0.0f).uv((scaledX + 0.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + (float)n3 + 0.5f) * lowpFracAccur + adjustedCloudZ).color(redNS, greenNS, blueNS, 0.8f).normal(0.0f, 0.0f, -1.0f).endVertex();
}
}
if (z > 1) continue;
for (n3 = 0; n3 < 8; ++n3) {
bufferBuilder.vertex(scaledX + 0.0f, adjustedCloudY + cloudThickness, scaledZ + (float)n3 + 1.0f - mediumpFracAccur).uv((scaledX + 0.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + (float)n3 + 0.5f) * lowpFracAccur + adjustedCloudZ).color(redNS, greenNS, blueNS, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
bufferBuilder.vertex(scaledX + 8.0f, adjustedCloudY + cloudThickness, scaledZ + (float)n3 + 1.0f - mediumpFracAccur).uv((scaledX + 8.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + (float)n3 + 0.5f) * lowpFracAccur + adjustedCloudZ).color(redNS, greenNS, blueNS, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
bufferBuilder.vertex(scaledX + 8.0f, adjustedCloudY + 0.0f, scaledZ + (float)n3 + 1.0f - mediumpFracAccur).uv((scaledX + 8.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + (float)n3 + 0.5f) * lowpFracAccur + adjustedCloudZ).color(redNS, greenNS, blueNS, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
bufferBuilder.vertex(scaledX + 0.0f, adjustedCloudY + 0.0f, scaledZ + (float)n3 + 1.0f - mediumpFracAccur).uv((scaledX + 0.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + (float)n3 + 0.5f) * lowpFracAccur + adjustedCloudZ).color(redNS, greenNS, blueNS, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
if (z < 1) { // FIX.ME is doing to big of an area
for (n3 = 0; n3 < 8; ++n3) {
bufferBuilder.vertex(scaledX + 0.0f, adjustedCloudY + cloudThickness, scaledZ + (float) n3 + 1.0f - mediumpFracAccur).uv((scaledX + 0.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + (float) n3 + 0.5f) * lowpFracAccur + adjustedCloudZ).color(redNS, greenNS, blueNS, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
bufferBuilder.vertex(scaledX + 8.0f, adjustedCloudY + cloudThickness, scaledZ + (float) n3 + 1.0f - mediumpFracAccur).uv((scaledX + 8.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + (float) n3 + 0.5f) * lowpFracAccur + adjustedCloudZ).color(redNS, greenNS, blueNS, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
bufferBuilder.vertex(scaledX + 8.0f, adjustedCloudY + 0.0f, scaledZ + (float) n3 + 1.0f - mediumpFracAccur).uv((scaledX + 8.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + (float) n3 + 0.5f) * lowpFracAccur + adjustedCloudZ).color(redNS, greenNS, blueNS, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
bufferBuilder.vertex(scaledX + 0.0f, adjustedCloudY + 0.0f, scaledZ + (float) n3 + 1.0f - mediumpFracAccur).uv((scaledX + 0.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + (float) n3 + 0.5f) * lowpFracAccur + adjustedCloudZ).color(redNS, greenNS, blueNS, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
}
}
}
}
} else {
int scaledRenderDistance = (int) ((Config.Client.Graphics.CloudQuality.extendClouds ? Config.Client.Graphics.Quality.lodChunkRenderDistance : minecraft.options.renderDistance) / scale);
int scaledRenderDistance = (int) ((CONFIG.client().graphics().cloudQuality().getExtendClouds() ? CONFIG.client().graphics().quality().getLodChunkRenderDistance() : minecraft.options.renderDistance) / scale);
for (int x = -scaledRenderDistance; x < scaledRenderDistance; x += scaledRenderDistance) {
for (int z = -scaledRenderDistance; z < scaledRenderDistance; z += scaledRenderDistance) {
+3 -2
View File
@@ -2,12 +2,13 @@
"required": true,
"minVersion": "0.8",
"package": "com.seibel.lod.forge.mixins",
"compatibilityLevel": "JAVA_8",
"compatibilityLevel": "JAVA_16",
"mixins": [
],
"client": [
"MixinOptionsScreen",
"MixinWorldRenderer"
"MixinWorldRenderer",
"MixinFogRenderer"
],
"server": []
}