supplier) {
+ return parent.getBlockFloorHeight(voxelShape, supplier);
+ }
+
+ @Override
+ public double getBlockFloorHeight(BlockPos blockPos) {
+ return parent.getBlockFloorHeight(blockPos);
+ }
+
+ @Override
+ public int getHeight() {
+ return parent.getHeight();
+ }
+
+ @Override
+ public int getMinBuildHeight() {
+ return parent.getMinBuildHeight();
+ }
+
+ @Override
+ public int getMaxBuildHeight() {
+ return parent.getMaxBuildHeight();
+ }
+
+ @Override
+ public int getSectionsCount() {
+ return parent.getSectionsCount();
+ }
+
+ @Override
+ public int getMinSection() {
+ return parent.getMinSection();
+ }
+
+ @Override
+ public int getMaxSection() {
+ return parent.getMaxSection();
+ }
+
+ @Override
+ public boolean isOutsideBuildHeight(BlockPos blockPos) {
+ return parent.isOutsideBuildHeight(blockPos);
+ }
+
+ @Override
+ public boolean isOutsideBuildHeight(int i) {
+ return parent.isOutsideBuildHeight(i);
+ }
+
+ @Override
+ public int getSectionIndex(int i) {
+ return parent.getSectionIndex(i);
+ }
+
+ @Override
+ public int getSectionIndexFromSectionY(int i) {
+ return parent.getSectionIndexFromSectionY(i);
+ }
+
+ @Override
+ public int getSectionYFromSectionIndex(int i) {
+ return parent.getSectionYFromSectionIndex(i);
+ }
+}
diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java
index f499d7a05..312f6636d 100644
--- a/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java
+++ b/common/src/main/java/com/seibel/lod/common/wrappers/chunk/ChunkWrapper.java
@@ -1,40 +1,47 @@
package com.seibel.lod.common.wrappers.chunk;
import com.seibel.lod.common.wrappers.block.BlockDetailWrapper;
-import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.LightedWorldGenRegion;
+import com.seibel.lod.core.enums.LodDirection;
import com.seibel.lod.core.util.LevelPosUtil;
import com.seibel.lod.core.util.LodUtil;
+import com.seibel.lod.core.wrapperInterfaces.block.IBlockDetailWrapper;
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IBiomeWrapper;
+
import com.seibel.lod.common.wrappers.WrapperUtil;
import com.seibel.lod.common.wrappers.block.BlockDetailMap;
import com.seibel.lod.common.wrappers.world.BiomeWrapper;
+import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.LightedWorldGenRegion;
import net.minecraft.core.BlockPos;
import net.minecraft.core.QuartPos;
-import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.LightLayer;
-import net.minecraft.world.level.block.Block;
-import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.LiquidBlockContainer;
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkStatus;
-import net.minecraft.world.level.chunk.LevelChunkSection;
+import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.levelgen.Heightmap;
/**
*
* @author James Seibel
- * @version 11-21-2021
+ * @version 3-5-2022
*/
public class ChunkWrapper implements IChunkWrapper
{
- private ChunkAccess chunk;
- private LevelReader lightSource;
+ private final ChunkAccess chunk;
+ private final LevelReader lightSource;
+
+
+ public ChunkWrapper(ChunkAccess chunk, LevelReader lightSource)
+ {
+ this.chunk = chunk;
+ this.lightSource = lightSource;
+ }
@Override
public int getHeight(){
@@ -66,23 +73,27 @@ public class ChunkWrapper implements IChunkWrapper
}
@Override
- public BlockDetailWrapper getBlockDetail(int x, int y, int z) {
+ public IBlockDetailWrapper getBlockDetail(int x, int y, int z) {
BlockPos pos = new BlockPos(x,y,z);
BlockState blockState = chunk.getBlockState(pos);
- BlockDetailWrapper blockDetail = BlockDetailMap.getOrMakeBlockDetailCache(blockState, pos, lightSource);
+ IBlockDetailWrapper blockDetail = BlockDetailMap.getOrMakeBlockDetailCache(blockState, pos, lightSource);
return blockDetail == BlockDetailWrapper.NULL_BLOCK_DETAIL ? null : blockDetail;
}
- @Deprecated
- public ChunkWrapper(ChunkAccess chunk)
- {
- this.chunk = chunk;
- this.lightSource = null;
- }
- public ChunkWrapper(ChunkAccess chunk, LevelReader lightSource)
- {
- this.chunk = chunk;
- this.lightSource = lightSource;
+ @Override
+ public IBlockDetailWrapper getBlockDetailAtFace(int x, int y, int z, LodDirection dir) {
+ int fy = y+dir.getNormal().y;
+ if (fy < getMinBuildHeight() || fy > getMaxBuildHeight()) return null;
+ BlockPos pos = new BlockPos(x+dir.getNormal().x,fy,z+dir.getNormal().z);
+ BlockState blockState;
+ if (blockPosInsideChunk(x,y,z))
+ blockState = chunk.getBlockState(pos);
+ else {
+ blockState = lightSource.getBlockState(pos);
+ }
+ if (blockState == null || blockState.isAir()) return null;
+ IBlockDetailWrapper blockDetail = BlockDetailMap.getOrMakeBlockDetailCache(blockState, pos, lightSource);
+ return blockDetail == BlockDetailWrapper.NULL_BLOCK_DETAIL ? null : blockDetail;
}
public ChunkAccess getChunk() {
@@ -101,12 +112,12 @@ public class ChunkWrapper implements IChunkWrapper
@Override
public int getRegionPosX(){
- return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, getChunkPosX(), LodUtil.REGION_DETAIL_LEVEL);
+ return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunk.getPos().x, LodUtil.REGION_DETAIL_LEVEL);
}
@Override
public int getRegionPosZ(){
- return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, getChunkPosZ(), LodUtil.REGION_DETAIL_LEVEL);
+ return LevelPosUtil.convert(LodUtil.CHUNK_DETAIL_LEVEL, chunk.getPos().z, LodUtil.REGION_DETAIL_LEVEL);
}
@Override
@@ -131,15 +142,19 @@ public class ChunkWrapper implements IChunkWrapper
return chunk.getPos().getMinBlockZ();
}
- @Override
- public long getLongChunkPos() {
- return chunk.getPos().toLong();
- }
+ @Override
+ public long getLongChunkPos() {
+ return chunk.getPos().toLong();
+ }
@Override
public boolean isLightCorrect(){
- return true;
- //return chunk.isLightCorrect();
+ return true;
+ // TODO
+// if (chunk instanceof LevelChunk) {
+// return ((LevelChunk) chunk).isClientLightReady();
+// }
+// return chunk.isLightCorrect();
}
public boolean isWaterLogged(int x, int y, int z)
@@ -166,7 +181,7 @@ public class ChunkWrapper implements IChunkWrapper
@Override
public int getSkyLight(int x, int y, int z) {
if (lightSource == null) return -1;
- return lightSource.getBrightness(LightLayer.SKY, new BlockPos(x, y, z));
+ return lightSource.getBrightness(LightLayer.SKY, new BlockPos(x,y,z));
}
@Override
@@ -185,4 +200,5 @@ public class ChunkWrapper implements IChunkWrapper
{
return lightSource;
}
+
}
diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/config/ConfigGui.java b/common/src/main/java/com/seibel/lod/common/wrappers/config/ConfigGui.java
index 37745722b..07442ac97 100644
--- a/common/src/main/java/com/seibel/lod/common/wrappers/config/ConfigGui.java
+++ b/common/src/main/java/com/seibel/lod/common/wrappers/config/ConfigGui.java
@@ -607,6 +607,7 @@ public abstract class ConfigGui
else if (info.screenButton)
{
Button widget = new Button(this.width / 2 - info.width, this.height - 28, info.width * 2, 20, name, (button -> {
+ saveToFile();
Objects.requireNonNull(minecraft).setScreen(ConfigGui.getScreen(this, info.gotoScreen));
}));
this.list.addButton(widget, null, null, null);
diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java
index 9c16205a4..7ab313a84 100644
--- a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java
+++ b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java
@@ -3,7 +3,6 @@ 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.wrapperInterfaces.config.ILodConfigWrapperSingleton.IClient.IMultiplayer;
import com.seibel.lod.common.Config;
/**
@@ -185,7 +184,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.graphics.quality.horizontalQuality").value = newHorizontalQuality;
ConfigGui.editSingleOption.saveOption("client.graphics.quality.horizontalQuality");
}
-
+
@Override
public DropoffQuality getDropoffQuality() {
return Config.Client.Graphics.Quality.dropoffQuality;
@@ -195,11 +194,29 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.graphics.quality.dropoffQuality").value = newDropoffQuality;
ConfigGui.editSingleOption.saveOption("client.graphics.quality.dropoffQuality");
}
+
+ @Override
+ public int getLodBiomeBlending() {
+ return Config.Client.Graphics.Quality.lodBiomeBlending;
+ }
+
+ @Override
+ public void setLodBiomeBlending(int newLodBiomeBlending) {
+ ConfigGui.editSingleOption.getEntry("client.graphics.quality.lodBiomeBlending").value = newLodBiomeBlending;
+ ConfigGui.editSingleOption.saveOption("client.graphics.quality.lodBiomeBlending");
+ }
}
public static class FogQuality implements IFogQuality
{
+ public final IAdvancedFog advancedFog;
+
+ FogQuality()
+ {
+ advancedFog = new AdvancedFog();
+ }
+
@Override
public FogDistance getFogDistance()
{
@@ -252,6 +269,167 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.disableVanillaFog").value = newDisableVanillaFog;
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.disableVanillaFog");
}
+
+ @Override
+ public IAdvancedFog advancedFog() {
+ return advancedFog;
+ }
+
+ public static class AdvancedFog implements IAdvancedFog {
+ public final IHeightFog heightFog;
+
+ public AdvancedFog() {
+ heightFog = new HeightFog();
+ }
+
+ @Override
+ public double getFarFogStart() {
+ return Config.Client.Graphics.FogQuality.AdvancedFog.farFogStart;
+ }
+ @Override
+ public double getFarFogEnd() {
+ return Config.Client.Graphics.FogQuality.AdvancedFog.farFogEnd;
+ }
+ @Override
+ public double getFarFogMin() {
+ return Config.Client.Graphics.FogQuality.AdvancedFog.farFogMin;
+ }
+ @Override
+ public double getFarFogMax() {
+ return Config.Client.Graphics.FogQuality.AdvancedFog.farFogMax;
+ }
+ @Override
+ public FogSetting.FogType getFarFogType() {
+ return Config.Client.Graphics.FogQuality.AdvancedFog.farFogType;
+ }
+ @Override
+ public double getFarFogDensity() {
+ return Config.Client.Graphics.FogQuality.AdvancedFog.farFogDensity;
+ }
+
+ @Override
+ public void setFarFogStart(double newFarFogStart) {
+ ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogStart").value = newFarFogStart;
+ ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogStart");
+ }
+ @Override
+ public void setFarFogEnd(double newFarFogEnd) {
+ ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogEnd").value = newFarFogEnd;
+ ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogEnd");
+ }
+ @Override
+ public void setFarFogMin(double newFarFogMin) {
+ ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogMin").value = newFarFogMin;
+ ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogMin");
+ }
+ @Override
+ public void setFarFogMax(double newFarFogMax) {
+ ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogMax").value = newFarFogMax;
+ ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogMax");
+ }
+ @Override
+ public void setFarFogType(FogSetting.FogType newFarFogType) {
+ ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogType").value = newFarFogType;
+ ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogType");
+ }
+ @Override
+ public void setFarFogDensity(double newFarFogDensity) {
+ ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.farFogDensity").value = newFarFogDensity;
+ ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.farFogDensity");
+ }
+
+ @Override
+ public IHeightFog heightFog() {
+ return heightFog;
+ }
+
+ public static class HeightFog implements IHeightFog {
+
+ @Override
+ public HeightFogMixMode getHeightFogMixMode() {
+ return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMixMode;
+ }
+ @Override
+ public HeightFogMode getHeightFogMode() {
+ return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMode;
+ }
+ @Override
+ public double getHeightFogHeight() {
+ return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogHeight;
+ }
+ @Override
+ public double getHeightFogStart() {
+ return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogStart;
+ }
+ @Override
+ public double getHeightFogEnd() {
+ return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogEnd;
+ }
+ @Override
+ public double getHeightFogMin() {
+ return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMin;
+ }
+ @Override
+ public double getHeightFogMax() {
+ return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogMax;
+ }
+ @Override
+ public FogSetting.FogType getHeightFogType() {
+ return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogType;
+ }
+ @Override
+ public double getHeightFogDensity() {
+ return Config.Client.Graphics.FogQuality.AdvancedFog.heightFog.heightFogDensity;
+ }
+
+ @Override
+ public void setHeightFogMixMode(HeightFogMixMode newHeightFogMixMode) {
+ ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMixMode").value = newHeightFogMixMode;
+ ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMixMode");
+ }
+ @Override
+ public void setHeightFogMode(HeightFogMode newHeightFogMode) {
+ ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMode").value = newHeightFogMode;
+ ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMode");
+ }
+ @Override
+ public void setHeightFogHeight(double newHeightFogHeight) {
+ ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogHeight").value = newHeightFogHeight;
+ ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogHeight");
+ }
+ @Override
+ public void setHeightFogStart(double newHeightFogStart) {
+ ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogStart").value = newHeightFogStart;
+ ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogStart");
+ }
+ @Override
+ public void setHeightFogEnd(double newHeightFogEnd) {
+ ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogEnd").value = newHeightFogEnd;
+ ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogEnd");
+ }
+ @Override
+ public void setHeightFogMin(double newHeightFogMin) {
+ ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMin").value = newHeightFogMin;
+ ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMin");
+ }
+ @Override
+ public void setHeightFogMax(double newHeightFogMax) {
+ ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogMax").value = newHeightFogMax;
+ ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogMax");
+ }
+ @Override
+ public void setHeightFogType(FogSetting.FogType newHeightFogType) {
+ ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogType").value = newHeightFogType;
+ ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogType");
+ }
+ @Override
+ public void setHeightFogDensity(double newHeightFogDensity) {
+ ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.advancedFog.heightFog.heightFogDensity").value = newHeightFogDensity;
+ ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.advancedFog.heightFog.heightFogDensity");
+ }
+ }
+ }
+
}
@@ -269,6 +447,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.disableDirectionalCulling");
}
+
@Override
public VanillaOverdraw getVanillaOverdraw()
{
@@ -280,6 +459,17 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.vanillaOverdraw").value = newVanillaOverdraw;
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.vanillaOverdraw");
}
+
+ @Override
+ public int getOverdrawOffset() {
+ return Config.Client.Graphics.AdvancedGraphics.overdrawOffset;
+ }
+
+ @Override
+ public void setOverdrawOffset(int newOverdrawOffset) {
+ ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.overdrawOffset").value = newOverdrawOffset;
+ ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.overdrawOffset");
+ }
/*
@Override
public int getBacksideCullingRange()
@@ -292,7 +482,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.backsideCullingRange").value = newBacksideCullingRange;
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.backsideCullingRange");
}*/
-
+
@Override
public boolean getUseExtendedNearClipPlane()
{
@@ -328,6 +518,30 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.saturationMultiplier").value = newSaturationMultiplier;
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.saturationMultiplier");
}
+
+ @Override
+ public boolean getEnableCaveCulling() {
+ return Config.Client.Graphics.AdvancedGraphics.enableCaveCulling;
+ }
+
+ @Override
+ public void setEnableCaveCulling(boolean newEnableCaveCulling) {
+ ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.enableCaveCulling").value = newEnableCaveCulling;
+ ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.enableCaveCulling");
+
+ }
+
+ @Override
+ public int getCaveCullingHeight() {
+ return Config.Client.Graphics.AdvancedGraphics.caveCullingHeight;
+ }
+
+ @Override
+ public void setCaveCullingHeight(int newCaveCullingHeight) {
+ ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.caveCullingHeight").value = newCaveCullingHeight;
+ ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.caveCullingHeight");
+
+ }
}
}
@@ -364,6 +578,20 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.saveOption("client.worldGenerator.distanceGenerationMode");
}
+ /*
+ @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()
{
@@ -418,7 +646,18 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.saveOption("client.multiplayer.serverFolderNameMode");
}
+ @Override
+ public double getMultiDimensionRequiredSimilarity()
+ {
+ return Config.Client.Multiplayer.multiDimensionRequiredSimilarity;
+ }
+ @Override
+ public void setMultiDimensionRequiredSimilarity(double newMultiDimensionMinimumSimilarityPercent)
+ {
+ ConfigGui.editSingleOption.getEntry("client.multiplayer.multiDimensionMinimumSimilarityPercent").value = newMultiDimensionMinimumSimilarityPercent;
+ ConfigGui.editSingleOption.saveOption("client.multiplayer.multiDimensionMinimumSimilarityPercent");
+ }
}
@@ -497,18 +736,28 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
//===============//
public static class Debugging implements IDebugging
{
+ public final IDebugSwitch debugSwitch;
+
@Override
- public boolean getDrawLods()
+ public IDebugSwitch debugSwitch()
{
- return (boolean) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.drawLods").value;
- }
- @Override
- public void setDrawLods(boolean newDrawLods)
- {
- ConfigGui.editSingleOption.getEntry("client.advanced.debugging.drawLods").value = newDrawLods;
- ConfigGui.editSingleOption.saveOption("client.advanced.debugging.drawLods");
+ return debugSwitch;
}
+ /* RendererType:
+ * DEFAULT
+ * DEBUG
+ * DISABLED
+ * */
+ @Override
+ public RendererType getRendererType() {
+ return (RendererType) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.rendererType").value;
+ }
+ @Override
+ public void setRendererType(RendererType newRenderType) {
+ ConfigGui.editSingleOption.getEntry("client.advanced.debugging.rendererType").value = newRenderType;
+ ConfigGui.editSingleOption.saveOption("client.advanced.debugging.rendererType");
+ }
@Override
public DebugMode getDebugMode()
@@ -534,6 +783,116 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.advanced.debugging.enableDebugKeybindings").value = newEnableDebugKeybindings;
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.enableDebugKeybindings");
}
+
+ public Debugging()
+ {
+ debugSwitch = new DebugSwitch();
+ }
+
+ public static class DebugSwitch implements IDebugSwitch {
+
+ /* The logging switches available:
+ * WorldGenEvent
+ * WorldGenPerformance
+ * WorldGenLoadEvent
+ * LodBuilderEvent
+ * RendererBufferEvent
+ * RendererGLEvent
+ * FileReadWriteEvent
+ * FileSubDimEvent
+ * NetworkEvent //NOT IMPL YET
+ */
+
+ @Override
+ public LoggerMode getLogWorldGenEvent() {
+ return (LoggerMode) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logWorldGenEvent").value;
+ }
+ @Override
+ public void setLogWorldGenEvent(LoggerMode newLogWorldGenEvent) {
+ ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logWorldGenEvent").value = newLogWorldGenEvent;
+ ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugSwitch.logWorldGenEvent");
+ }
+
+ @Override
+ public LoggerMode getLogWorldGenPerformance() {
+ return (LoggerMode) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logWorldGenPerformance").value;
+ }
+ @Override
+ public void setLogWorldGenPerformance(LoggerMode newLogWorldGenPerformance) {
+ ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logWorldGenPerformance").value = newLogWorldGenPerformance;
+ ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugSwitch.logWorldGenPerformance");
+ }
+
+ @Override
+ public LoggerMode getLogWorldGenLoadEvent() {
+ return (LoggerMode) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logWorldGenLoadEvent").value;
+ }
+ @Override
+ public void setLogWorldGenLoadEvent(LoggerMode newLogWorldGenLoadEvent) {
+ ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logWorldGenLoadEvent").value = newLogWorldGenLoadEvent;
+ ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugSwitch.logWorldGenLoadEvent");
+ }
+
+ @Override
+ public LoggerMode getLogLodBuilderEvent() {
+ return (LoggerMode) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logLodBuilderEvent").value;
+ }
+ @Override
+ public void setLogLodBuilderEvent(LoggerMode newLogLodBuilderEvent) {
+ ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logLodBuilderEvent").value = newLogLodBuilderEvent;
+ ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugSwitch.logLodBuilderEvent");
+ }
+
+ @Override
+ public LoggerMode getLogRendererBufferEvent() {
+ return (LoggerMode) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logRendererBufferEvent").value;
+ }
+ @Override
+ public void setLogRendererBufferEvent(LoggerMode newLogRendererBufferEvent) {
+ ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logRendererBufferEvent").value = newLogRendererBufferEvent;
+ ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugSwitch.logRendererBufferEvent");
+ }
+
+ @Override
+ public LoggerMode getLogRendererGLEvent() {
+ return (LoggerMode) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logRendererGLEvent").value;
+ }
+ @Override
+ public void setLogRendererGLEvent(LoggerMode newLogRendererGLEvent) {
+ ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logRendererGLEvent").value = newLogRendererGLEvent;
+ ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugSwitch.logRendererGLEvent");
+ }
+
+ @Override
+ public LoggerMode getLogFileReadWriteEvent() {
+ return (LoggerMode) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logFileReadWriteEvent").value;
+ }
+ @Override
+ public void setLogFileReadWriteEvent(LoggerMode newLogFileReadWriteEvent) {
+ ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logFileReadWriteEvent").value = newLogFileReadWriteEvent;
+ ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugSwitch.logFileReadWriteEvent");
+ }
+
+ @Override
+ public LoggerMode getLogFileSubDimEvent() {
+ return (LoggerMode) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logFileSubDimEvent").value;
+ }
+ @Override
+ public void setLogFileSubDimEvent(LoggerMode newLogFileSubDimEvent) {
+ ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logFileSubDimEvent").value = newLogFileSubDimEvent;
+ ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugSwitch.logFileSubDimEvent");
+ }
+
+ @Override
+ public LoggerMode getLogNetworkEvent() {
+ return (LoggerMode) ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logNetworkEvent").value;
+ }
+ @Override
+ public void setLogNetworkEvent(LoggerMode newLogNetworkEvent) {
+ ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugSwitch.logNetworkEvent").value = newLogNetworkEvent;
+ ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugSwitch.logNetworkEvent");
+ }
+ }
}
@@ -577,6 +936,18 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.saveOption("client.advanced.buffers.newBufferRebuildTimes");
}
}
+
+ @Override
+ public boolean getLodOnlyMode() {
+ return Config.Client.Advanced.lodOnlyMode;
+ }
+
+ @Override
+ public void setLodOnlyMode(boolean newLodOnlyMode) {
+ ConfigGui.editSingleOption.getEntry("client.advanced.buffers.lodOnlyMode").value = newLodOnlyMode;
+ ConfigGui.editSingleOption.saveOption("client.advanced.buffers.lodOnlyMode");
+
+ }
}
}
}
diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftClientWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftClientWrapper.java
index 7d56db903..7835923cb 100644
--- a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftClientWrapper.java
+++ b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftClientWrapper.java
@@ -189,7 +189,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper
{
if (lightMap == null)
{
- sendChatMessage("new");
+ //sendChatMessage("new");
// make sure the lightMap is up-to-date
getCurrentLightMap();
}
@@ -197,22 +197,6 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper
return lightMap.getPixelRGBA(blockLight, skyLight);
}
- /**
- * Returns the Color at the given pixel coordinates
- * from the current lightmap.
- * @param blockLight x location in texture space
- * @param skyLight z location in texture space
- */
- @Override
- public Color getColorFromLightMap(int blockLight, int skyLight) {
- if (lightMap == null) {
- // make sure the lightMap is up-to-date
- getCurrentLightMap();
- }
-
- return LodUtil.intToColor(lightMap.getPixelRGBA(blockLight, skyLight));
- }
-
diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java
index 12ad0f893..b3df4daf9 100644
--- a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java
+++ b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java
@@ -2,19 +2,19 @@ package com.seibel.lod.common.wrappers.minecraft;
import java.awt.*;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.stream.Collectors;
+import com.mojang.blaze3d.pipeline.RenderTarget;
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.ApiShared;
import com.seibel.lod.core.api.ClientApi;
-import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorHandler;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
-import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
-import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
-import com.seibel.lod.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
+import com.seibel.lod.core.util.LodUtil;
+
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.client.renderer.LightTexture;
@@ -22,9 +22,11 @@ import com.mojang.math.Vector3f;
import com.seibel.lod.core.objects.math.Mat4f;
import com.seibel.lod.core.objects.math.Vec3d;
import com.seibel.lod.core.objects.math.Vec3f;
+import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
import com.seibel.lod.core.wrapperInterfaces.block.AbstractBlockPosWrapper;
import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
+import com.seibel.lod.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
import com.seibel.lod.common.wrappers.McObjectConverter;
import com.seibel.lod.common.wrappers.WrapperFactory;
@@ -57,7 +59,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
private static final Minecraft MC = Minecraft.getInstance();
private static final GameRenderer GAME_RENDERER = MC.gameRenderer;
- private static final WrapperFactory FACTORY = WrapperFactory.INSTANCE;
+ private static final IWrapperFactory FACTORY = WrapperFactory.INSTANCE;
@Override
public Vec3f getLookAtVector()
@@ -143,11 +145,32 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
return MC.getWindow().getHeight();
}
+ private RenderTarget getRenderTarget() {
+ RenderTarget r = null; //MC.levelRenderer.getCloudsTarget();
+ return r!=null ? r : MC.getMainRenderTarget();
+ }
+
+ @Override
+ public int getTargetFrameBuffer() {
+ return getRenderTarget().frameBufferId;
+ }
+
+ @Override
+ public int getTargetFrameBufferViewportWidth() {
+ return getRenderTarget().viewWidth;
+ }
+
+ @Override
+ public int getTargetFrameBufferViewportHeight() {
+ return getRenderTarget().viewHeight;
+ }
+
/**
* This method returns the ChunkPos of all chunks that Minecraft
* is going to render this frame.
*
*/
+
public boolean usingBackupGetVanillaRenderedChunks = false;
@Override
public HashSet getVanillaRenderedChunks()
@@ -161,36 +184,34 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
if (optifine != null)
{
HashSet pos = optifine.getNormalRenderedChunks();
- if (pos==null)
+ if (pos == null)
pos = getMaximumRenderedChunks();
return pos;
}
- if (!usingBackupGetVanillaRenderedChunks) {
- try {
- LevelRenderer levelRenderer = MC.levelRenderer;
- ObjectArrayList chunks = levelRenderer.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 {
- MinecraftClientWrapper.INSTANCE.sendChatMessage(
- "\u00A7e\u00A7l\u00A7uWARNING: Distant Horizons: getVanillaRenderedChunks method failed."
- + " Using Backup Method.");
- MinecraftClientWrapper.INSTANCE.sendChatMessage(
- "\u00A7eOverdraw prevention will be worse than normal.");
- } catch (Exception e2) {}
- ApiShared.LOGGER.error("getVanillaRenderedChunks Error: {}", e);
- usingBackupGetVanillaRenderedChunks = true;
- }
- }
- return getMaximumRenderedChunks();
-
+ if (!usingBackupGetVanillaRenderedChunks) {
+ try {
+ LevelRenderer levelRenderer = MC.levelRenderer;
+ ObjectArrayList chunks = levelRenderer.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 {
+ MinecraftClientWrapper.INSTANCE.sendChatMessage(
+ "\u00A7e\u00A7l\u00A7uWARNING: Distant Horizons: getVanillaRenderedChunks method failed."
+ + " Using Backup Method.");
+ MinecraftClientWrapper.INSTANCE.sendChatMessage(
+ "\u00A7eOverdraw prevention will be worse than normal.");
+ } catch (Exception e2) {}
+ ApiShared.LOGGER.error("getVanillaRenderedChunks Error: ", e);
+ usingBackupGetVanillaRenderedChunks = true;
+ }
+ }
+ return getMaximumRenderedChunks();
}
-
@Override
public int[] getLightmapPixels()
{
@@ -208,10 +229,10 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
{
for (int v = 0; v < lightMapWidth; v++)
{
- // this could probably be kept as an int, but
+ // this could probably be kept as a int, but
// it is easier to test and see the colors when debugging this way.
// When creating a new release this should be changed to the int version.
- Color c = LodUtil.intToColor(lightMap.getLightValue(u, v));
+ int col = lightMap.getLightValue(u, v);
// these should both create a totally white image
// int col =
@@ -222,11 +243,11 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
// (0b11111111 << 16) + // blue
// (0b11111111 << 24); // blue
- int col =
- ((c.getRed() & 0xFF) << 16) | // blue
- ((c.getGreen() & 0xFF) << 8) | // green
- ((c.getBlue() & 0xFF)) | // red
- ((c.getAlpha() & 0xFF) << 24); // alpha
+// int col =
+// ((c.getRed() & 0xFF) << 16) | // blue
+// ((c.getGreen() & 0xFF) << 8) | // green
+// ((c.getBlue() & 0xFF)) | // red
+// ((c.getAlpha() & 0xFF) << 24); // alpha
// 2D array stored in a 1D array.
// Thank you Tim from College ;)
@@ -292,13 +313,13 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
@Override
public boolean isFogStateSpecial() {
- Entity entity = GAME_RENDERER.getMainCamera().getEntity();
- boolean isBlind = (entity instanceof LivingEntity) && ((LivingEntity)entity).hasEffect(MobEffects.BLINDNESS);
- return GAME_RENDERER.getMainCamera().getFluidInCamera() != FogType.NONE || isBlind;
+ Entity entity = GAME_RENDERER.getMainCamera().getEntity();
+ boolean isBlind = (entity instanceof LivingEntity) && ((LivingEntity)entity).hasEffect(MobEffects.BLINDNESS);
+ return GAME_RENDERER.getMainCamera().getFluidInCamera() != FogType.NONE || isBlind;
}
- @Override
- public boolean tryDisableVanillaFog() {
- return true; // Handled via MixinFogRenderer in both Fabric and Forge
- }
+ @Override
+ public boolean tryDisableVanillaFog() {
+ return true; // Handled via MixinFogRenderer in both forge and fabric
+ }
}
diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/world/BiomeWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/world/BiomeWrapper.java
index 20cb22114..173969ae5 100644
--- a/common/src/main/java/com/seibel/lod/common/wrappers/world/BiomeWrapper.java
+++ b/common/src/main/java/com/seibel/lod/common/wrappers/world/BiomeWrapper.java
@@ -65,7 +65,7 @@ public class BiomeWrapper implements IBiomeWrapper
{
int colorInt;
- switch (biome.getBiomeCategory())
+ switch (biome.biomeCategory)
{
case NETHER:
@@ -110,9 +110,11 @@ public class BiomeWrapper implements IBiomeWrapper
case SAVANNA:
case SWAMP:
default:
- Color tmp = LodUtil.intToColor(biome.getGrassColor(x, z));
- tmp = tmp.darker();
- colorInt = LodUtil.colorToInt(tmp);
+ colorInt = biome.getGrassColor(x,z);
+ //FIXME: Repair what James did - LeeTom
+// Color tmp = LodUtil.intToColor(biome.getGrassColor(x, z));
+// tmp = tmp.darker();
+// colorInt = LodUtil.colorToInt(tmp);
break;
}
diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java
index 45a05362e..267c13d73 100644
--- a/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java
+++ b/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java
@@ -36,6 +36,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LightLayer;
import net.minecraft.world.level.chunk.ChunkAccess;
+import net.minecraft.world.level.chunk.ChunkSource;
import net.minecraft.world.level.chunk.ChunkStatus;
import org.jetbrains.annotations.Nullable;
@@ -175,5 +176,12 @@ public class WorldWrapper implements IWorldWrapper
return new ChunkWrapper(chunk, world);
}
+ @Override
+ public boolean hasChunkLoaded(int chunkX, int chunkZ) {
+ // world.hasChunk(chunkX, chunkZ); THIS DOES NOT WORK FOR CLIENT LEVEL CAUSE MOJANG ALWAYS RETURN TRUE FOR THAT!
+ ChunkSource source = world.getChunkSource();
+ return source.hasChunk(chunkX, chunkZ);
+ }
+
}
diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java
index be6eb2599..ab406e488 100644
--- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java
+++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java
@@ -25,10 +25,12 @@ import com.seibel.lod.core.builders.lodBuilding.LodBuilder;
import com.seibel.lod.core.builders.lodBuilding.LodBuilderConfig;
import com.seibel.lod.core.enums.config.DistanceGenerationMode;
import com.seibel.lod.core.enums.config.LightGenerationMode;
+import com.seibel.lod.core.logging.ConfigBasedLogger;
+import com.seibel.lod.core.logging.ConfigBasedSpamLogger;
import com.seibel.lod.core.objects.lod.LodDimension;
-import com.seibel.lod.core.util.GridList;
import com.seibel.lod.core.util.LodThreadFactory;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
+import com.seibel.lod.core.util.gridList.ArrayGridList;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper;
@@ -71,6 +73,7 @@ import net.minecraft.world.level.levelgen.FlatLevelSource;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.lighting.LevelLightEngine;
+import org.apache.logging.log4j.LogManager;
/*
Total: 3.135214124s
@@ -88,9 +91,16 @@ Lod Generation: 0.269023348s
public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnvionmentWrapper
{
- public static final boolean ENABLE_PERF_LOGGING = false;
- public static final boolean ENABLE_EVENT_LOGGING = false;
- public static final boolean ENABLE_LOAD_EVENT_LOGGING = false;
+ private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
+ public static final ConfigBasedSpamLogger PREF_LOGGER =
+ new ConfigBasedSpamLogger(LogManager.getLogger("LodWorldGen"),
+ () -> CONFIG.client().advanced().debugging().debugSwitch().getLogWorldGenPerformance(),1);
+ public static final ConfigBasedLogger EVENT_LOGGER =
+ new ConfigBasedLogger(LogManager.getLogger("LodWorldGen"),
+ () -> CONFIG.client().advanced().debugging().debugSwitch().getLogWorldGenEvent());
+ public static final ConfigBasedLogger LOAD_LOGGER =
+ new ConfigBasedLogger(LogManager.getLogger("LodWorldGen"),
+ () -> CONFIG.client().advanced().debugging().debugSwitch().getLogWorldGenLoadEvent());
//TODO: Make actual proper support for StarLight
public static class PrefEvent
@@ -191,7 +201,6 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
if (e.endNano != 0)
{
lodTime.add(e.endNano - preTime);
- preTime = e.endNano;
}
}
@@ -215,7 +224,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
//=================Generation Step===================
- public final LinkedList events = new LinkedList();
+ public final LinkedList events = new LinkedList<>();
public final GlobalParameters params;
public final StepStructureStart stepStructureStart = new StepStructureStart(this);
public final StepStructureReference stepStructureReference = new StepStructureReference(this);
@@ -226,16 +235,16 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
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 IMinecraftClientWrapper MC = SingletonHandler.get(IMinecraftClientWrapper.class);
public static final long EXCEPTION_TIMER_RESET_TIME = TimeUnit.NANOSECONDS.convert(1, TimeUnit.SECONDS);
public static final int EXCEPTION_COUNTER_TRIGGER = 20;
+ public static final int RANGE_TO_RANGE_EMPTY_EXTENSION = 1;
public int unknownExceptionCount = 0;
public long lastExceptionTriggerTime = 0;
public static final LodThreadFactory threadFactory = new LodThreadFactory("Gen-Worker-Thread", Thread.MIN_PRIORITY);
- public static ThreadLocal isDistantGeneratorThread = new ThreadLocal();
+ public static ThreadLocal isDistantGeneratorThread = new ThreadLocal<>();
public static boolean isCurrentThreadDistantGeneratorThread() {
return (isDistantGeneratorThread.get() != null);
@@ -250,9 +259,8 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
public T joinSync(CompletableFuture 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.");
- ApiShared.LOGGER.error("Unsafe Threading in Chunk Generator: ", new RuntimeException("Concurrent future"));
+ EVENT_LOGGER.error("Unsafe Threading in Chunk Generator: ", new RuntimeException("Concurrent future"));
+ EVENT_LOGGER.error("To increase stability, it is recommended to set world generation threads count to 1.");
unsafeThreadingRecorded = true;
}
return f.join();
@@ -300,8 +308,8 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
}
catch (Throwable e)
{
- ApiShared.LOGGER.error("Batching World Generator: Event {} gotten an exception", event);
- ApiShared.LOGGER.error("Exception: ", e);
+ EVENT_LOGGER.error("Batching World Generator: Event {} gotten an exception", event);
+ EVENT_LOGGER.error("Exception: ", e);
unknownExceptionCount++;
lastExceptionTriggerTime = System.nanoTime();
}
@@ -312,12 +320,12 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
}
else if (event.hasTimeout(TIMEOUT_SECONDS, TimeUnit.SECONDS))
{
- ApiShared.LOGGER.error("Batching World Generator: " + event + " timed out and terminated!");
- ApiShared.LOGGER.info("Dump PrefEvent: " + event.pEvent);
+ EVENT_LOGGER.error("Batching World Generator: " + event + " timed out and terminated!");
+ EVENT_LOGGER.info("Dump PrefEvent: " + event.pEvent);
try
{
if (!event.terminate())
- ApiShared.LOGGER.error("Failed to terminate the stuck generation event!");
+ EVENT_LOGGER.error("Failed to terminate the stuck generation event!");
}
finally
{
@@ -326,10 +334,7 @@ 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) {}
- ApiShared.LOGGER.error("Too many exceptions in Batching World Generator! Now disabling.");
+ EVENT_LOGGER.error("Too many exceptions in Batching World Generator! Disabling the generator.");
unknownExceptionCount = 0;
CONFIG.client().worldGenerator().setEnableDistantGeneration(false);
}
@@ -338,13 +343,13 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
public BatchGenerationEnvironment(IWorldWrapper serverlevel, LodBuilder lodBuilder, LodDimension lodDim)
{
super(serverlevel, lodBuilder, lodDim);
- ApiShared.LOGGER.info("================WORLD_GEN_STEP_INITING=============");
+ EVENT_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.");
+ EVENT_LOGGER.warn("Unknown Chunk Generator detected: [{}], Distant Generation May Fail!", generator.getClass());
+ EVENT_LOGGER.warn("If it does crash, set Distant Generation to OFF or Generation Mode to None.");
ApiShared.LOGGER.warn("Unknown Chunk Generator detected: {}", generator.getClass());
}
params = new GlobalParameters((ServerLevel) ((WorldWrapper) serverlevel).getWorld(), lodBuilder, lodDim);
@@ -360,7 +365,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
}
catch (Exception e)
{
- ApiShared.LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e);
+ LOAD_LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e);
}
if (chunkData == null)
{
@@ -371,7 +376,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
try {
return ChunkLoader.read(level, lightEngine, chunkPos, chunkData);
} catch (Exception e) {
- ApiShared.LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e);
+ LOAD_LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e);
return new ProtoChunk(chunkPos, UpgradeData.EMPTY, level);
}
}
@@ -380,25 +385,23 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
public void generateLodFromList(GenerationEvent e)
{
- if (ENABLE_EVENT_LOGGING)
- ApiShared.LOGGER.info("Lod Generate Event: " + e.pos);
+ EVENT_LOGGER.debug("Lod Generate Event: " + e.pos);
e.pEvent.beginNano = System.nanoTime();
- GridList referencedChunks;
+ ArrayGridList referencedChunks;
+ ArrayGridList genChunks;
DistanceGenerationMode generationMode;
LightedWorldGenRegion region;
WorldGenLevelLightEngine lightEngine;
LightGetterAdaptor adaptor;
-
+ int refRange = e.range + RANGE_TO_RANGE_EMPTY_EXTENSION;
+ int refOffsetX = e.pos.x - refRange;
+ int refOffsetZ = e.pos.z - refRange;
+
try
{
adaptor = new LightGetterAdaptor(params.level);
lightEngine = new WorldGenLevelLightEngine(adaptor);
-
- int cx = e.pos.x;
- int cy = e.pos.z;
- int rangeEmpty = e.range + 1;
- GridList chunks = new GridList(rangeEmpty);
-
+
@SuppressWarnings("resource")
EmptyChunkGenerator generator = (int x, int z) ->
{
@@ -416,23 +419,19 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
target = new ProtoChunk(chunkPos, UpgradeData.EMPTY, params.level);
return target;
};
-
- for (int oy = -rangeEmpty; oy <= rangeEmpty; oy++)
- {
- for (int ox = -rangeEmpty; ox <= rangeEmpty; ox++)
- {
- ChunkAccess target = generator.generate(cx + ox, cy + oy);
- chunks.add(target);
- }
- }
+
+ referencedChunks = new ArrayGridList<>(refRange*2+1,
+ (x,z) -> generator.generate(x + refOffsetX,z + refOffsetZ)
+ );
e.pEvent.emptyNano = System.nanoTime();
e.refreshTimeout();
- region = new LightedWorldGenRegion(params.level, lightEngine, chunks, ChunkStatus.STRUCTURE_STARTS, rangeEmpty, e.lightMode, generator);
+ region = new LightedWorldGenRegion(params.level, lightEngine, referencedChunks,
+ ChunkStatus.STRUCTURE_STARTS, refRange, e.lightMode, generator);
adaptor.setRegion(region);
- e.tParam.makeStructFeat(region);
- referencedChunks = chunks.subGrid(e.range);
- referencedChunks = generateDirect(e, referencedChunks, e.target, region);
-
+ e.tParam.makeStructFeat(region, params);
+ genChunks = new ArrayGridList<>(referencedChunks, RANGE_TO_RANGE_EMPTY_EXTENSION,
+ referencedChunks.gridSize - RANGE_TO_RANGE_EMPTY_EXTENSION);
+ generateDirect(e, genChunks, e.target, region);
}
catch (StepStructureStart.StructStartCorruptedException f)
{
@@ -464,14 +463,12 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
default:
return;
}
- int centreIndex = referencedChunks.size() / 2;
-
- for (int oy = -e.range; oy <= e.range; oy++)
+
+ for (int oy = 0; oy < genChunks.gridSize; oy++)
{
- for (int ox = -e.range; ox <= e.range; ox++)
+ for (int ox = 0; ox < genChunks.gridSize; ox++)
{
- int targetIndex = referencedChunks.offsetOf(centreIndex, ox, oy);
- ChunkAccess target = referencedChunks.get(targetIndex);
+ ChunkAccess target = genChunks.get(ox, oy);
target.setLightCorrect(true);
//if (target instanceof LevelChunk)
// ((LevelChunk) target).setClientLightReady(true);
@@ -479,8 +476,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
//boolean isPartial = target.isOldNoiseGeneration();
if (isFull)
{
- if (ENABLE_LOAD_EVENT_LOGGING)
- ApiShared.LOGGER.info("Detected full existing chunk at {}", target.getPos());
+ LOAD_LOGGER.info("Detected full existing chunk at {}", target.getPos());
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, new ChunkWrapper(target, region),
new LodBuilderConfig(DistanceGenerationMode.FULL), true, e.genAllDetails);
}
@@ -503,15 +499,15 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
}
e.pEvent.endNano = System.nanoTime();
e.refreshTimeout();
- if (ENABLE_PERF_LOGGING)
+ if (PREF_LOGGER.canMaybeLog())
{
e.tParam.perf.recordEvent(e.pEvent);
- ApiShared.LOGGER.info(e.tParam.perf);
+ PREF_LOGGER.infoInc("{}", e.tParam.perf);
}
}
-
- public GridList generateDirect(GenerationEvent e, GridList subRange, Steps step,
- LightedWorldGenRegion region)
+
+ public void generateDirect(GenerationEvent e, ArrayGridList subRange, Steps step,
+ LightedWorldGenRegion region)
{
try
{
@@ -524,38 +520,38 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
}
});
if (step == Steps.Empty)
- return subRange;
+ return;
stepStructureStart.generateGroup(e.tParam, region, subRange);
e.pEvent.structStartNano = System.nanoTime();
e.refreshTimeout();
if (step == Steps.StructureStart)
- return subRange;
+ return;
stepStructureReference.generateGroup(e.tParam, region, subRange);
e.pEvent.structRefNano = System.nanoTime();
e.refreshTimeout();
if (step == Steps.StructureReference)
- return subRange;
+ return;
stepBiomes.generateGroup(e.tParam, region, subRange);
e.pEvent.biomeNano = System.nanoTime();
e.refreshTimeout();
if (step == Steps.Biomes)
- return subRange;
+ return;
stepNoise.generateGroup(e.tParam, region, subRange);
e.pEvent.noiseNano = System.nanoTime();
e.refreshTimeout();
if (step == Steps.Noise)
- return subRange;
+ return;
stepSurface.generateGroup(e.tParam, region, subRange);
e.pEvent.surfaceNano = System.nanoTime();
e.refreshTimeout();
if (step == Steps.Surface)
- return subRange;
+ return;
if (step == Steps.Carvers)
- return subRange;
+ return;
stepFeatures.generateGroup(e.tParam, region, subRange);
e.pEvent.featureNano = System.nanoTime();
e.refreshTimeout();
- return subRange;
+ return;
}
finally
{
@@ -589,14 +585,14 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
@Override
public void stop(boolean blocking) {
- ApiShared.LOGGER.info("Batch Chunk Generator shutting down...");
+ EVENT_LOGGER.info("Batch Chunk Generator shutting down...");
executors.shutdownNow();
if (blocking) try {
if (!executors.awaitTermination(10, TimeUnit.SECONDS)) {
- ApiShared.LOGGER.error("Batch Chunk Generator shutdown failed! Ignoring child threads...");
+ EVENT_LOGGER.error("Batch Chunk Generator shutdown failed! Ignoring child threads...");
}
} catch (InterruptedException e) {
- ApiShared.LOGGER.error("Batch Chunk Generator shutdown failed! Ignoring child threads...", e);
+ EVENT_LOGGER.error("Batch Chunk Generator shutdown failed! Ignoring child threads...", e);
}
}
}
\ No newline at end of file
diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/ThreadedParameters.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/ThreadedParameters.java
index f641a5bc0..aa4d543c4 100644
--- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/ThreadedParameters.java
+++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/ThreadedParameters.java
@@ -12,7 +12,7 @@ public final class ThreadedParameters
{
private static final ThreadLocal localParam = new ThreadLocal();
final ServerLevel level;
- public final WorldGenStructFeatManager structFeat;
+ public WorldGenStructFeatManager structFeat = null;
boolean isValid = true;
public final PerfCalculator perf = new PerfCalculator();
@@ -34,11 +34,9 @@ public final class ThreadedParameters
private ThreadedParameters(GlobalParameters param)
{
level = param.level;
- structFeat = new WorldGenStructFeatManager(level, param.worldGenSettings, null);
+ structFeat = new WorldGenStructFeatManager(level, param.worldGenSettings);
}
-
- public void makeStructFeat(WorldGenLevel genLevel)
- {
- structFeat.setGenLevel(genLevel);
+ public void makeStructFeat(WorldGenLevel genLevel, GlobalParameters param) {
+ structFeat = new WorldGenStructFeatManager(param.worldGenSettings, genLevel);
}
}
\ No newline at end of file
diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGeneratorWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGeneratorWrapper.java
deleted file mode 100644
index cda496fd8..000000000
--- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGeneratorWrapper.java
+++ /dev/null
@@ -1,152 +0,0 @@
-package com.seibel.lod.common.wrappers.worldGeneration;
-
-import com.seibel.lod.core.builders.lodBuilding.LodBuilder;
-import com.seibel.lod.core.builders.lodBuilding.LodBuilderConfig;
-import com.seibel.lod.core.enums.config.DistanceGenerationMode;
-import com.seibel.lod.core.objects.lod.LodDimension;
-//import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
-import com.seibel.lod.core.wrapperInterfaces.chunk.AbstractChunkPosWrapper;
-//import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
-import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper;
-import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractWorldGeneratorWrapper;
-import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
-import com.seibel.lod.common.wrappers.world.WorldWrapper;
-
-import net.minecraft.server.level.ServerLevel;
-import net.minecraft.world.level.chunk.*;
-
-/**
- * @author James Seibel
- * @version 11-13-2021
- */
-public class WorldGeneratorWrapper extends AbstractWorldGeneratorWrapper
-{
- public final ServerLevel serverWorld;
- public final LodDimension lodDim;
- public final LodBuilder lodBuilder;
-
- public WorldGeneratorWrapper(LodBuilder newLodBuilder, LodDimension newLodDimension, IWorldWrapper worldWrapper)
- {
- super(newLodBuilder, newLodDimension, worldWrapper);
-
- lodBuilder = newLodBuilder;
- lodDim = newLodDimension;
- serverWorld = ((WorldWrapper) worldWrapper).getServerWorld();
- }
-
-
- /** takes about 2-5 ms */
- @Override
- public void generateBiomesOnly(AbstractChunkPosWrapper pos, DistanceGenerationMode generationMode)
- {
- generate(pos.getX(), pos.getZ(), generationMode);
- }
-
-
- /** takes about 10 - 20 ms */
- @Override
- public void generateSurface(AbstractChunkPosWrapper pos)
- {
- generate(pos.getX(), pos.getZ(), DistanceGenerationMode.SURFACE);
- }
-
-
- /**
- * takes about 15 - 20 ms
- *
- */
- @Override
- public void generateFeatures(AbstractChunkPosWrapper pos)
- {
- generate(pos.getX(), pos.getZ(), DistanceGenerationMode.FEATURES);
- }
-
-
- /**
- * Generates using MC's ServerWorld.
- *
- * on pre generated chunks 0 - 1 ms
- * on un generated chunks 0 - 50 ms
- * with the median seeming to hover around 15 - 30 ms
- * and outliers in the 100 - 200 ms range
- *
- * Note this should not be multithreaded and does cause server/simulation lag
- * (Higher lag for generating than loading)
- */
- @Override
- public void generateFull(AbstractChunkPosWrapper pos)
- {
- generate(pos.getX(), pos.getZ(), DistanceGenerationMode.FULL);
- }
-
- private void generate(int chunkX, int chunkZ, DistanceGenerationMode generationMode) {
-
-// long t = System.nanoTime();
-
- ChunkStatus targetStatus;
- switch (generationMode) {
- case BIOME_ONLY:
- targetStatus = ChunkStatus.BIOMES;
- break;
- case BIOME_ONLY_SIMULATE_HEIGHT:
- targetStatus = ChunkStatus.NOISE;
- break;
- case SURFACE:
- targetStatus = ChunkStatus.SURFACE;
- break;
- case FEATURES:
- targetStatus = ChunkStatus.FEATURES;
- break;
- case FULL:
- targetStatus = ChunkStatus.FULL;
- break;
- case NONE:
- default:
- return;
- }
-
- // The bool=true means that we want to generate chunk, and that the returned ChunkAccess must not be null
-
- ChunkAccess ca = serverWorld.getChunkSource().getChunk(chunkX, chunkZ, targetStatus, true);
- if (ca == null) throw new RuntimeException("This should NEVER be null due to bool being true");
- lodBuilder.generateLodNodeFromChunk(lodDim, new ChunkWrapper(ca, serverWorld), new LodBuilderConfig(generationMode), false, true);
-
- // long duration = System.nanoTime()-t;
-
- // Debug print the duration
- // System.out.println("LodChunkGenFull["+chunkX+","+chunkZ+"]: "+(double)(duration)/1000.);
- }
-
-
-
-
-
-
-
- /* TODO: Ask leetom to update chart
- * performance/generation tests related to
- * serverWorld.getChunk(x, z, ChunkStatus. *** )
-
- true/false is whether they generated blocks or not
- the time is how long it took to generate
-
- ChunkStatus.EMPTY 0 - 1 ms false (empty, what did you expect? :P)
- ChunkStatus.STRUCTURE_REFERENCES 1 - 2 ms false (no height, only generates some chunks)
- ChunkStatus.BIOMES 1 - 10 ms false (no height)
- ChunkStatus.NOISE 4 - 15 ms true (all blocks are stone)
- ChunkStatus.LIQUID_CARVERS 6 - 12 ms true (no snow/trees, just grass)
- ChunkStatus.SURFACE 5 - 15 ms true (no snow/trees, just grass)
- ChunkStatus.CARVERS 5 - 30 ms true (no snow/trees, just grass)
- ChunkStatus.FEATURES 7 - 25 ms true
- ChunkStatus.HEIGHTMAPS 20 - 40 ms true
- ChunkStatus.LIGHT 20 - 40 ms true
- ChunkStatus.FULL 30 - 50 ms true
- ChunkStatus.SPAWN 50 - 80 ms true
-
-
- At this point I would suggest using FEATURES, as it generates snow and trees
- (and any other object that are needed to make biomes distinct)
-
- Otherwise, if snow/trees aren't necessary SURFACE is the next fastest (although not by much)
- */
-}
diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java
index 480aa91eb..a9c9727d6 100644
--- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java
+++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java
@@ -1,10 +1,12 @@
package com.seibel.lod.common.wrappers.worldGeneration.mimicObject;
+import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
import com.seibel.lod.core.api.ApiShared;
import java.util.Objects;
+import com.seibel.lod.core.logging.ConfigBasedLogger;
import net.minecraft.core.Registry;
import net.minecraft.core.SectionPos;
import net.minecraft.nbt.CompoundTag;
@@ -30,7 +32,7 @@ import net.minecraft.world.level.material.Fluids;
import org.apache.logging.log4j.Logger;
public class ChunkLoader {
- private static final Logger LOGGER = ApiShared.LOGGER;
+ private static final ConfigBasedLogger LOGGER = BatchGenerationEnvironment.LOAD_LOGGER;
private static LevelChunkSection[] readSections(WorldGenLevel level, LevelLightEngine lightEngine,
ChunkPos chunkPos, CompoundTag tagLevel) {
@@ -102,8 +104,7 @@ public class ChunkLoader {
ChunkPos actualPos = new ChunkPos(tagLevel.getInt("xPos"), tagLevel.getInt("zPos"));
if (!Objects.equals(chunkPos, actualPos)) {
- LOGGER.error("Distant Horizons: Chunk file at {} is in the wrong location; Ignoring. (Expected {}, got {})",
- (Object) chunkPos, (Object) chunkPos, (Object) actualPos);
+ LOGGER.error("Chunk file at {} is in the wrong location; Ignoring. (Expected {}, got {})", (Object) chunkPos, (Object) chunkPos, (Object) actualPos);
return null;
}
diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightedWorldGenRegion.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightedWorldGenRegion.java
index e3b15c7ef..a98dc45fe 100644
--- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightedWorldGenRegion.java
+++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightedWorldGenRegion.java
@@ -91,6 +91,13 @@ public class LightedWorldGenRegion extends WorldGenRegion {
return true;
}
+ // TODO Check this
+// @Override
+// public List extends StructureStart>> startsForFeature(SectionPos sectionPos,
+// StructureFeature> structureFeature) {
+// return structFeat.startsForFeature(sectionPos, structureFeature);
+// }
+
// Skip updating the related tile entities
@Override
public boolean setBlock(BlockPos blockPos, BlockState blockState, int i, int j) {
@@ -240,6 +247,10 @@ public class LightedWorldGenRegion extends WorldGenRegion {
return blockTintCache.getColor(blockPos, null); // FIXME[Generator]: Replace this null with something else
}
+ private Biome _getBiome(BlockPos pos) {
+ return getBiome(pos);
+ }
+
public int calculateBlockTint(BlockPos blockPos, ColorResolver colorResolver)
{
int i = (Minecraft.getInstance()).options.biomeBlendRadius;
diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java
index 1be8dfc4b..8b56392ec 100644
--- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java
+++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java
@@ -15,24 +15,25 @@ import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.structure.StructureStart;
public class WorldGenStructFeatManager extends StructureFeatureManager {
- WorldGenLevel genLevel;
+ final WorldGenLevel genLevel;
WorldGenSettings worldGenSettings;
- public WorldGenStructFeatManager(LevelAccessor levelAccessor, WorldGenSettings worldGenSettings,
+ public WorldGenStructFeatManager(WorldGenSettings worldGenSettings,
WorldGenLevel genLevel) {
- super(levelAccessor, worldGenSettings);
+ super(genLevel, worldGenSettings);
this.genLevel = genLevel;
this.worldGenSettings = worldGenSettings;
}
-
- public void setGenLevel(WorldGenLevel genLevel) {
- this.genLevel = genLevel;
- }
@Override
public WorldGenStructFeatManager forWorldGenRegion(WorldGenRegion worldGenRegion) {
if (worldGenRegion == genLevel)
return this;
- return new WorldGenStructFeatManager(worldGenRegion, worldGenSettings, worldGenRegion);
+ return new WorldGenStructFeatManager(worldGenSettings, worldGenRegion);
+ }
+
+ private ChunkAccess _getChunk(int x, int z, ChunkStatus status) {
+ if (genLevel == null) return null;
+ return genLevel.getChunk(x, z, status, false);
}
@Override
diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepFeatures.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepFeatures.java
index 0383c3b21..3c1645e09 100644
--- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepFeatures.java
+++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepFeatures.java
@@ -5,8 +5,8 @@ import java.util.ArrayList;
import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters;
import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.LightedWorldGenRegion;
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
-import com.seibel.lod.core.util.GridList;
+import com.seibel.lod.core.util.gridList.ArrayGridList;
import net.minecraft.ReportedException;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkStatus;
@@ -27,7 +27,7 @@ public final class StepFeatures {
public final ChunkStatus STATUS = ChunkStatus.FEATURES;
- public void generateGroup(ThreadedParameters tParams, LightedWorldGenRegion worldGenRegion, GridList chunks) {
+ public void generateGroup(ThreadedParameters tParams, LightedWorldGenRegion worldGenRegion, ArrayGridList chunks) {
ArrayList chunksToDo = new ArrayList();
for (ChunkAccess chunk : chunks) {
diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepLight.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepLight.java
index 13728799b..23c438538 100644
--- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepLight.java
+++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepLight.java
@@ -2,8 +2,8 @@ package com.seibel.lod.common.wrappers.worldGeneration.step;
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
import com.seibel.lod.common.wrappers.worldGeneration.mimicObject.WorldGenLevelLightEngine;
-import com.seibel.lod.core.util.GridList;
+import com.seibel.lod.core.util.gridList.ArrayGridList;
import net.minecraft.server.level.ThreadedLevelLightEngine;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkStatus;
@@ -28,7 +28,7 @@ public final class StepLight {
public final ChunkStatus STATUS = ChunkStatus.LIGHT;
public void generateGroup(LightEventListener lightEngine,
- GridList chunks) {
+ ArrayGridList chunks) {
//ArrayList chunksToDo = new ArrayList();
for (ChunkAccess chunk : chunks) {
diff --git a/common/src/main/resources/lod.accesswidener b/common/src/main/resources/lod.accesswidener
index c639800fb..b84cb29fd 100644
--- a/common/src/main/resources/lod.accesswidener
+++ b/common/src/main/resources/lod.accesswidener
@@ -1,6 +1,6 @@
accessWidener v1 named
-# used when determining where to save files too
+# used when determining where to save files to
accessible field net/minecraft/world/level/storage/DimensionDataStorage dataFolder Ljava/io/File;
# used when rendering
@@ -25,7 +25,10 @@ accessible field net/minecraft/world/level/lighting/LevelLightEngine skyEngine L
# world generation
accessible method net/minecraft/world/level/levelgen/Heightmap setHeight (III)V
accessible field net/minecraft/world/level/biome/Biome generationSettings Lnet/minecraft/world/level/biome/BiomeGenerationSettings;
+accessible field net/minecraft/world/level/biome/Biome biomeCategory Lnet/minecraft/world/level/biome/Biome$BiomeCategory;
+# accessible field net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator settings Lnet/minecraft/core/Holder;
accessible field net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator settings Ljava/util/function/Supplier;
+#accessible method net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator doCreateBiomes (Lnet/minecraft/core/Registry;Lnet/minecraft/world/level/levelgen/blending/Blender;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V
accessible method net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator doFill (Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;II)Lnet/minecraft/world/level/chunk/ChunkAccess;
accessible method net/minecraft/world/level/lighting/LayerLightEngine queueSectionData (JLnet/minecraft/world/level/chunk/DataLayer;Z)V
diff --git a/core b/core
index bca2b6180..4c984c5c1 160000
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit bca2b61800b613b630def131e9c9f85f9736493d
+Subproject commit 4c984c5c102aaee9fd5a34acf94aa0ffbdbfacb1
diff --git a/fabric/src/main/java/com/seibel/lod/fabric/ClientProxy.java b/fabric/src/main/java/com/seibel/lod/fabric/ClientProxy.java
index f4bb45710..122f80e9c 100644
--- a/fabric/src/main/java/com/seibel/lod/fabric/ClientProxy.java
+++ b/fabric/src/main/java/com/seibel/lod/fabric/ClientProxy.java
@@ -19,6 +19,7 @@
package com.seibel.lod.fabric;
+import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
import com.seibel.lod.core.api.ClientApi;
import com.seibel.lod.core.api.EventApi;
import com.mojang.blaze3d.platform.InputConstants;
@@ -42,6 +43,7 @@ import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.chunk.LevelChunk;
import java.util.HashSet;
+import java.util.function.Supplier;
import org.lwjgl.glfw.GLFW;
@@ -58,6 +60,7 @@ public class ClientProxy
private final EventApi eventApi = EventApi.INSTANCE;
private final ClientApi clientApi = ClientApi.INSTANCE;
+ public static Supplier isGenerationThreadChecker = null;
/**
* Registers Fabric Events
@@ -89,6 +92,7 @@ public class ClientProxy
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (client.player != null) onKeyInput();
});
+ isGenerationThreadChecker = BatchGenerationEnvironment::isCurrentThreadDistantGeneratorThread;
}
diff --git a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinUtilBackgroudThread.java b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinUtilBackgroudThread.java
index c1b67baca..879c264f1 100644
--- a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinUtilBackgroudThread.java
+++ b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinUtilBackgroudThread.java
@@ -2,6 +2,7 @@ package com.seibel.lod.fabric.mixins;
import java.util.concurrent.Executor;
+import com.seibel.lod.fabric.ClientProxy;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@@ -29,7 +30,7 @@ public class MixinUtilBackgroudThread
at = @At("HEAD"), cancellable = true)
private static void overrideUtil$wrapThreadWithTaskName(String string, Runnable r, CallbackInfoReturnable ci)
{
- if (DependencySetupDoneCheck.isDone && doTriggerOverride())
+ if (ClientProxy.isGenerationThreadChecker != null && ClientProxy.isGenerationThreadChecker.get())
{
// ApiShared.LOGGER.info("util wrapThreadWithTaskName(Runnable) triggered");
ci.setReturnValue(r);
@@ -39,7 +40,7 @@ public class MixinUtilBackgroudThread
@Inject(method = "backgroundExecutor", at = @At("HEAD"), cancellable = true)
private static void overrideUtil$backgroundExecutor(CallbackInfoReturnable ci)
{
- if (DependencySetupDoneCheck.isDone && doTriggerOverride())
+ if (ClientProxy.isGenerationThreadChecker != null && ClientProxy.isGenerationThreadChecker.get())
{
// ApiShared.LOGGER.info("util backgroundExecutor triggered");
ci.setReturnValue(Runnable::run);
diff --git a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinWorldRenderer.java b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinWorldRenderer.java
index 9264da68f..a7403fdd3 100644
--- a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinWorldRenderer.java
+++ b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinWorldRenderer.java
@@ -21,6 +21,7 @@ package com.seibel.lod.fabric.mixins;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f;
+import com.seibel.lod.common.Config;
import com.seibel.lod.common.wrappers.McObjectConverter;
import com.seibel.lod.core.api.ClientApi;
import com.seibel.lod.core.objects.math.Mat4f;
@@ -60,8 +61,11 @@ public class MixinWorldRenderer
previousPartialTicks = tickDelta;
}
+ // Inject rendering at first call to renderChunkLayer
// HEAD or RETURN
- @Inject(at = @At("HEAD"), method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLcom/mojang/math/Matrix4f;)V")
+ @Inject(at = @At("HEAD"),
+ method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLcom/mojang/math/Matrix4f;)V",
+ cancellable = true)
private void renderChunkLayer(RenderType renderType, PoseStack modelViewMatrixStack, double cameraXBlockPos, double cameraYBlockPos, double cameraZBlockPos, Matrix4f projectionMatrix, CallbackInfo callback)
{
// only render before solid blocks
@@ -72,5 +76,8 @@ public class MixinWorldRenderer
ClientApi.INSTANCE.renderLods(mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
}
+ if (Config.Client.Advanced.lodOnlyMode) {
+ callback.cancel();
+ }
}
}
diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json
index 8c55b17d5..7f5921c3d 100644
--- a/fabric/src/main/resources/fabric.mod.json
+++ b/fabric/src/main/resources/fabric.mod.json
@@ -34,8 +34,8 @@
"depends": {
"fabricloader": "*",
"fabric": "*",
- "minecraft": "1.17.x",
- "java": ">=16"
+ "minecraft": "${minecraft_version}",
+ "java": ">=${java_version}"
},
"suggests": {
"another-mod": "*"
diff --git a/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java b/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java
index 44d3067a3..f0f3b3d80 100644
--- a/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java
+++ b/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java
@@ -70,20 +70,9 @@ public class ForgeMain implements LodForgeMethodCaller
{
LodCommonMain.initConfig();
LodCommonMain.startup(this, !FMLLoader.getDist().isClient());
-
- ApiShared.LOGGER.info("Distant Horizons initializing...");
-
-
- // make sure the dependencies are set up before the mod needs them
ForgeDependencySetup.createInitialBindings();
ForgeDependencySetup.finishBinding();
-
- // mod dependencies
- if (ReflectionHandler.instance.optifinePresent()) {
- ModAccessorHandler.bind(IOptifineAccessor.class, new OptifineAccessor());
- }
-
- ModAccessorHandler.finishBinding();
+ ApiShared.LOGGER.info("Distant Horizons initializing...");
}
@@ -99,6 +88,15 @@ public class ForgeMain implements LodForgeMethodCaller
private void onClientStart(final FMLClientSetupEvent event)
{
+ if (ReflectionHandler.instance.optifinePresent()) {
+ ModAccessorHandler.bind(IOptifineAccessor.class, new OptifineAccessor());
+ }
+
+ ModAccessorHandler.finishBinding();
+
+
+ ModAccessorHandler.finishBinding();
+
ModLoadingContext.get().registerExtensionPoint(ConfigGuiHandler.ConfigGuiFactory.class,
() -> new ConfigGuiHandler.ConfigGuiFactory((client, parent) -> ConfigGui.getScreen(parent, "")));
forgeClientProxy = new ForgeClientProxy();
diff --git a/forge/src/main/java/com/seibel/lod/forge/mixins/MixinWorldRenderer.java b/forge/src/main/java/com/seibel/lod/forge/mixins/MixinWorldRenderer.java
index 9a3947d32..cad7b44e8 100644
--- a/forge/src/main/java/com/seibel/lod/forge/mixins/MixinWorldRenderer.java
+++ b/forge/src/main/java/com/seibel/lod/forge/mixins/MixinWorldRenderer.java
@@ -21,6 +21,7 @@ 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.wrappers.McObjectConverter;
import com.seibel.lod.core.api.ClientApi;
import com.seibel.lod.core.objects.math.Mat4f;
@@ -61,7 +62,9 @@ public class MixinWorldRenderer
}
// HEAD or RETURN
- @Inject(at = @At("HEAD"), method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLcom/mojang/math/Matrix4f;)V")
+ @Inject(at = @At("HEAD"),
+ method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLcom/mojang/math/Matrix4f;)V",
+ cancellable = true)
private void renderChunkLayer(RenderType renderType, PoseStack modelViewMatrixStack, double cameraXBlockPos, double cameraYBlockPos, double cameraZBlockPos, Matrix4f projectionMatrix, CallbackInfo callback)
{
// only render before solid blocks
@@ -72,5 +75,8 @@ public class MixinWorldRenderer
ClientApi.INSTANCE.renderLods(mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
}
+ if (Config.Client.Advanced.lodOnlyMode) {
+ callback.cancel();
+ }
}
}
diff --git a/gradle.properties b/gradle.properties
index 3c8eaee09..297c34e5f 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,13 +1,11 @@
org.gradle.jvmargs=-Xmx2048M
+org.gradle.daemon=false
-minecraft_version=1.17.1
-
-archives_base_name=DistantHorizons
-mod_version=1.6.2a
maven_group=com.seibel.lod
-toml_version=3.6.4
+archives_base_name=DistantHorizons
# Mod info
+mod_version=1.6.2a
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
@@ -15,35 +13,9 @@ 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
+# Global Plugin versions
+toml_version=3.6.4
+manifold_version=2022.1.7
-# Fabric loader
-fabric_loader_version=0.13.2
-fabric_api_version=0.46.1+1.17
- # Fabric mod versions
- modmenu_version=2.0.14
- starlight_version_fabric=3442770
- lithium_version=mc1.17.1-0.7.5
- sodium_version=3605275
- iris_version=1.17.x-v1.1.4
- immersive_portals_version = 0.14-1.17
-
- # Fabric mod run
- # 0 = Dont enable and dont run
- # 1 = Can be refranced in code but dosnt run
- # 2 = Can be refranced in code and runs in client
- enable_starlight=0
- enable_lithium=0
- enable_sodium=1
- enable_iris=0
-
-
-# Forge loader
-forge_version=37.1.1
- # Forge mod versions
- starlight_version_forge=3457784
-
- # Forge mod run
- # 0 = Dont enable and dont run
- # 1 = Can be refranced in code but dosnt run
- # 2 = Can be refranced in code and runs in client
- enable_starlight_forge=0
+##### FOR IDE SUPPORT AND TELL IDE TO USE CERTIAN MC VERSION: SWITCH THIS:
+mcVer=1.17.1
\ No newline at end of file
diff --git a/plugins/DHJarMerger-1.0.jar b/plugins/DHJarMerger-1.0.jar
index a38dae5e7..acec82e0b 100644
Binary files a/plugins/DHJarMerger-1.0.jar and b/plugins/DHJarMerger-1.0.jar differ