Compare commits

..

21 Commits

Author SHA1 Message Date
James Seibel 75193d76a3 Update the version number to 1.6.2a 2022-02-17 20:11:13 -06:00
James Seibel aa24fd341e Update the version number to 1.6.2a 2022-02-17 20:10:02 -06:00
tom lee d669b2a1fe Update and merge the render_test core 2022-02-17 22:26:48 +08:00
cola98765 2bd8dab240 #159 multiply color by color... not by alpha 2022-02-15 11:50:14 +01:00
cola98765 2b423c2edd squared colour averaging as in #159
please check if it works looks better.
2022-02-15 11:37:54 +01:00
cola98765 1a4faf4bdd close #188; fix lang parts in #189 2022-02-15 11:21:23 +01:00
cola98765 b70829aceb RotatedPillarBlock colors are taken form sides, resolving #191 2022-02-15 11:06:37 +01:00
cola98765 bba771d376 Potentially fix water texture packs. 2022-02-14 17:31:36 +01:00
James Seibel 75b18f8bd8 Update the forge version to fix a potential crash with Biomes-o-plenty 2022-02-13 16:28:21 -06:00
James Seibel 60da404900 Merge branch '1.18.X' of gitlab.com:jeseibel/minecraft-lod-mod into 1.18.X 2022-02-13 07:37:43 -06:00
coolGi2007 b75eebd0dc Getting more stuff ready for new config 2022-02-13 14:48:56 +10:30
James Seibel 72cbd1167a Prepare for 1.6.1a 2022-02-12 12:01:40 -06:00
tom lee e4e51ebf5b Update core 2022-02-12 23:54:23 +08:00
tom lee dd2096bf1b Frontported the forge mixin issue fix. (It may work without that but...) 2022-02-12 23:54:23 +08:00
coolGi2007 393a94a7a1 We don’t talk about this 1 line in the gradle 2022-02-12 14:04:18 +00:00
tom lee ef0023ef39 Switch to another way to do the world gen. Now more mod compat! 2022-02-12 22:00:09 +08:00
coolGi2007 f0994fff75 Added a way to add mods in code and not run on runtime and moved issues and source to gradle.properties 2022-02-12 19:34:54 +10:30
tom lee 31f41540c0 Fix chat format color. Add failsafe stopping of generator 2022-02-12 15:13:58 +08:00
tom lee 81fe13b9c0 Add backup to VanillaRenderedChunks & many generator stuff 2022-02-12 14:30:04 +08:00
tom lee 332df13b29 Fix loadChunk try/catch missing the mark & add WRAN on modded chunkGen 2022-02-12 13:12:25 +08:00
James Seibel b3af6df0c5 Update the version number to 1.6.1a-pre and re-enable dev code 2022-02-11 22:08:35 -06:00
28 changed files with 861 additions and 194 deletions
+3 -1
View File
@@ -108,7 +108,9 @@ allprojects { p ->
mod_name: mod_name,
authors: mod_authors,
description: mod_description,
homepage: mod_homepage
homepage: mod_homepage,
source: mod_source,
issues: mod_issues
] // The left side is what gets replaced in the mod info and the right side is where to get it from in the gradle.properties
inputs.properties replaceProperties
@@ -4,6 +4,8 @@ import com.seibel.lod.common.forge.LodForgeMethodCaller;
import com.seibel.lod.common.networking.NetworkInterface;
import com.seibel.lod.common.wrappers.DependencySetup;
import com.seibel.lod.common.wrappers.config.ConfigGui;
import com.seibel.lod.core.Config;
import com.seibel.lod.core.config.ConfigBase;
/**
* This is the common main class
@@ -15,6 +17,8 @@ public class LodCommonMain {
public static LodForgeMethodCaller forgeMethodCaller;
public static NetworkInterface networkInterface;
public static final boolean IsNewConfig = false;
public static void startup(LodForgeMethodCaller caller, boolean serverSided) {
LodCommonMain.serverSided = serverSided;
if (caller != null) {
@@ -27,7 +31,8 @@ public class LodCommonMain {
public static void initConfig() {
ConfigGui.init(Config.class);
if (!IsNewConfig)
ConfigGui.init(OldConfig.class);
}
public static void registerNetworking(NetworkInterface networkInterface) {
@@ -33,7 +33,7 @@ import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton.I
* @author coolGi2007
* @version 12-12-2021
*/
public class Config extends ConfigGui
public class OldConfig
//public class Config extends TinyConfig
{
// CONFIG STRUCTURE
@@ -34,5 +34,6 @@ public class DependencySetup {
SingletonHandler.bind(IVersionConstants.class, VersionConstants.INSTANCE);
SingletonHandler.bind(IWrapperFactory.class, WrapperFactory.INSTANCE);
DependencySetupDoneCheck.isDone = true;
}
}
@@ -0,0 +1,10 @@
package com.seibel.lod.common.wrappers;
import java.util.function.Supplier;
public class DependencySetupDoneCheck
{
public static boolean isDone = false;
public static Supplier<Boolean> getIsCurrentThreadDistantGeneratorThread = (() -> {return false;});
}
@@ -14,13 +14,7 @@ import com.seibel.lod.core.wrapperInterfaces.block.IBlockColorWrapper;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BushBlock;
import net.minecraft.world.level.block.FlowerBlock;
import net.minecraft.world.level.block.GrassBlock;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.TallGrassBlock;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockState;
@@ -125,7 +119,7 @@ public class BlockColorWrapper implements IBlockColorWrapper
for (Direction direction : directions)
{
quads = mc.getModelManager().getBlockModelShaper().getBlockModel(block.defaultBlockState()).getQuads(blockState, direction, random);
if (!quads.isEmpty())
if (!quads.isEmpty() && !(block instanceof RotatedPillarBlock && direction == Direction.UP))
break;
}
@@ -152,7 +146,7 @@ public class BlockColorWrapper implements IBlockColorWrapper
// generate the block's color
// for (int frameIndex = 0; frameIndex < texture.getFrameCount(); frameIndex++)
boolean lookForTint = grassInstance() || leavesInstance() || waterIstance();
boolean lookForTint = grassInstance() || leavesInstance() || waterInstance();
int frameIndex = 0; // TODO
{
@@ -170,7 +164,7 @@ public class BlockColorWrapper implements IBlockColorWrapper
{
// determine if this pixel is gray
int colorMax = Math.max(Math.max(ColorUtil.getBlue(tempColor), ColorUtil.getGreen(tempColor)), ColorUtil.getRed(tempColor));
int colorMin = 4 + Math.min(Math.min(ColorUtil.getBlue(tempColor), ColorUtil.getGreen(tempColor)), ColorUtil.getRed(tempColor));
int colorMin = 16 + Math.min(Math.min(ColorUtil.getBlue(tempColor), ColorUtil.getGreen(tempColor)), ColorUtil.getRed(tempColor));
boolean isGray = colorMax < colorMin;
if (isGray)
numberOfGreyPixel++;
@@ -186,10 +180,10 @@ public class BlockColorWrapper implements IBlockColorWrapper
// add to the running averages
count += colorMultiplier;
alpha += ColorUtil.getAlpha(tempColor) * colorMultiplier;
red += ColorUtil.getBlue(tempColor) * colorMultiplier;
green += ColorUtil.getGreen(tempColor) * colorMultiplier;
blue += ColorUtil.getRed(tempColor) * colorMultiplier;
alpha += ColorUtil.getAlpha(tempColor) * ColorUtil.getAlpha(tempColor) * colorMultiplier;
red += ColorUtil.getBlue(tempColor) * ColorUtil.getBlue(tempColor) * colorMultiplier;
green += ColorUtil.getGreen(tempColor) * ColorUtil.getGreen(tempColor) * colorMultiplier;
blue += ColorUtil.getRed(tempColor) * ColorUtil.getRed(tempColor) * colorMultiplier;
}
}
}
@@ -201,11 +195,11 @@ public class BlockColorWrapper implements IBlockColorWrapper
else
{
// determine the average color
alpha /= count;
red /= count;
green /= count;
blue /= count;
tempColor = ColorUtil.rgbToInt(alpha, red, green, blue);
tempColor = ColorUtil.rgbToInt(
(int) Math.sqrt(alpha / count),
(int) Math.sqrt(red / count),
(int) Math.sqrt(green / count),
(int) Math.sqrt(blue / count));
}
// determine if this block should use the biome color tint
@@ -217,7 +211,7 @@ public class BlockColorWrapper implements IBlockColorWrapper
this.foliageTint = leavesInstance() && toTint;
this.waterTint = waterIstance() && toTint;
this.waterTint = waterInstance();
//hardcoded leaves
if (block == Blocks.SPRUCE_LEAVES)
@@ -248,7 +242,7 @@ public class BlockColorWrapper implements IBlockColorWrapper
}
/** determine if the given block should use the biome's foliage color */
private boolean waterIstance()
private boolean waterInstance()
{
return block == Blocks.WATER;
}
@@ -3,7 +3,7 @@ package com.seibel.lod.common.wrappers.config;
import com.seibel.lod.core.enums.config.*;
import com.seibel.lod.core.enums.rendering.*;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.common.Config;
import com.seibel.lod.common.OldConfig;
/**
* This holds the config defaults and setters/getters
@@ -53,7 +53,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public boolean getOptionsButton()
{
return Config.optionsButton;
return OldConfig.optionsButton;
}
@Override
public void setOptionsButton(boolean newOptionsButton)
@@ -117,7 +117,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public HorizontalResolution getDrawResolution()
{
return Config.Client.Graphics.Quality.drawResolution;
return OldConfig.Client.Graphics.Quality.drawResolution;
}
@Override
public void setDrawResolution(HorizontalResolution newHorizontalResolution)
@@ -130,7 +130,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public int getLodChunkRenderDistance()
{
return Config.Client.Graphics.Quality.lodChunkRenderDistance;
return OldConfig.Client.Graphics.Quality.lodChunkRenderDistance;
}
@Override
public void setLodChunkRenderDistance(int newLodChunkRenderDistance)
@@ -143,7 +143,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public VerticalQuality getVerticalQuality()
{
return Config.Client.Graphics.Quality.verticalQuality;
return OldConfig.Client.Graphics.Quality.verticalQuality;
}
@Override
public void setVerticalQuality(VerticalQuality newVerticalQuality)
@@ -156,7 +156,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public int getHorizontalScale()
{
return Config.Client.Graphics.Quality.horizontalScale;
return OldConfig.Client.Graphics.Quality.horizontalScale;
}
@Override
public void setHorizontalScale(int newHorizontalScale)
@@ -169,7 +169,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public HorizontalQuality getHorizontalQuality()
{
return Config.Client.Graphics.Quality.horizontalQuality;
return OldConfig.Client.Graphics.Quality.horizontalQuality;
}
@Override
public void setHorizontalQuality(HorizontalQuality newHorizontalQuality)
@@ -180,7 +180,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public DropoffQuality getDropoffQuality() {
return Config.Client.Graphics.Quality.dropoffQuality;
return OldConfig.Client.Graphics.Quality.dropoffQuality;
}
@Override
public void setDropoffQuality(DropoffQuality newDropoffQuality) {
@@ -195,7 +195,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public FogDistance getFogDistance()
{
return Config.Client.Graphics.FogQuality.fogDistance;
return OldConfig.Client.Graphics.FogQuality.fogDistance;
}
@Override
public void setFogDistance(FogDistance newFogDistance)
@@ -208,7 +208,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public FogDrawMode getFogDrawMode()
{
return Config.Client.Graphics.FogQuality.fogDrawMode;
return OldConfig.Client.Graphics.FogQuality.fogDrawMode;
}
@Override
@@ -222,7 +222,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public FogColorMode getFogColorMode()
{
return Config.Client.Graphics.FogQuality.fogColorMode;
return OldConfig.Client.Graphics.FogQuality.fogColorMode;
}
@Override
@@ -236,7 +236,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public boolean getDisableVanillaFog()
{
return Config.Client.Graphics.FogQuality.disableVanillaFog;
return OldConfig.Client.Graphics.FogQuality.disableVanillaFog;
}
@Override
public void setDisableVanillaFog(boolean newDisableVanillaFog)
@@ -252,7 +252,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public boolean getDisableDirectionalCulling()
{
return Config.Client.Graphics.AdvancedGraphics.disableDirectionalCulling;
return OldConfig.Client.Graphics.AdvancedGraphics.disableDirectionalCulling;
}
@Override
public void setDisableDirectionalCulling(boolean newDisableDirectionalCulling)
@@ -265,7 +265,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public VanillaOverdraw getVanillaOverdraw()
{
return Config.Client.Graphics.AdvancedGraphics.vanillaOverdraw;
return OldConfig.Client.Graphics.AdvancedGraphics.vanillaOverdraw;
}
@Override
public void setVanillaOverdraw(VanillaOverdraw newVanillaOverdraw)
@@ -277,7 +277,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public int getBacksideCullingRange()
{
return Config.Client.Graphics.AdvancedGraphics.backsideCullingRange;
return OldConfig.Client.Graphics.AdvancedGraphics.backsideCullingRange;
}
@Override
public void setBacksideCullingRange(int newBacksideCullingRange)
@@ -289,7 +289,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public boolean getUseExtendedNearClipPlane()
{
return Config.Client.Graphics.AdvancedGraphics.useExtendedNearClipPlane;
return OldConfig.Client.Graphics.AdvancedGraphics.useExtendedNearClipPlane;
}
@Override
public void setUseExtendedNearClipPlane(boolean newUseExtendedNearClipPlane)
@@ -311,7 +311,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public GenerationPriority getGenerationPriority()
{
return Config.Client.WorldGenerator.generationPriority;
return OldConfig.Client.WorldGenerator.generationPriority;
}
@Override
public void setGenerationPriority(GenerationPriority newGenerationPriority)
@@ -324,7 +324,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public DistanceGenerationMode getDistanceGenerationMode()
{
return Config.Client.WorldGenerator.distanceGenerationMode;
return OldConfig.Client.WorldGenerator.distanceGenerationMode;
}
@Override
public void setDistanceGenerationMode(DistanceGenerationMode newDistanceGenerationMode)
@@ -337,7 +337,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public boolean getAllowUnstableFeatureGeneration()
{
return Config.Client.WorldGenerator.allowUnstableFeatureGeneration;
return OldConfig.Client.WorldGenerator.allowUnstableFeatureGeneration;
}
@Override
public void setAllowUnstableFeatureGeneration(boolean newAllowUnstableFeatureGeneration)
@@ -350,7 +350,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public BlocksToAvoid getBlocksToAvoid()
{
return Config.Client.WorldGenerator.blocksToAvoid;
return OldConfig.Client.WorldGenerator.blocksToAvoid;
}
@Override
public void setBlockToAvoid(BlocksToAvoid newBlockToAvoid)
@@ -361,7 +361,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public boolean getEnableDistantGeneration()
{
return Config.Client.WorldGenerator.enableDistantGeneration;
return (boolean) ConfigGui.editSingleOption.getEntry("client.worldGenerator.enableDistantGeneration").value;
}
@Override
public void setEnableDistantGeneration(boolean newEnableDistantGeneration)
@@ -372,7 +372,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public LightGenerationMode getLightGenerationMode()
{
return Config.Client.WorldGenerator.lightGenerationMode;
return OldConfig.Client.WorldGenerator.lightGenerationMode;
}
@Override
public void setLightGenerationMode(LightGenerationMode newLightGenerationMode)
@@ -428,7 +428,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public int getNumberOfWorldGenerationThreads()
{
return Config.Client.Advanced.Threading.numberOfWorldGenerationThreads;
return OldConfig.Client.Advanced.Threading.numberOfWorldGenerationThreads;
}
@Override
public void setNumberOfWorldGenerationThreads(int newNumberOfWorldGenerationThreads)
@@ -441,7 +441,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public int getNumberOfBufferBuilderThreads()
{
return Config.Client.Advanced.Threading.numberOfBufferBuilderThreads;
return OldConfig.Client.Advanced.Threading.numberOfBufferBuilderThreads;
}
@Override
public void setNumberOfBufferBuilderThreads(int newNumberOfWorldBuilderThreads)
@@ -505,7 +505,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public GpuUploadMethod getGpuUploadMethod()
{
return Config.Client.Advanced.Buffers.gpuUploadMethod;
return OldConfig.Client.Advanced.Buffers.gpuUploadMethod;
}
@Override
public void setGpuUploadMethod(GpuUploadMethod newDisableVanillaFog)
@@ -518,7 +518,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public int getGpuUploadPerMegabyteInMilliseconds()
{
return Config.Client.Advanced.Buffers.gpuUploadPerMegabyteInMilliseconds;
return OldConfig.Client.Advanced.Buffers.gpuUploadPerMegabyteInMilliseconds;
}
@Override
public void setGpuUploadPerMegabyteInMilliseconds(int newMilliseconds) {
@@ -530,7 +530,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
@Override
public BufferRebuildTimes getRebuildTimes()
{
return Config.Client.Advanced.Buffers.rebuildTimes;
return OldConfig.Client.Advanced.Buffers.rebuildTimes;
}
@Override
public void setRebuildTimes(BufferRebuildTimes newBufferRebuildTimes)
@@ -0,0 +1,505 @@
package com.seibel.lod.common.wrappers.config;
import com.seibel.lod.core.enums.config.*;
import com.seibel.lod.core.enums.rendering.*;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.Config;
/**
* This is temporary for testing the new config
*
* @author coolGi2007
* @version 02-13-2022
*/
public class NewLodConfigWrapperSingleton implements ILodConfigWrapperSingleton
{
public static final NewLodConfigWrapperSingleton INSTANCE = new NewLodConfigWrapperSingleton();
private static final Client client = new Client();
@Override
public IClient client()
{
return client;
}
public static class Client implements IClient
{
public final IGraphics graphics;
public final IWorldGenerator worldGenerator;
public final IAdvanced advanced;
@Override
public IGraphics graphics()
{
return graphics;
}
@Override
public IWorldGenerator worldGenerator()
{
return worldGenerator;
}
@Override
public IAdvanced advanced()
{
return advanced;
}
@Override
public boolean getOptionsButton()
{
return Config.client.optionsButton.get();
}
@Override
public void setOptionsButton(boolean newOptionsButton)
{
Config.client.optionsButton.set(newOptionsButton);
}
//================//
// Client Configs //
//================//
public Client()
{
graphics = new Graphics();
worldGenerator = new WorldGenerator();
advanced = new Advanced();
}
//==================//
// Graphics Configs //
//==================//
public static class Graphics implements IGraphics
{
public final IQuality quality;
public final IFogQuality fogQuality;
public final IAdvancedGraphics advancedGraphics;
@Override
public IQuality quality()
{
return quality;
}
@Override
public IFogQuality fogQuality()
{
return fogQuality;
}
@Override
public IAdvancedGraphics advancedGraphics()
{
return advancedGraphics;
}
Graphics()
{
quality = new Quality();
fogQuality = new FogQuality();
advancedGraphics = new AdvancedGraphics();
}
public static class Quality implements IQuality
{
@Override
public HorizontalResolution getDrawResolution()
{
return Config.Client.Graphics.Quality.drawResolution.get();
}
@Override
public void setDrawResolution(HorizontalResolution newHorizontalResolution)
{
Config.Client.Graphics.Quality.drawResolution.set(newHorizontalResolution);
}
@Override
public int getLodChunkRenderDistance()
{
return Config.Client.Graphics.Quality.lodChunkRenderDistance.get();
}
@Override
public void setLodChunkRenderDistance(int newLodChunkRenderDistance)
{
Config.Client.Graphics.Quality.lodChunkRenderDistance.set(newLodChunkRenderDistance);
}
@Override
public VerticalQuality getVerticalQuality()
{
return Config.Client.Graphics.Quality.verticalQuality.get();
}
@Override
public void setVerticalQuality(VerticalQuality newVerticalQuality)
{
Config.Client.Graphics.Quality.verticalQuality.set(newVerticalQuality);
}
@Override
public int getHorizontalScale()
{
return Config.Client.Graphics.Quality.horizontalScale.get();
}
@Override
public void setHorizontalScale(int newHorizontalScale)
{
Config.Client.Graphics.Quality.horizontalScale.set(newHorizontalScale);
}
@Override
public HorizontalQuality getHorizontalQuality()
{
return Config.Client.Graphics.Quality.horizontalQuality.get();
}
@Override
public void setHorizontalQuality(HorizontalQuality newHorizontalQuality)
{
Config.Client.Graphics.Quality.horizontalQuality.set(newHorizontalQuality);
}
@Override
public DropoffQuality getDropoffQuality() {
return Config.Client.Graphics.Quality.dropoffQuality.get();
}
@Override
public void setDropoffQuality(DropoffQuality newDropoffQuality) {
Config.Client.Graphics.Quality.dropoffQuality.set(newDropoffQuality);
}
}
public static class FogQuality implements IFogQuality
{
@Override
public FogDistance getFogDistance()
{
return Config.Client.Graphics.FogQuality.fogDistance.get();
}
@Override
public void setFogDistance(FogDistance newFogDistance)
{
Config.Client.Graphics.FogQuality.fogDistance.set(newFogDistance);
}
@Override
public FogDrawMode getFogDrawMode()
{
return Config.Client.Graphics.FogQuality.fogDrawMode.get();
}
@Override
public void setFogDrawMode(FogDrawMode setFogDrawMode)
{
Config.Client.Graphics.FogQuality.fogDrawMode.set(setFogDrawMode);
}
@Override
public FogColorMode getFogColorMode()
{
return Config.Client.Graphics.FogQuality.fogColorMode.get();
}
@Override
public void setFogColorMode(FogColorMode newFogColorMode)
{
Config.Client.Graphics.FogQuality.fogColorMode.set(newFogColorMode);
}
@Override
public boolean getDisableVanillaFog()
{
return Config.Client.Graphics.FogQuality.disableVanillaFog.get();
}
@Override
public void setDisableVanillaFog(boolean newDisableVanillaFog)
{
Config.Client.Graphics.FogQuality.disableVanillaFog.set(newDisableVanillaFog);
}
}
public static class AdvancedGraphics implements IAdvancedGraphics
{
@Override
public boolean getDisableDirectionalCulling()
{
return Config.Client.Graphics.AdvancedGraphics.disableDirectionalCulling.get();
}
@Override
public void setDisableDirectionalCulling(boolean newDisableDirectionalCulling)
{
Config.Client.Graphics.AdvancedGraphics.disableDirectionalCulling.set(newDisableDirectionalCulling);
}
@Override
public VanillaOverdraw getVanillaOverdraw()
{
return Config.Client.Graphics.AdvancedGraphics.vanillaOverdraw.get();
}
@Override
public void setVanillaOverdraw(VanillaOverdraw newVanillaOverdraw)
{
Config.Client.Graphics.AdvancedGraphics.vanillaOverdraw.set(newVanillaOverdraw);
}
@Override
public boolean getUseExtendedNearClipPlane()
{
return Config.Client.Graphics.AdvancedGraphics.useExtendedNearClipPlane.get();
}
@Override
public void setUseExtendedNearClipPlane(boolean newUseExtendedNearClipPlane)
{
Config.Client.Graphics.AdvancedGraphics.useExtendedNearClipPlane.set(newUseExtendedNearClipPlane);
}
}
}
//========================//
// WorldGenerator Configs //
//========================//
public static class WorldGenerator implements IWorldGenerator
{
@Override
public GenerationPriority getGenerationPriority()
{
return Config.Client.WorldGenerator.generationPriority.get();
}
@Override
public void setGenerationPriority(GenerationPriority newGenerationPriority)
{
Config.Client.WorldGenerator.generationPriority.set(newGenerationPriority);
}
@Override
public DistanceGenerationMode getDistanceGenerationMode()
{
return Config.Client.WorldGenerator.distanceGenerationMode.get();
}
@Override
public void setDistanceGenerationMode(DistanceGenerationMode newDistanceGenerationMode)
{
Config.Client.WorldGenerator.distanceGenerationMode.set(newDistanceGenerationMode);
}
/*
@Override
public boolean getAllowUnstableFeatureGeneration()
{
return Config.Client.WorldGenerator.allowUnstableFeatureGeneration;
}
@Override
public void setAllowUnstableFeatureGeneration(boolean newAllowUnstableFeatureGeneration)
{
ConfigGui.editSingleOption.getEntry("client.worldGenerator.allowUnstableFeatureGeneration").value = newAllowUnstableFeatureGeneration;
ConfigGui.editSingleOption.saveOption("client.worldGenerator.allowUnstableFeatureGeneration");
}*/
@Override
public BlocksToAvoid getBlocksToAvoid()
{
return Config.Client.WorldGenerator.blocksToAvoid.get();
}
@Override
public void setBlockToAvoid(BlocksToAvoid newBlockToAvoid)
{
Config.Client.WorldGenerator.blocksToAvoid.set(newBlockToAvoid);
}
@Override
public boolean getEnableDistantGeneration()
{
return Config.Client.WorldGenerator.enableDistantGeneration.get();
}
@Override
public void setEnableDistantGeneration(boolean newEnableDistantGeneration)
{
Config.Client.WorldGenerator.enableDistantGeneration.set(newEnableDistantGeneration);
}
@Override
public LightGenerationMode getLightGenerationMode()
{
return Config.Client.WorldGenerator.lightGenerationMode.get();
}
@Override
public void setLightGenerationMode(LightGenerationMode newLightGenerationMode)
{
Config.Client.WorldGenerator.lightGenerationMode.set(newLightGenerationMode);
}
}
//============================//
// AdvancedModOptions Configs //
//============================//
public static class Advanced implements IAdvanced
{
public final IThreading threading;
public final IDebugging debugging;
public final IBuffers buffers;
@Override
public IThreading threading()
{
return threading;
}
@Override
public IDebugging debugging()
{
return debugging;
}
@Override
public IBuffers buffers()
{
return buffers;
}
public Advanced()
{
threading = new Threading();
debugging = new Debugging();
buffers = new Buffers();
}
public static class Threading implements IThreading
{
@Override
public int getNumberOfWorldGenerationThreads()
{
return Config.Client.Advanced.Threading.numberOfWorldGenerationThreads.get();
}
@Override
public void setNumberOfWorldGenerationThreads(int newNumberOfWorldGenerationThreads)
{
Config.Client.Advanced.Threading.numberOfWorldGenerationThreads.set(newNumberOfWorldGenerationThreads);
}
@Override
public int getNumberOfBufferBuilderThreads()
{
return Config.Client.Advanced.Threading.numberOfBufferBuilderThreads.get();
}
@Override
public void setNumberOfBufferBuilderThreads(int newNumberOfWorldBuilderThreads)
{
Config.Client.Advanced.Threading.numberOfBufferBuilderThreads.set(newNumberOfWorldBuilderThreads);
}
}
//===============//
// Debug Options //
//===============//
public static class Debugging implements IDebugging
{
@Override
public boolean getDrawLods()
{
return Config.Client.Advanced.Debugging.drawLods.get();
}
@Override
public void setDrawLods(boolean newDrawLods)
{
Config.Client.Advanced.Debugging.drawLods.set(newDrawLods);
}
@Override
public DebugMode getDebugMode()
{
return Config.Client.Advanced.Debugging.debugMode.get();
}
@Override
public void setDebugMode(DebugMode newDebugMode)
{
Config.Client.Advanced.Debugging.debugMode.set(newDebugMode);
}
@Override
public boolean getDebugKeybindingsEnabled()
{
return Config.Client.Advanced.Debugging.enableDebugKeybindings.get();
}
@Override
public void setDebugKeybindingsEnabled(boolean newEnableDebugKeybindings)
{
Config.Client.Advanced.Debugging.enableDebugKeybindings.set(newEnableDebugKeybindings);
}
}
public static class Buffers implements IBuffers
{
@Override
public GpuUploadMethod getGpuUploadMethod()
{
return Config.Client.Advanced.Buffers.gpuUploadMethod.get();
}
@Override
public void setGpuUploadMethod(GpuUploadMethod newDisableVanillaFog)
{
Config.Client.Advanced.Buffers.gpuUploadMethod.set(newDisableVanillaFog);
}
@Override
public int getGpuUploadPerMegabyteInMilliseconds()
{
return Config.Client.Advanced.Buffers.gpuUploadPerMegabyteInMilliseconds.get();
}
@Override
public void setGpuUploadPerMegabyteInMilliseconds(int newMilliseconds) {
Config.Client.Advanced.Buffers.gpuUploadPerMegabyteInMilliseconds.set(newMilliseconds);
}
@Override
public BufferRebuildTimes getRebuildTimes()
{
return Config.Client.Advanced.Buffers.rebuildTimes.get();
}
@Override
public void setRebuildTimes(BufferRebuildTimes newBufferRebuildTimes)
{
Config.Client.Advanced.Buffers.rebuildTimes.set(newBufferRebuildTimes);
}
}
}
}
}
@@ -8,6 +8,7 @@ import java.util.stream.Collectors;
import com.mojang.blaze3d.platform.NativeImage;
import com.mojang.blaze3d.systems.RenderSystem;
import com.seibel.lod.common.wrappers.misc.LightMapWrapper;
import com.seibel.lod.core.api.ClientApi;
import com.seibel.lod.core.api.ModAccessorApi;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.util.SingletonHandler;
@@ -148,6 +149,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
* <p>
*/
public boolean usingBackupGetVanillaRenderedChunks = false;
@Override
public HashSet<AbstractChunkPosWrapper> getVanillaRenderedChunks()
{
@@ -164,14 +166,28 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
pos = getMaximumRenderedChunks();
return pos;
}
LevelRenderer levelRenderer = MC.levelRenderer;
LinkedHashSet<LevelRenderer.RenderChunkInfo> chunks = levelRenderer.renderChunkStorage.get().renderChunks;
return (chunks.stream().map((chunk) -> {
AABB chunkBoundingBox = chunk.chunk.bb;
return FACTORY.createChunkPos(Math.floorDiv((int) chunkBoundingBox.minX, 16),
Math.floorDiv((int) chunkBoundingBox.minZ, 16));
}).collect(Collectors.toCollection(HashSet::new)));
if (!usingBackupGetVanillaRenderedChunks) {
try {
LevelRenderer levelRenderer = MC.levelRenderer;
LinkedHashSet<LevelRenderer.RenderChunkInfo> chunks = levelRenderer.renderChunkStorage.get().renderChunks;
return (chunks.stream().map((chunk) -> {
AABB chunkBoundingBox = chunk.chunk.bb;
return FACTORY.createChunkPos(Math.floorDiv((int) chunkBoundingBox.minX, 16),
Math.floorDiv((int) chunkBoundingBox.minZ, 16));
}).collect(Collectors.toCollection(HashSet::new)));
} catch (LinkageError e) {
try {
MinecraftWrapper.INSTANCE.sendChatMessage(
"\u00A7e\u00A7l\u00A7uWARNING: Distant Horizons: getVanillaRenderedChunks method failed."
+ " Using Backup Method.");
MinecraftWrapper.INSTANCE.sendChatMessage(
"\u00A7eOverdraw prevention will be worse than normal.");
} catch (Exception e2) {}
ClientApi.LOGGER.error("getVanillaRenderedChunks Error: {}", e);
usingBackupGetVanillaRenderedChunks = true;
}
}
return getMaximumRenderedChunks();
}
@Override
@@ -29,20 +29,19 @@ import com.seibel.lod.core.util.GridList;
import com.seibel.lod.core.util.LodThreadFactory;
import com.seibel.lod.core.util.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper;
import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvionmentWrapper;
import java.io.IOException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import com.seibel.lod.common.wrappers.DependencySetupDoneCheck;
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
import com.seibel.lod.common.wrappers.world.WorldWrapper;
import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.ChunkLoader;
@@ -60,10 +59,14 @@ import com.seibel.lod.common.wrappers.worldGeneration.step.StepSurface;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.ProtoChunk;
import net.minecraft.world.level.chunk.UpgradeData;
import net.minecraft.world.level.levelgen.DebugLevelSource;
import net.minecraft.world.level.levelgen.FlatLevelSource;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
import net.minecraft.core.Registry;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.lighting.LevelLightEngine;
@@ -207,7 +210,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
}
}
public static final int TIMEOUT_SECONDS = 30;
public static final int TIMEOUT_SECONDS = 60;
//=================Generation Step===================
@@ -220,12 +223,39 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
public final StepSurface stepSurface = new StepSurface(this);
public final StepFeatures stepFeatures = new StepFeatures(this);
public final StepLight stepLight = new StepLight(this);
public boolean unsafeThreadingRecorded = false;
//public boolean safeMode = false;
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
private static final IMinecraftWrapper MC = SingletonHandler.get(IMinecraftWrapper.class);
public static final long EXCEPTION_TIMER_RESET_TIME = TimeUnit.NANOSECONDS.convert(1, TimeUnit.SECONDS);
public static final int EXCEPTION_COUNTER_TRIGGER = 20;
public int unknownExceptionCount = 0;
public long lastExceptionTriggerTime = 0;
public static final LodThreadFactory threadFactory = new LodThreadFactory("Gen-Worker-Thread", Thread.MIN_PRIORITY);
public static ThreadLocal<Boolean> isDistantGeneratorThread = new ThreadLocal<Boolean>();
public static boolean isCurrentThreadDistantGeneratorThread() {
return (isDistantGeneratorThread.get() != null);
}
static {
DependencySetupDoneCheck.getIsCurrentThreadDistantGeneratorThread = BatchGenerationEnvironment::isCurrentThreadDistantGeneratorThread;
}
public ExecutorService executors = Executors.newFixedThreadPool(
CONFIG.client().advanced().threading().getNumberOfWorldGenerationThreads(), threadFactory);
public <T> T joinSync(CompletableFuture<T> f) {
if (!unsafeThreadingRecorded && !f.isDone()) {
MC.sendChatMessage("\u00A74\u00A7l\u00A7uERROR: Distant Horizons: Unsafe Threading in Chunk Generator Detected!");
MC.sendChatMessage("\u00A7eTo increase stability, it is recommended to set world generation threads count to 1.");
ClientApi.LOGGER.error("Unsafe Threading in Chunk Generator: ", new RuntimeException("Concurrent future"));
unsafeThreadingRecorded = true;
}
return f.join();
}
public void resizeThreadPool(int newThreadCount)
{
@@ -251,6 +281,12 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
public void updateAllFutures()
{
if (unknownExceptionCount > 0) {
if (System.nanoTime() - lastExceptionTriggerTime >= EXCEPTION_TIMER_RESET_TIME) {
unknownExceptionCount = 0;
}
}
// Update all current out standing jobs
Iterator<GenerationEvent> iter = events.iterator();
while (iter.hasNext())
@@ -264,12 +300,10 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
}
catch (Throwable e)
{
e.printStackTrace();
while (e.getCause() != null)
{
e = e.getCause();
e.printStackTrace();
}
ClientApi.LOGGER.error("Batching World Generator: Event {} gotten an exception", event);
ClientApi.LOGGER.error("Exception: ", e);
unknownExceptionCount++;
lastExceptionTriggerTime = System.nanoTime();
}
finally
{
@@ -291,22 +325,31 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
}
}
}
if (unknownExceptionCount > EXCEPTION_COUNTER_TRIGGER) {
try {
MC.sendChatMessage("\u00A74\u00A7l\u00A7uERROR: Distant Horizons: Too many exceptions in Batching World Generator! Disabling the generator.");
} catch (Exception e) {}
ClientApi.LOGGER.error("Too many exceptions in Batching World Generator! Now disabling.");
unknownExceptionCount = 0;
CONFIG.client().worldGenerator().setEnableDistantGeneration(false);
}
}
public BatchGenerationEnvironment(IWorldWrapper serverlevel, LodBuilder lodBuilder, LodDimension lodDim)
{
super(serverlevel, lodBuilder, lodDim);
ClientApi.LOGGER.info("================WORLD_GEN_STEP_INITING=============");
ChunkGenerator generator = ((WorldWrapper) serverlevel).getServerWorld().getChunkSource().getGenerator();
if (!(generator instanceof NoiseBasedChunkGenerator ||
generator instanceof DebugLevelSource ||
generator instanceof FlatLevelSource)) {
MC.sendChatMessage("\u00A74\u00A7l\u00A7uWARNING: Distant Horizons: Unknown Chunk Generator Detected! Distant Generation May Fail!");
MC.sendChatMessage("\u00A7eIf it does crash, set Distant Generation to OFF or Generation Mode to None.");
ClientApi.LOGGER.warn("Unknown Chunk Generator detected: {}", generator.getClass());
}
params = new GlobalParameters((ServerLevel) ((WorldWrapper) serverlevel).getWorld(), lodBuilder, lodDim);
}
public void startLoadingAllRegionsFromFile(LodDimension lodDim)
{
ServerLevel level = params.level;
level.getChunkSource();
}
@SuppressWarnings("resource")
public static ChunkAccess loadOrMakeChunk(ChunkPos chunkPos, ServerLevel level, LevelLightEngine lightEngine)
{
@@ -315,7 +358,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
{
chunkData = level.getChunkSource().chunkMap.readChunk(chunkPos);
}
catch (IOException e)
catch (Exception e)
{
ClientApi.LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e);
}
@@ -325,7 +368,12 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
}
else
{
try {
return ChunkLoader.read(level, lightEngine, chunkPos, chunkData);
} catch (Exception e) {
ClientApi.LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e);
return new ProtoChunk(chunkPos, UpgradeData.EMPTY, level, level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null);
}
}
}
@@ -363,7 +411,6 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
catch (RuntimeException e2)
{
// Continue...
e2.printStackTrace();
}
if (target == null)
target = new ProtoChunk(chunkPos, UpgradeData.EMPTY, params.level,
@@ -426,33 +473,35 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
{
int targetIndex = referencedChunks.offsetOf(centreIndex, ox, oy);
ChunkAccess target = referencedChunks.get(targetIndex);
target.setLightCorrect(true);
if (target instanceof LevelChunk)
((LevelChunk) target).setClientLightReady(true);
ChunkWrapper wrappedChunk = new ChunkWrapper(target, region);
if (!wrappedChunk.isLightCorrect()) {
throw new RuntimeException("The generated chunk somehow has isLightCorrect() returning false");
}
boolean isFull = target.getStatus() == ChunkStatus.FULL || target instanceof LevelChunk;
boolean isPartial = target.isOldNoiseGeneration();
if (isFull)
{
if (ENABLE_LOAD_EVENT_LOGGING)
ClientApi.LOGGER.info("Detected full existing chunk at {}", target.getPos());
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, new ChunkWrapper(target, region),
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, wrappedChunk,
new LodBuilderConfig(DistanceGenerationMode.FULL), true, e.genAllDetails);
}
else if (isPartial)
{
if (ENABLE_LOAD_EVENT_LOGGING)
ClientApi.LOGGER.info("Detected old existing chunk at {}", target.getPos());
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, new ChunkWrapper(target, region),
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, wrappedChunk,
new LodBuilderConfig(generationMode), true, e.genAllDetails);
}
else if (target.getStatus() == ChunkStatus.EMPTY && generationMode == DistanceGenerationMode.NONE)
{
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, new ChunkWrapper(target, region),
params.lodBuilder.generateLodNodeFromChunk(params.lodDim,wrappedChunk,
LodBuilderConfig.getFillVoidConfig(), true, e.genAllDetails);
}
else
{
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, new ChunkWrapper(target, region),
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, wrappedChunk,
new LodBuilderConfig(generationMode), true, e.genAllDetails);
}
if (e.lightMode == LightGenerationMode.FANCY || isFull)
@@ -530,6 +579,10 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
{
if (p instanceof ProtoChunk)
((ProtoChunk) p).setLightCorrect(true);
if (p instanceof LevelChunk) {
((LevelChunk) p).setLightCorrect(true);
((LevelChunk) p).setClientLightReady(true);
}
});
break;
}
@@ -46,7 +46,12 @@ public final class GenerationEvent
future = generationGroup.executors.submit(() ->
{
generationGroup.generateLodFromList(this);
BatchGenerationEnvironment.isDistantGeneratorThread.set(true);
try {
generationGroup.generateLodFromList(this);
} finally {
BatchGenerationEnvironment.isDistantGeneratorThread.remove();
}
});
}
@@ -78,7 +83,7 @@ public final class GenerationEvent
}
catch (InterruptedException | ExecutionException e)
{
e.printStackTrace();
throw new RuntimeException(e.getCause()==null? e : e.getCause());
}
}
@@ -4,6 +4,8 @@ package com.seibel.lod.common.wrappers.worldGeneration;
import com.mojang.datafixers.DataFixer;
import com.seibel.lod.core.builders.lodBuilding.LodBuilder;
import com.seibel.lod.core.objects.lod.LodDimension;
import com.seibel.lod.core.util.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
@@ -14,6 +16,9 @@ import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeManager;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.chunk.storage.ChunkScanAccess;
import net.minecraft.world.level.levelgen.DebugLevelSource;
import net.minecraft.world.level.levelgen.FlatLevelSource;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
import net.minecraft.world.level.levelgen.WorldGenSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
import net.minecraft.world.level.storage.WorldData;
@@ -14,6 +14,8 @@ import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.ProtoChunk;
import net.minecraft.world.level.levelgen.DebugLevelSource;
import net.minecraft.world.level.levelgen.FlatLevelSource;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
import net.minecraft.world.level.levelgen.blending.Blender;
@@ -32,17 +34,7 @@ public final class StepBiomes {
}
public final ChunkStatus STATUS = ChunkStatus.BIOMES;
private ChunkAccess createBiomes(ChunkGenerator generator, Registry<Biome> registry, Blender blender, StructureFeatureManager structureFeatureManager, ChunkAccess chunkAccess) {
if (generator instanceof NoiseBasedChunkGenerator) {
((NoiseBasedChunkGenerator) generator).doCreateBiomes(registry, blender, structureFeatureManager, chunkAccess);
return chunkAccess;
} else {
chunkAccess.fillBiomesFromNoise(generator.getBiomeSource()::getNoiseBiome, generator.climateSampler());
return chunkAccess;
}
}
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion,
List<ChunkAccess> chunks) {
@@ -56,8 +48,8 @@ public final class StepBiomes {
for (ChunkAccess chunk : chunksToDo) {
// System.out.println("StepBiomes: "+chunk.getPos());
chunk = createBiomes(environment.params.generator, environment.params.biomes, Blender.of(worldGenRegion),
tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk);
chunk = environment.joinSync(environment.params.generator.createBiomes(environment.params.biomes, Runnable::run, Blender.of(worldGenRegion),
tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk));
}
}
}
@@ -52,6 +52,7 @@ public final class StepLight {
} catch (Exception e) {
e.printStackTrace();
}
if (chunk instanceof LevelChunk) ((LevelChunk)chunk).setClientLightReady(true);
chunk.setLightCorrect(true);
}
lightEngine.runUpdates(Integer.MAX_VALUE, true, true);
@@ -35,36 +35,7 @@ public final class StepNoise {
environment = batchGenerationEnvironment;
}
private static <T> T joinSync(CompletableFuture<T> f) {
if (!f.isDone()) throw new RuntimeException("The future is concurrent!");
return f.join();
}
public final ChunkStatus STATUS = ChunkStatus.NOISE;
private ChunkAccess NoiseBased$fillFromNoise(NoiseBasedChunkGenerator generator, Blender blender, StructureFeatureManager structureFeatureManager, ChunkAccess chunkAccess) {
NoiseSettings noiseSettings = generator.settings.get().noiseSettings();
LevelHeightAccessor levelHeightAccessor = chunkAccess.getHeightAccessorForGeneration();
int i = Math.max(noiseSettings.minY(), levelHeightAccessor.getMinBuildHeight());
int j = Math.min(noiseSettings.minY() + noiseSettings.height(), levelHeightAccessor.getMaxBuildHeight());
int k = Mth.intFloorDiv(i, noiseSettings.getCellHeight());
int l = Mth.intFloorDiv(j - i, noiseSettings.getCellHeight());
if (l <= 0) {
return chunkAccess;
}
int m = chunkAccess.getSectionIndex(l * noiseSettings.getCellHeight() - 1 + i);
int n = chunkAccess.getSectionIndex(i);
HashSet<LevelChunkSection> set = Sets.newHashSet();
for (int o = m; o >= n; --o) {
LevelChunkSection levelChunkSection = chunkAccess.getSection(o);
levelChunkSection.acquire();
set.add(levelChunkSection);
}
chunkAccess = generator.doFill(blender, structureFeatureManager, chunkAccess, k, l);
for (LevelChunkSection levelChunkSection : set) {
levelChunkSection.release();
};
return chunkAccess;
}
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion,
List<ChunkAccess> chunks) {
@@ -79,13 +50,8 @@ public final class StepNoise {
for (ChunkAccess chunk : chunksToDo) {
// System.out.println("StepNoise: "+chunk.getPos());
if (environment.params.generator instanceof NoiseBasedChunkGenerator) {
chunk = NoiseBased$fillFromNoise((NoiseBasedChunkGenerator)environment.params.generator,Blender.of(worldGenRegion),
tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk);
} else {
chunk = joinSync(environment.params.generator.fillFromNoise(Runnable::run, Blender.of(worldGenRegion),
chunk = environment.joinSync(environment.params.generator.fillFromNoise(Runnable::run, Blender.of(worldGenRegion),
tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk));
}
}
}
}
@@ -35,44 +35,6 @@ public final class StepStructureReference {
public final ChunkStatus STATUS = ChunkStatus.STRUCTURE_REFERENCES;
private void createReferences(WorldGenRegion worldGenLevel, StructureFeatureManager structureFeatureManager,
ChunkAccess chunkAccess) {
ChunkPos chunkPos = chunkAccess.getPos();
int j = chunkPos.x;
int k = chunkPos.z;
int l = chunkPos.getMinBlockX();
int m = chunkPos.getMinBlockZ();
SectionPos sectionPos = SectionPos.bottomOf(chunkAccess);
for (int n = j - 8; n <= j + 8; n++) {
for (int o = k - 8; o <= k + 8; o++) {
if (!worldGenLevel.hasChunk(n, o))
continue;
long p = ChunkPos.asLong(n, o);
for (StructureStart<?> structureStart : worldGenLevel.getChunk(n, o).getAllStarts().values()) {
try {
if (structureStart.isValid()
&& structureStart.getBoundingBox().intersects(l, m, l + 15, m + 15)) {
structureFeatureManager.addReferenceForFeature(sectionPos, structureStart.getFeature(),
p, chunkAccess);
}
} catch (Exception exception) {
CrashReport crashReport = CrashReport.forThrowable(exception,
"Generating structure reference");
CrashReportCategory crashReportCategory = crashReport.addCategory("Structure");
crashReportCategory.setDetail("Id",
() -> Registry.STRUCTURE_FEATURE.getKey(structureStart.getFeature()).toString());
crashReportCategory.setDetail("Name", () -> structureStart.getFeature().getFeatureName());
crashReportCategory.setDetail("Class",
() -> structureStart.getFeature().getClass().getCanonicalName());
throw new ReportedException(crashReport);
}
}
}
}
}
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion,
List<ChunkAccess> chunks) {
@@ -86,7 +48,7 @@ public final class StepStructureReference {
for (ChunkAccess chunk : chunksToDo) {
// System.out.println("StepStructureReference: "+chunk.getPos());
createReferences(worldGenRegion, tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk);
environment.params.generator.createReferences(worldGenRegion, tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk);
}
}
}
+1 -1
Submodule core updated: 67f12c136c...fd81a8e067
+11 -5
View File
@@ -24,6 +24,12 @@ repositories {
maven { url "https://maven.terraformersmc.com/" }
}
def addMod(path, enabled) {
if (enabled == "2")
dependencies { modImplementation(path) }
else if (enabled == "1")
dependencies { modCompileOnly(path) }
}
dependencies {
// Fabric loader
@@ -38,20 +44,20 @@ dependencies {
}
// Starlight
// modImplementation "curse.maven:starlight-521783:${rootProject.starlight_version_fabric}"
addMod("curse.maven:starlight-521783:${rootProject.starlight_version_fabric}", rootProject.enable_starlight)
// Sodium
modImplementation "curse.maven:sodium-394468:${rootProject.sodium_version}"
addMod("curse.maven:sodium-394468:${rootProject.sodium_version}", rootProject.enable_sodium)
implementation "org.joml:joml:1.10.2"
// Lithium
// modImplementation "maven.modrinth:lithium:${rootProject.lithium_version}"
addMod("maven.modrinth:lithium:${rootProject.lithium_version}", rootProject.enable_lithium)
// Iris
// modImplementation "maven.modrinth:iris:${rootProject.iris_version}"
addMod("maven.modrinth:iris:${rootProject.iris_version}", rootProject.enable_iris)
// BCLib
// modImplementation "com.github.paulevsGitch:BCLib:${rootProject.bclib_version}"
addMod("com.github.paulevsGitch:BCLib:${rootProject.bclib_version}", rootProject.enable_bclib)
// Immersive Portals
/*
@@ -0,0 +1,52 @@
package com.seibel.lod.fabric.mixins;
import java.util.concurrent.ExecutorService;
import java.util.function.Supplier;
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.CallbackInfoReturnable;
import com.seibel.lod.common.wrappers.DependencySetupDoneCheck;
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
import com.seibel.lod.core.api.ClientApi;
import com.seibel.lod.core.util.DummyRunExecutorService;
import net.minecraft.Util;
@Mixin(Util.class)
public class MixinUtilBackgroudThread
{
@Inject(method = "wrapThreadWithTaskName(Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Runnable;",
at = @At("HEAD"), cancellable = true)
private static void overrideUtil$wrapThreadWithTaskName(String string, Runnable r, CallbackInfoReturnable<Runnable> ci)
{
if (DependencySetupDoneCheck.isDone && BatchGenerationEnvironment.isCurrentThreadDistantGeneratorThread())
{
//ClientApi.LOGGER.info("util wrapThreadWithTaskName(Runnable) triggered");
ci.setReturnValue(r);
}
}
@Inject(method = "wrapThreadWithTaskName(Ljava/lang/String;Ljava/util/function/Supplier;)Ljava/util/function/Supplier;",
at = @At("HEAD"), cancellable = true)
private static void overrideUtil$wrapThreadWithTaskNameForSupplier(String string, Supplier<?> r, CallbackInfoReturnable<Supplier<?>> ci)
{
if (DependencySetupDoneCheck.isDone && BatchGenerationEnvironment.isCurrentThreadDistantGeneratorThread())
{
//ClientApi.LOGGER.info("util wrapThreadWithTaskName(Supplier) triggered");
ci.setReturnValue(r);
}
}
@Inject(method = "backgroundExecutor", at = @At("HEAD"), cancellable = true)
private static void overrideUtil$backgroundExecutor(CallbackInfoReturnable<ExecutorService> ci)
{
if (DependencySetupDoneCheck.isDone && BatchGenerationEnvironment.isCurrentThreadDistantGeneratorThread())
{
//ClientApi.LOGGER.info("util backgroundExecutor triggered");
ci.setReturnValue(new DummyRunExecutorService());
}
}
}
@@ -1,5 +1,7 @@
package com.seibel.lod.fabric.wrappers;
import com.seibel.lod.common.LodCommonMain;
import com.seibel.lod.common.wrappers.config.NewLodConfigWrapperSingleton;
import com.seibel.lod.core.util.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.common.wrappers.config.LodConfigWrapperSingleton;
@@ -18,6 +20,9 @@ public class DependencySetup
{
public static void createInitialBindings()
{
SingletonHandler.bind(ILodConfigWrapperSingleton.class, LodConfigWrapperSingleton.INSTANCE);
if (!LodCommonMain.IsNewConfig)
SingletonHandler.bind(ILodConfigWrapperSingleton.class, LodConfigWrapperSingleton.INSTANCE);
else
SingletonHandler.bind(ILodConfigWrapperSingleton.class, NewLodConfigWrapperSingleton.INSTANCE);
}
}
@@ -5,6 +5,7 @@
"compatibilityLevel": "JAVA_17",
"mixins": [
"unsafe.MixinThreadingDectector",
"MixinUtilBackgroudThread",
"events.MixinServerLevel"
],
"client": [
+2 -2
View File
@@ -9,8 +9,8 @@
"contact": {
"homepage": "${homepage}",
"sources": "https://gitlab.com/jeseibel/minecraft-lod-mod/",
"issues": "https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues"
"sources": "${source}",
"issues": "${issues}"
},
"license": "CC0-1.0",
+9 -2
View File
@@ -25,13 +25,20 @@ configurations {
developmentForge.extendsFrom common
}
def addMod(path, enabled) {
if (enabled == "2")
dependencies { modImplementation(path) }
else if (enabled == "1")
dependencies { modCompileOnly(path) }
}
dependencies {
// Forge loader
forge "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}"
// Starlight
// modImplementation("curse.maven:starlight-forge-526854:${rootProject.starlight_version_forge}")
// annotationProcessor "org.spongepowered:mixin:0.8.4:processor"
addMod("curse.maven:starlight-forge-526854:${rootProject.starlight_version_forge}", rootProject.enable_starlight_forge)
annotationProcessor "org.spongepowered:mixin:0.8.4:processor"
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowMe(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }
@@ -0,0 +1,55 @@
package com.seibel.lod.forge.mixins;
import java.util.concurrent.ExecutorService;
import java.util.function.Supplier;
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.CallbackInfoReturnable;
import com.seibel.lod.common.wrappers.DependencySetupDoneCheck;
import com.seibel.lod.core.util.DummyRunExecutorService;
import net.minecraft.Util;
@Mixin(Util.class)
public class MixinUtilBackgroudThread
{
private static boolean shouldApplyOverride() {
return DependencySetupDoneCheck.getIsCurrentThreadDistantGeneratorThread.get();
}
@Inject(method = "wrapThreadWithTaskName(Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Runnable;",
at = @At("HEAD"), cancellable = true)
private static void overrideUtil$wrapThreadWithTaskName(String string, Runnable r, CallbackInfoReturnable<Runnable> ci)
{
if (DependencySetupDoneCheck.isDone && shouldApplyOverride())
{
//ClientApi.LOGGER.info("util wrapThreadWithTaskName(Runnable) triggered");
ci.setReturnValue(r);
}
}
@Inject(method = "wrapThreadWithTaskName(Ljava/lang/String;Ljava/util/function/Supplier;)Ljava/util/function/Supplier;",
at = @At("HEAD"), cancellable = true)
private static void overrideUtil$wrapThreadWithTaskNameForSupplier(String string, Supplier<?> r, CallbackInfoReturnable<Supplier<?>> ci)
{
if (DependencySetupDoneCheck.isDone && shouldApplyOverride())
{
//ClientApi.LOGGER.info("util wrapThreadWithTaskName(Supplier) triggered");
ci.setReturnValue(r);
}
}
@Inject(method = "backgroundExecutor", at = @At("HEAD"), cancellable = true)
private static void overrideUtil$backgroundExecutor(CallbackInfoReturnable<ExecutorService> ci)
{
if (DependencySetupDoneCheck.isDone && shouldApplyOverride())
{
//ClientApi.LOGGER.info("util backgroundExecutor triggered");
ci.setReturnValue(new DummyRunExecutorService());
}
}
}
@@ -1,6 +1,8 @@
package com.seibel.lod.forge.wrappers;
import com.seibel.lod.common.LodCommonMain;
import com.seibel.lod.common.wrappers.config.LodConfigWrapperSingleton;
import com.seibel.lod.common.wrappers.config.NewLodConfigWrapperSingleton;
import com.seibel.lod.core.util.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
@@ -18,6 +20,9 @@ public class ForgeDependencySetup
{
public static void createInitialBindings()
{
SingletonHandler.bind(ILodConfigWrapperSingleton.class, LodConfigWrapperSingleton.INSTANCE);
if (!LodCommonMain.IsNewConfig)
SingletonHandler.bind(ILodConfigWrapperSingleton.class, LodConfigWrapperSingleton.INSTANCE);
else
SingletonHandler.bind(ILodConfigWrapperSingleton.class, NewLodConfigWrapperSingleton.INSTANCE);
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
modLoader="javafml" #//mandatory
loaderVersion="[37,40)" # // mandatory. This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
license="GNU GPLv3"
issueTrackerURL="https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues"
issueTrackerURL="${issues}"
[[mods]] #//mandatory
+1
View File
@@ -4,6 +4,7 @@
"package": "com.seibel.lod.forge.mixins",
"compatibilityLevel": "JAVA_17",
"mixins": [
"MixinUtilBackgroudThread"
],
"client": [
"MixinOptionsScreen",
+25 -7
View File
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx2048M
minecraft_version=1.18.1
archives_base_name=DistantHorizons
mod_version=1.6.0a
mod_version=1.6.2a
maven_group=com.seibel.lod
toml_version=3.6.4
@@ -12,20 +12,38 @@ mod_name=Distant Horizons
mod_description=This mod generates and renders simplified terrain beyond the normal view distance at a low performance cost. Allowing you to see much farther without turning your game into a slideshow.
mod_authors=James Seibel, Leonardo Amato, Cola, coolGi2007, Ran, Leetom
mod_homepage=https://www.curseforge.com/minecraft/mc-mods/distant-horizons
mod_source=https://gitlab.com/jeseibel/minecraft-lod-mod/
mod_issues=https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues
# Fabric loader
fabric_loader_version=0.12.12
fabric_api_version=0.44.0+1.18
# Fabric mods
fabric_loader_version=0.13.1
fabric_api_version=0.46.4+1.18
# Fabric mod versions
modmenu_version=3.0.0
starlight_version_fabric=3554912
lithium_version=mc1.18.1-0.7.7
sodium_version=3605309
iris_version=1.18.x-v1.1.4
bclib_version=1.2.5
immersive_portals_version = v1.0.4-1.18
bclib_version=1.2.5
# Fabric mod run
# 0 = Don't enable and don't run
# 1 = Can be referenced in code but doesn't run
# 2 = Can be referenced in code and runs in client
enable_starlight=0
enable_sodium=1
enable_lithium=0
enable_iris=0
enable_bclib=0
# Forge loader
forge_version=39.0.44
# Forge mods
forge_version=39.0.76
# Forge mod versions
starlight_version_forge=3559934
# Forge mod run
# 0 = Dont enable and don't run
# 1 = Can be referenced in code but doesn't run
# 2 = Can be referenced in code and runs in client
enable_starlight_forge=0