Updated everything

This commit is contained in:
coolGi2007
2022-01-07 18:03:31 +10:30
parent 49012a6996
commit 8a41734bce
18 changed files with 222 additions and 539 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;
}
@@ -1,92 +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.WorldgenRandom;
import net.minecraft.world.level.levelgen.synth.SimplexNoise;
import java.util.*;
import java.util.List;
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(long time) {
Random random = new Random(time);
// Comment to clear 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;
}
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();
// 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);
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(time);
}
}
}
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,68 +0,0 @@
package com.seibel.lod.common.clouds;
import com.mojang.blaze3d.platform.NativeImage;
import net.minecraft.world.level.levelgen.synth.SimplexNoise;
import java.util.List;
import java.util.Random;
public class SkyCoverGenerators {
public static final int COLOR = NativeImage.combine(255, 255, 255, 255);
// 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);
}
}
}
}
public static void cloudySkyGenerator(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 cloudySkyUpdate(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;
}
}
@@ -60,7 +60,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
* 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)
{
@@ -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.addButton(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")));
}
}
@@ -70,40 +70,9 @@ import java.util.Random;
@Mixin(LevelRenderer.class)
public class MixinWorldRenderer
{
// @Final @Shadow private static ResourceLocation CLOUDS_LOCATION;
// @Shadow private final int ticks;
// @Final @Shadow @NotNull private final Minecraft minecraft;
// @Shadow private int prevCloudX;
// @Shadow private int prevCloudY;
// @Shadow private int prevCloudZ;
// @Shadow @NotNull private Vec3 prevCloudColor;
// @Shadow @NotNull private CloudStatus prevCloudsType;
// @Shadow private boolean generateClouds;
// @Shadow @NotNull private VertexBuffer cloudBuffer;
// @Shadow @Final private VertexFormat format;
// @Unique private boolean initializedClouds = false;
// TODO: Fix clouds
private static float previousPartialTicks = 0;
// public MixinWorldRenderer() {
// throw new NullPointerException("Null cannot be cast to non-null type.");
// }
// @Inject(method = "renderClouds", at = @At("HEAD"), cancellable = true)
// public void renderClouds(PoseStack poseStack, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) {
// if (Config.Client.Graphics.CloudQuality.customClouds) {
// TextureManager textureManager = Minecraft.getInstance().getTextureManager();
// registerClouds(textureManager);
// NoiseCloudHandler.update();
//
// if (minecraft.level.dimension() == ClientLevel.OVERWORLD) {
// CloudTexture cloudTexture = NoiseCloudHandler.cloudTextures.get(NoiseCloudHandler.cloudTextures.size() - 1);
// renderCloudLayer(poseStack, 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);
// }
//
// ci.cancel();
// }
// }
@Inject(at = @At("RETURN"), method = "renderSky(Lcom/mojang/blaze3d/vertex/PoseStack;F)V")
private void renderSky(PoseStack matrixStackIn, float partialTicks, CallbackInfo callback)
@@ -134,195 +103,4 @@ public class MixinWorldRenderer
ClientApi.INSTANCE.renderLods(mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
}
}
/*
// TODO: Move these outside of the mixin
// When moved out then put credit to https://github.com/misterslime/fabulousclouds-fabric
private void registerClouds(TextureManager textureManager) {
if (!this.initializedClouds) {
Random random = new Random();
NoiseCloudHandler.initCloudTextures(CLOUDS_LOCATION);
for(CloudTexture cloudTexture : NoiseCloudHandler.cloudTextures) {
cloudTexture.initNoise(random);
DynamicTexture texture = cloudTexture.getNativeImage();
textureManager.register(cloudTexture.resourceLocation, texture);
cloudTexture.setTexture(texture);
}
this.initializedClouds = true;
}
}
private void renderCloudLayer(PoseStack poseStack, float tickDelta, double cameraX, double cameraY, double cameraZ, float cloudHeight, float cloudOffset, float cloudScale, float speedMod, ResourceLocation resourceLocation) {
RenderSystem.disableCull();
RenderSystem.enableBlend();
RenderSystem.enableDepthTest();
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.depthMask(true);
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 posZ = cameraZ / scale + 0.33000001311302185D;
posX -= Math.floor(posX / 2048.0D) * 2048;
posZ -= Math.floor(posZ / 2048.0D) * 2048;
float adjustedX = (float) (posX - (double) Math.floor(posX));
float adjustedY = (float) (posY / 4.0D - (double) Math.floor(posY / 4.0D)) * 4.0F;
float adjustedZ = (float) (posZ - (double) Math.floor(posZ));
Vec3 cloudColor = minecraft.level.getCloudColor(tickDelta);
int floorX = (int) Math.floor(posX);
int floorY = (int) Math.floor(posY / 4.0D);
int floorZ = (int) Math.floor(posZ);
if (floorX != this.prevCloudX || floorY != this.prevCloudY || floorZ != this.prevCloudZ || this.minecraft.options.getCloudsType() != this.prevCloudsType || this.prevCloudColor.distanceToSqr(cloudColor) > 2.0E-4D) {
this.prevCloudX = floorX;
this.prevCloudY = floorY;
this.prevCloudZ = floorZ;
this.prevCloudColor = cloudColor;
this.prevCloudsType = this.minecraft.options.getCloudsType();
this.generateClouds = true;
}
// RenderSystem.setShader(GameRenderer::getPositionTexColorNormalShader);
if (this.generateClouds) {
this.generateClouds = false;
Tesselator tessellator = Tesselator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuilder();
if (this.cloudBuffer != null) this.cloudBuffer.close();
this.cloudBuffer = new VertexBuffer(format);
this.buildCloudLayer(bufferBuilder, posX, posY, posZ, cloudOffset, cloudScale, cloudColor);
bufferBuilder.end();
this.cloudBuffer.upload(bufferBuilder);
}
// RenderSystem.setShaderTexture(0, resourceLocation);
RenderSystem.activeTexture(0);
FogRenderer.levelFogColor();
poseStack.pushPose();
poseStack.scale(scale, cloudScale, scale);
poseStack.translate(-adjustedX, adjustedY, -adjustedZ);
if (this.cloudBuffer != null) {
int cloudMainIndex = this.prevCloudsType == CloudStatus.FANCY ? 0 : 1;
for (int cloudIndex = 1; cloudMainIndex <= cloudIndex; ++cloudMainIndex) {
if (cloudMainIndex == 0) {
RenderSystem.colorMask(false, false, false, false);
} else {
RenderSystem.colorMask(true, true, true, true);
}
// ShaderInstance shader = RenderSystem.getShader();
// this.cloudBuffer.drawWithShader(poseStack.last().pose(), model, shader);
int shader = RenderSystem.maxSupportedTextureSize();
this.cloudBuffer.draw(poseStack.last().pose(), shader);
}
}
poseStack.popPose();
// RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.color4f(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) {
float lowpFracAccur = (float) Math.pow(2.0, -8);
float mediumpFracAccur = (float) Math.pow(2.0, -10);
float viewDistance = 8;
float cloudThickness = 4.0f;
float adjustedCloudX = (float)Math.floor(cloudX) * lowpFracAccur;
float adjustedCloudZ = (float)Math.floor(cloudZ) * lowpFracAccur;
float redTop = (float)color.x;
float greenTop = (float)color.y;
float blueTop = (float)color.z;
float redEW = redTop * 0.9f;
float greenEW = greenTop * 0.9f;
float blueEW = blueTop * 0.9f;
float redBottom = redTop * 0.7f;
float greenBottom = greenTop * 0.7f;
float blueBottom = blueTop * 0.7f;
float redNS = redTop * 0.8f;
float greenNS = greenTop * 0.8f;
float blueNS = blueTop * 0.8f;
bufferBuilder.begin(0, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
float adjustedCloudY = (float)Math.floor(cloudY / cloudThickness) * cloudThickness;
if (this.prevCloudsType == CloudStatus.FANCY) {
int scaledViewDistance = (int) (((Config.Client.Graphics.CloudQuality.extendClouds ? Config.Client.Graphics.Quality.lodChunkRenderDistance : 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) {
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) {
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();
bufferBuilder.vertex(scaledX + 0.0f, adjustedCloudY + cloudThickness - mediumpFracAccur, scaledZ + 0.0f).uv((scaledX + 0.0f) * lowpFracAccur + adjustedCloudX, (scaledZ + 0.0f) * lowpFracAccur + adjustedCloudZ).color(redTop, greenTop, blueTop, 0.8f).normal(0.0f, 1.0f, 0.0f).endVertex();
}
if (x > -1) {
for (n3 = 0; n3 < 8; ++n3) {
bufferBuilder.vertex(scaledX + (float)n3 + 0.0f, 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 + 0.0f, 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();
bufferBuilder.vertex(scaledX + (float)n3 + 0.0f, adjustedCloudY + cloudThickness, 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();
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) {
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();
bufferBuilder.vertex(scaledX + (float)n3 + 1.0f - mediumpFracAccur, adjustedCloudY + cloudThickness, 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();
bufferBuilder.vertex(scaledX + (float)n3 + 1.0f - mediumpFracAccur, 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 (z > -1) {
for (n3 = 0; n3 < 8; ++n3) {
bufferBuilder.vertex(scaledX + 0.0f, adjustedCloudY + cloudThickness, 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();
bufferBuilder.vertex(scaledX + 8.0f, adjustedCloudY + cloudThickness, scaledZ + (float)n3 + 0.0f).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 + 0.0f).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 + 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();
}
}
}
} else {
int scaledRenderDistance = (int) ((Config.Client.Graphics.CloudQuality.extendClouds ? Config.Client.Graphics.Quality.lodChunkRenderDistance : minecraft.options.renderDistance) / scale);
for (int x = -scaledRenderDistance; x < scaledRenderDistance; x += scaledRenderDistance) {
for (int z = -scaledRenderDistance; z < scaledRenderDistance; z += scaledRenderDistance) {
bufferBuilder.vertex(x, adjustedCloudY, z + scaledRenderDistance).uv((float)x * lowpFracAccur + adjustedCloudX, (float)(z + scaledRenderDistance) * lowpFracAccur + adjustedCloudZ).color(redTop, greenTop, blueTop, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
bufferBuilder.vertex(x + scaledRenderDistance, adjustedCloudY, z + scaledRenderDistance).uv((float)(x + scaledRenderDistance) * lowpFracAccur + adjustedCloudX, (float)(z + scaledRenderDistance) * lowpFracAccur + adjustedCloudZ).color(redTop, greenTop, blueTop, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
bufferBuilder.vertex(x + scaledRenderDistance, adjustedCloudY, z).uv((float)(x + scaledRenderDistance) * lowpFracAccur + adjustedCloudX, (float)z * lowpFracAccur + adjustedCloudZ).color(redTop, greenTop, blueTop, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
bufferBuilder.vertex(x, adjustedCloudY, z).uv((float)x * lowpFracAccur + adjustedCloudX, (float)z * lowpFracAccur + adjustedCloudZ).color(redTop, greenTop, blueTop, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
}
}
}
}
*/
}
@@ -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, "");
}
}
@@ -75,7 +75,7 @@ public class ForgeClientProxy
@SubscribeEvent
public void worldUnloadEvent(WorldEvent.Unload event)
{
eventApi.worldUnloadEvent();
eventApi.worldUnloadEvent(WorldWrapper.getWorldWrapper(event.getWorld()));
}
@SubscribeEvent
@@ -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,12 @@ 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.ExtensionPoint;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.client.ConfigGuiHandler;
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.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLEnvironment;
import net.minecraftforge.fml.loading.FMLLoader;
import java.util.List;
@@ -53,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
*/
@@ -61,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
@@ -69,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(ExtensionPoint.CONFIGGUIFACTORY,
() -> (client, parent) -> Config.getScreen(parent, ""));
() -> (client, parent) -> ConfigGui.getScreen(parent, ""));
forgeClientProxy = new ForgeClientProxy();
MinecraftForge.EVENT_BUS.register(forgeClientProxy);
}
@SubscribeEvent
public void onServerStarting(FMLServerStartingEvent event)
{
// this is called when the server starts
}
private ModelDataMap dataMap = new ModelDataMap.Builder().build();
@Override
@@ -1,9 +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;
@@ -32,7 +33,7 @@ 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.addButton(new TexturedButtonWidget(
// Where the button is on the screen
this.width / 2 - 180, this.height / 6 - 12,
@@ -20,6 +20,10 @@
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.CloudTexture;
import com.seibel.lod.common.clouds.NoiseCloudHandler;
import com.seibel.lod.common.wrappers.McObjectConverter;
import net.minecraft.client.renderer.LevelRenderer;
import org.lwjgl.opengl.GL15;
@@ -33,6 +37,23 @@ import com.seibel.lod.core.objects.math.Mat4f;
import net.minecraft.client.renderer.RenderType;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import net.minecraft.client.CloudStatus;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.*;
import java.util.Random;
/**
* This class is used to mix in my rendering code
* before Minecraft starts rendering blocks.
@@ -40,14 +61,19 @@ import net.minecraft.client.renderer.RenderType;
* render last event, the LODs would render on top
* of the normal terrain.
*
* This is also the mixin for rendering the clouds
*
* @author coolGi2007
* @author James Seibel
* @version 12-29-2021
* @version 12-31-2021
*/
@Mixin(LevelRenderer.class)
public class MixinWorldRenderer
{
// TODO: Fix clouds
private static float previousPartialTicks = 0;
@Inject(at = @At("RETURN"), method = "renderSky(Lcom/mojang/blaze3d/vertex/PoseStack;F)V")
private void renderSky(PoseStack matrixStackIn, float partialTicks, CallbackInfo callback)
{
@@ -56,6 +82,7 @@ public class MixinWorldRenderer
previousPartialTicks = partialTicks;
}
// HEAD or RETURN
@Inject(at = @At("HEAD"), method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDD)V")
private void renderChunkLayer(RenderType renderType, PoseStack matrixStackIn, double xIn, double yIn, double zIn, CallbackInfo callback)
{
+2 -1
View File
@@ -7,7 +7,8 @@
],
"client": [
"MixinOptionsScreen",
"MixinWorldRenderer"
"MixinWorldRenderer",
"MixinFogRenderer"
],
"server": []
}