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 885123a64..512be61bd 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,19 +1,20 @@
package com.seibel.lod.common.wrappers.chunk;
+import com.seibel.lod.common.wrappers.block.BlockDetailWrapper;
+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.block.BlockDetailWrapper;
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.LiquidBlockContainer;
@@ -32,22 +33,21 @@ import net.minecraft.world.level.levelgen.Heightmap;
*/
public class ChunkWrapper implements IChunkWrapper
{
- private final ChunkAccess chunk;
- private final LevelReader lightSource;
-
-
- public ChunkWrapper(ChunkAccess chunk, LevelReader lightSource)
- {
- this.chunk = chunk;
- this.lightSource = lightSource;
- }
-
-
- @Override
- public int getHeight(){
- return chunk.getHeight();
- }
-
+ private final ChunkAccess chunk;
+ private final LevelReader lightSource;
+
+
+ public ChunkWrapper(ChunkAccess chunk, LevelReader lightSource)
+ {
+ this.chunk = chunk;
+ this.lightSource = lightSource;
+ }
+
+ @Override
+ public int getHeight(){
+ return chunk.getHeight();
+ }
+
@Override
public int getMinBuildHeight()
{
@@ -58,114 +58,134 @@ public class ChunkWrapper implements IChunkWrapper
{
return chunk.getMaxBuildHeight();
}
-
- @Override
- public int getHeightMapValue(int xRel, int zRel)
- {
- return chunk.getOrCreateHeightmapUnprimed(WrapperUtil.DEFAULT_HEIGHTMAP).getFirstAvailable(xRel, zRel);
- }
-
- @Override
- public IBiomeWrapper getBiome(int x, int y, int z)
- {
+
+ @Override
+ public int getHeightMapValue(int xRel, int zRel)
+ {
+ return chunk.getOrCreateHeightmapUnprimed(WrapperUtil.DEFAULT_HEIGHTMAP).getFirstAvailable(xRel, zRel);
+ }
+
+ @Override
+ public IBiomeWrapper getBiome(int x, int y, int z)
+ {
+ #if MC_VERSION_1_18_2
+ return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome(
+ QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)).value());
+ #elif MC_VERSION_1_18_1
return BiomeWrapper.getBiomeWrapper(chunk.getNoiseBiome(
QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)));
- }
-
+ #endif
+ }
+
+ @Override
+ public IBlockDetailWrapper getBlockDetail(int x, int y, int z) {
+ BlockPos pos = new BlockPos(x,y,z);
+ BlockState blockState = chunk.getBlockState(pos);
+ IBlockDetailWrapper blockDetail = BlockDetailMap.getOrMakeBlockDetailCache(blockState, pos, lightSource);
+ return blockDetail == BlockDetailWrapper.NULL_BLOCK_DETAIL ? null : blockDetail;
+ }
+
@Override
- public BlockDetailWrapper 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);
+ 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() {
- return chunk;
- }
-
- @Override
- public int getChunkPosX(){
- return chunk.getPos().x;
- }
-
- @Override
- public int getChunkPosZ(){
- return chunk.getPos().z;
- }
-
- @Override
- public int getRegionPosX(){
- 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, chunk.getPos().z, LodUtil.REGION_DETAIL_LEVEL);
- }
-
- @Override
- public int getMaxY(int x, int z) {
- return chunk.getHeight(Heightmap.Types.MOTION_BLOCKING, Math.floorMod(x, 16), Math.floorMod(z, 16));
- }
-
- @Override
- public int getMaxX(){
- return chunk.getPos().getMaxBlockX();
- }
- @Override
- public int getMaxZ(){
- return chunk.getPos().getMaxBlockZ();
- }
- @Override
- public int getMinX(){
- return chunk.getPos().getMinBlockX();
- }
- @Override
- public int getMinZ() {
- return chunk.getPos().getMinBlockZ();
- }
-
- @Override
- public long getLongChunkPos() {
- return chunk.getPos().toLong();
- }
-
- @Override
- public boolean isLightCorrect(){
- //return true;
- if (chunk instanceof LevelChunk) {
- return ((LevelChunk) chunk).isClientLightReady();
- }
- return chunk.isLightCorrect();
- }
-
- public boolean isWaterLogged(int x, int y, int z)
- {
- BlockState blockState = chunk.getBlockState(new BlockPos(x,y,z));
-
- //This type of block is always in water
- return (!(blockState.getBlock() instanceof LiquidBlockContainer) && (blockState.getBlock() instanceof SimpleWaterloggedBlock))
- && (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && blockState.getValue(BlockStateProperties.WATERLOGGED));
- }
-
- @Override
- public int getEmittedBrightness(int x, int y, int z)
- {
- return chunk.getLightEmission(new BlockPos(x,y,z));
- }
-
+
+ public ChunkAccess getChunk() {
+ return chunk;
+ }
+
+ @Override
+ public int getChunkPosX(){
+ return chunk.getPos().x;
+ }
+
+ @Override
+ public int getChunkPosZ(){
+ return chunk.getPos().z;
+ }
+
+ @Override
+ public int getRegionPosX(){
+ 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, chunk.getPos().z, LodUtil.REGION_DETAIL_LEVEL);
+ }
+
+ @Override
+ public int getMaxY(int x, int z) {
+ return chunk.getHeight(Heightmap.Types.MOTION_BLOCKING, Math.floorMod(x, 16), Math.floorMod(z, 16));
+ }
+
+ @Override
+ public int getMaxX(){
+ return chunk.getPos().getMaxBlockX();
+ }
+ @Override
+ public int getMaxZ(){
+ return chunk.getPos().getMaxBlockZ();
+ }
+ @Override
+ public int getMinX(){
+ return chunk.getPos().getMinBlockX();
+ }
+ @Override
+ public int getMinZ() {
+ return chunk.getPos().getMinBlockZ();
+ }
+
+ @Override
+ public long getLongChunkPos() {
+ return chunk.getPos().toLong();
+ }
+
+ @Override
+ public boolean isLightCorrect(){
+ //return true;
+ if (chunk instanceof LevelChunk) {
+ return ((LevelChunk) chunk).isClientLightReady();
+ }
+ return chunk.isLightCorrect();
+ }
+
+ public boolean isWaterLogged(int x, int y, int z)
+ {
+ BlockState blockState = chunk.getBlockState(new BlockPos(x,y,z));
+
+ //This type of block is always in water
+ return (!(blockState.getBlock() instanceof LiquidBlockContainer) && (blockState.getBlock() instanceof SimpleWaterloggedBlock))
+ && (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && blockState.getValue(BlockStateProperties.WATERLOGGED));
+ }
+
+ @Override
+ public int getEmittedBrightness(int x, int y, int z)
+ {
+ return chunk.getLightEmission(new BlockPos(x,y,z));
+ }
+
@Override
public int getBlockLight(int x, int y, int z) {
if (lightSource == null) return -1;
- return lightSource.getBrightness(LightLayer.BLOCK, new BlockPos(x,y,z));
+ return lightSource.getBrightness(LightLayer.BLOCK, new BlockPos(x,y,z));
}
-
+
@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
@@ -179,9 +199,10 @@ public class ChunkWrapper implements IChunkWrapper
}
return true;
}
-
- public LevelReader getColorResolver()
- {
- return lightSource;
- }
+
+ public LevelReader getColorResolver()
+ {
+ 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 7f099fcff..ff230ac63 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 a6c243e30..36a1283ee 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;
/**
@@ -16,29 +15,29 @@ import com.seibel.lod.common.Config;
public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
{
public static final LodConfigWrapperSingleton INSTANCE = new LodConfigWrapperSingleton();
-
-
+
+
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 IMultiplayer multiplayer;
public final IAdvanced advanced;
-
-
+
+
@Override
public IGraphics graphics()
{
return graphics;
}
-
+
@Override
public IWorldGenerator worldGenerator()
{
@@ -46,8 +45,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
}
@Override
- public IMultiplayer multiplayer()
- {
+ public IMultiplayer multiplayer() {
return multiplayer;
}
@@ -56,8 +54,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
{
return advanced;
}
-
-
+
+
@Override
public boolean getOptionsButton()
{
@@ -69,8 +67,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("optionsButton").value = newOptionsButton;
ConfigGui.editSingleOption.saveOption("optionsButton");
}
-
-
+
+
//================//
// Client Configs //
//================//
@@ -81,8 +79,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
multiplayer = new Multiplayer();
advanced = new Advanced();
}
-
-
+
+
//==================//
// Graphics Configs //
//==================//
@@ -91,36 +89,36 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
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
@@ -134,8 +132,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.graphics.quality.drawResolution").value = newHorizontalResolution;
ConfigGui.editSingleOption.saveOption("client.graphics.quality.drawResolution");
}
-
-
+
+
@Override
public int getLodChunkRenderDistance()
{
@@ -147,8 +145,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.graphics.quality.lodChunkRenderDistance").value = newLodChunkRenderDistance;
ConfigGui.editSingleOption.saveOption("client.graphics.quality.lodChunkRenderDistance");
}
-
-
+
+
@Override
public VerticalQuality getVerticalQuality()
{
@@ -160,8 +158,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.graphics.quality.verticalQuality").value = newVerticalQuality;
ConfigGui.editSingleOption.saveOption("client.graphics.quality.verticalQuality");
}
-
-
+
+
@Override
public int getHorizontalScale()
{
@@ -173,8 +171,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.graphics.quality.horizontalScale").value = newHorizontalScale;
ConfigGui.editSingleOption.saveOption("client.graphics.quality.horizontalScale");
}
-
-
+
+
@Override
public HorizontalQuality getHorizontalQuality()
{
@@ -196,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()
{
@@ -212,36 +228,36 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.fogDistance").value = newFogDistance;
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.fogDistance");
}
-
-
+
+
@Override
public FogDrawMode getFogDrawMode()
{
return Config.Client.Graphics.FogQuality.fogDrawMode;
}
-
+
@Override
public void setFogDrawMode(FogDrawMode setFogDrawMode)
{
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.fogDrawMode").value = setFogDrawMode;
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.fogDrawMode");
}
-
-
+
+
@Override
public FogColorMode getFogColorMode()
{
return Config.Client.Graphics.FogQuality.fogColorMode;
}
-
+
@Override
public void setFogColorMode(FogColorMode newFogColorMode)
{
ConfigGui.editSingleOption.getEntry("client.graphics.fogQuality.fogColorMode").value = newFogColorMode;
ConfigGui.editSingleOption.saveOption("client.graphics.fogQuality.fogColorMode");
}
-
-
+
+
@Override
public boolean getDisableVanillaFog()
{
@@ -253,9 +269,170 @@ 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");
+ }
+ }
+ }
+
}
-
-
+
+
public static class AdvancedGraphics implements IAdvancedGraphics
{
@Override
@@ -269,8 +446,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.disableDirectionalCulling").value = newDisableDirectionalCulling;
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.disableDirectionalCulling");
}
-
-
+
+
@Override
public VanillaOverdraw getVanillaOverdraw()
{
@@ -306,7 +483,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.useExtendedNearClipPlane").value = newUseExtendedNearClipPlane;
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.useExtendedNearClipPlane");
}
-
+
@Override
public double getBrightnessMultiplier()
{
@@ -318,7 +495,7 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.graphics.advancedGraphics.brightnessMultiplier").value = newBrightnessMultiplier;
ConfigGui.editSingleOption.saveOption("client.graphics.advancedGraphics.brightnessMultiplier");
}
-
+
@Override
public double getSaturationMultiplier()
{
@@ -332,29 +509,6 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
}
}
}
-
-
-
-
- //=====================//
- // Multiplayer Configs //
- //=====================//
- public static class Multiplayer implements IMultiplayer
- {
- @Override
- public ServerFolderNameMode getServerFolderNameMode()
- {
- return Config.Client.Multiplayer.serverFolderNameMode;
- }
- @Override
- public void setServerFolderNameMode(ServerFolderNameMode newServerFolderNameMode)
- {
- ConfigGui.editSingleOption.getEntry("client.multiplayer.serverFolderNameMode").value = newServerFolderNameMode;
- ConfigGui.editSingleOption.saveOption("client.multiplayer.serverFolderNameMode");
- }
-
-
- }
@@ -375,8 +529,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.worldGenerator.generationPriority").value = newGenerationPriority;
ConfigGui.editSingleOption.saveOption("client.worldGenerator.generationPriority");
}
-
-
+
+
@Override
public DistanceGenerationMode getDistanceGenerationMode()
{
@@ -401,8 +555,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.worldGenerator.allowUnstableFeatureGeneration").value = newAllowUnstableFeatureGeneration;
ConfigGui.editSingleOption.saveOption("client.worldGenerator.allowUnstableFeatureGeneration");
}*/
-
-
+
+
@Override
public BlocksToAvoid getBlocksToAvoid()
{
@@ -437,10 +591,42 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.saveOption("client.worldGenerator.lightGenerationMode");
}
}
-
-
-
-
+
+
+
+ //=====================//
+ // Multiplayer Configs //
+ //=====================//
+ public static class Multiplayer implements IMultiplayer
+ {
+ @Override
+ public ServerFolderNameMode getServerFolderNameMode()
+ {
+ return Config.Client.Multiplayer.serverFolderNameMode;
+ }
+ @Override
+ public void setServerFolderNameMode(ServerFolderNameMode newServerFolderNameMode)
+ {
+ ConfigGui.editSingleOption.getEntry("client.multiplayer.serverFolderNameMode").value = newServerFolderNameMode;
+ 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");
+ }
+ }
+
+
+
//============================//
// AdvancedModOptions Configs //
//============================//
@@ -449,36 +635,36 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
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
@@ -492,8 +678,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.advanced.threading.numberOfWorldGenerationThreads").value = newNumberOfWorldGenerationThreads;
ConfigGui.editSingleOption.saveOption("client.advanced.threading.numberOfWorldGenerationThreads");
}
-
-
+
+
@Override
public int getNumberOfBufferBuilderThreads()
{
@@ -506,10 +692,10 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.saveOption("client.advanced.threading.numberOfBufferBuilderThreads");
}
}
-
-
-
-
+
+
+
+
//===============//
// Debug Options //
//===============//
@@ -526,8 +712,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.advanced.debugging.drawLods").value = newDrawLods;
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.drawLods");
}
-
-
+
+
@Override
public DebugMode getDebugMode()
{
@@ -539,8 +725,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.advanced.debugging.debugMode").value = newDebugMode;
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.debugMode");
}
-
-
+
+
@Override
public boolean getDebugKeybindingsEnabled()
{
@@ -553,11 +739,11 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.saveOption("client.advanced.debugging.enableDebugKeybindings");
}
}
-
-
+
+
public static class Buffers implements IBuffers
{
-
+
@Override
public GpuUploadMethod getGpuUploadMethod()
{
@@ -569,8 +755,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.advanced.buffers.gpuUploadMethod").value = newDisableVanillaFog;
ConfigGui.editSingleOption.saveOption("client.advanced.buffers.gpuUploadMethod");
}
-
-
+
+
@Override
public int getGpuUploadPerMegabyteInMilliseconds()
{
@@ -581,8 +767,8 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton
ConfigGui.editSingleOption.getEntry("client.advanced.buffers.gpuUploadPerMegabyteInMilliseconds").value = newMilliseconds;
ConfigGui.editSingleOption.saveOption("client.advanced.buffers.gpuUploadPerMegabyteInMilliseconds");
}
-
-
+
+
@Override
public BufferRebuildTimes getRebuildTimes()
{
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 9802ea590..e66fd2537 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
@@ -27,7 +27,6 @@ import com.mojang.blaze3d.platform.NativeImage;
import com.mojang.blaze3d.platform.Window;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.core.api.ApiShared;
-import com.seibel.lod.core.api.ClientApi;
import com.seibel.lod.core.enums.LodDirection;
import com.seibel.lod.core.util.LodUtil;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
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 ce7e5fcc5..c2d158073 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
@@ -5,6 +5,7 @@ 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;
@@ -24,7 +25,6 @@ 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.minecraft.IMinecraftClientWrapper;
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
import com.seibel.lod.common.wrappers.McObjectConverter;
@@ -54,104 +54,123 @@ import net.minecraft.world.phys.Vec3;
*/
public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
{
- public static final MinecraftRenderWrapper INSTANCE = new MinecraftRenderWrapper();
-
- private static final Minecraft MC = Minecraft.getInstance();
- private static final GameRenderer GAME_RENDERER = MC.gameRenderer;
- private static final IWrapperFactory FACTORY = WrapperFactory.INSTANCE;
-
-
- @Override
- public Vec3f getLookAtVector()
- {
- Camera camera = GAME_RENDERER.getMainCamera();
- Vector3f cameraDir = camera.getLookVector();
- return new Vec3f(cameraDir.x(), cameraDir.y(), cameraDir.z());
+ public static final MinecraftRenderWrapper INSTANCE = new MinecraftRenderWrapper();
+
+ private static final Minecraft MC = Minecraft.getInstance();
+ private static final GameRenderer GAME_RENDERER = MC.gameRenderer;
+ private static final IWrapperFactory FACTORY = WrapperFactory.INSTANCE;
+
+ @Override
+ public Vec3f getLookAtVector()
+ {
+ Camera camera = GAME_RENDERER.getMainCamera();
+ Vector3f cameraDir = camera.getLookVector();
+ return new Vec3f(cameraDir.x(), cameraDir.y(), cameraDir.z());
+ }
+
+ @Override
+ public AbstractBlockPosWrapper getCameraBlockPosition()
+ {
+ Camera camera = GAME_RENDERER.getMainCamera();
+ BlockPos blockPos = camera.getBlockPosition();
+ return new BlockPosWrapper(blockPos.getX(), blockPos.getY(), blockPos.getZ());
+ }
+
+ @Override
+ public boolean playerHasBlindnessEffect()
+ {
+ return MC.player.getActiveEffectsMap().get(MobEffects.BLINDNESS) != null;
+ }
+
+ @Override
+ public Vec3d getCameraExactPosition()
+ {
+ Camera camera = GAME_RENDERER.getMainCamera();
+ Vec3 projectedView = camera.getPosition();
+
+ return new Vec3d(projectedView.x, projectedView.y, projectedView.z);
+ }
+
+ @Override
+ public Mat4f getDefaultProjectionMatrix(float partialTicks)
+ {
+ return McObjectConverter.Convert(GAME_RENDERER.getProjectionMatrix(GAME_RENDERER.getFov(GAME_RENDERER.getMainCamera(), partialTicks, true)));
+ }
+
+ @Override
+ public double getGamma()
+ {
+ return MC.options.gamma;
+ }
+
+ @Override
+ public Color getFogColor(float partialTicks) {
+ FogRenderer.setupColor(GAME_RENDERER.getMainCamera(), partialTicks, MC.level, 1, GAME_RENDERER.getDarkenWorldAmount(partialTicks));
+ float[] colorValues = RenderSystem.getShaderFogColor();
+ return new Color(colorValues[0], colorValues[1], colorValues[2], colorValues[3]);
+ }
+ // getSpecialFogColor() is the same as getFogColor()
+
+ @Override
+ public Color getSkyColor() {
+ if (MC.level.dimensionType().hasSkyLight()) {
+ Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getPosition(), MC.getFrameTime());
+ return new Color((float) colorValues.x, (float) colorValues.y, (float) colorValues.z);
+ } else
+ return new Color(0, 0, 0);
+ }
+
+ @Override
+ public double getFov(float partialTicks)
+ {
+ return GAME_RENDERER.getFov(GAME_RENDERER.getMainCamera(), partialTicks, true);
+ }
+
+ /** Measured in chunks */
+ @Override
+ public int getRenderDistance()
+ {
+ return MC.options.getEffectiveRenderDistance();
+ }
+
+ @Override
+ public int getScreenWidth()
+ {
+ return MC.getWindow().getWidth();
+ }
+ @Override
+ public int getScreenHeight()
+ {
+ return MC.getWindow().getHeight();
+ }
+
+ private RenderTarget getRenderTarget() {
+ RenderTarget r = null; //MC.levelRenderer.getCloudsTarget();
+ return r!=null ? r : MC.getMainRenderTarget();
}
@Override
- public AbstractBlockPosWrapper getCameraBlockPosition()
- {
- Camera camera = GAME_RENDERER.getMainCamera();
- BlockPos blockPos = camera.getBlockPosition();
- return new BlockPosWrapper(blockPos.getX(), blockPos.getY(), blockPos.getZ());
+ public int getTargetFrameBuffer() {
+ return getRenderTarget().frameBufferId;
}
@Override
- public boolean playerHasBlindnessEffect()
- {
- return MC.player.getActiveEffectsMap().get(MobEffects.BLINDNESS) != null;
+ public int getTargetFrameBufferViewportWidth() {
+ return getRenderTarget().viewWidth;
}
@Override
- public Vec3d getCameraExactPosition()
- {
- Camera camera = GAME_RENDERER.getMainCamera();
- Vec3 projectedView = camera.getPosition();
-
- return new Vec3d(projectedView.x, projectedView.y, projectedView.z);
+ public int getTargetFrameBufferViewportHeight() {
+ return getRenderTarget().viewHeight;
}
- @Override
- public Mat4f getDefaultProjectionMatrix(float partialTicks)
- {
- return McObjectConverter.Convert(GAME_RENDERER.getProjectionMatrix(GAME_RENDERER.getFov(GAME_RENDERER.getMainCamera(), partialTicks, true)));
- }
-
- @Override
- public double getGamma()
- {
- return MC.options.gamma;
- }
-
- @Override
- public Color getFogColor(float partialTicks) {
- FogRenderer.setupColor(GAME_RENDERER.getMainCamera(), partialTicks, MC.level, 1, GAME_RENDERER.getDarkenWorldAmount(partialTicks));
- float[] colorValues = RenderSystem.getShaderFogColor();
- return new Color(colorValues[0], colorValues[1], colorValues[2], colorValues[3]);
- }
- // getSpecialFogColor() is the same as getFogColor()
-
- @Override
- public Color getSkyColor() {
- if (MC.level.dimensionType().hasSkyLight()) {
- Vec3 colorValues = MC.level.getSkyColor(MC.gameRenderer.getMainCamera().getPosition(), MC.getFrameTime());
- return new Color((float) colorValues.x, (float) colorValues.y, (float) colorValues.z);
- } else
- return new Color(0, 0, 0);
- }
-
- @Override
- public double getFov(float partialTicks)
- {
- return GAME_RENDERER.getFov(GAME_RENDERER.getMainCamera(), partialTicks, true);
- }
-
- /** Measured in chunks */
- @Override
- public int getRenderDistance()
- {
- return MC.options.renderDistance;
- }
-
- @Override
- public int getScreenWidth()
- {
- return MC.getWindow().getWidth();
- }
- @Override
- public int getScreenHeight()
- {
- return MC.getWindow().getHeight();
- }
-
- /**
- * This method returns the ChunkPos of all chunks that Minecraft
- * is going to render this frame.
- *
- */
-
- public boolean usingBackupGetVanillaRenderedChunks = false;
+ /**
+ * This method returns the ChunkPos of all chunks that Minecraft
+ * is going to render this frame.
+ *
+ */
+
+ public boolean usingBackupGetVanillaRenderedChunks = true;
@Override
public HashSet getVanillaRenderedChunks()
{
@@ -170,51 +189,55 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
}
if (!usingBackupGetVanillaRenderedChunks) {
try {
- LevelRenderer levelRenderer = MC.levelRenderer;
- LinkedHashSet 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)));
+ LevelRenderer levelRenderer = MC.levelRenderer;
+ LinkedHashSet chunks = levelRenderer.renderChunkStorage.get().renderChunks;
+ return (chunks.stream().map((chunk) -> {
+ #if MC_VERSION_1_18_2
+ AABB chunkBoundingBox = chunk.chunk.getBoundingBox();
+ #elif MC_VERSION_1_18_1
+ AABB chunkBoundingBox = chunk.chunk.bb;
+ #endif
+ 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.");
+ + " Using Backup Method.");
MinecraftClientWrapper.INSTANCE.sendChatMessage(
"\u00A7eOverdraw prevention will be worse than normal.");
} catch (Exception e2) {}
- ApiShared.LOGGER.error("getVanillaRenderedChunks Error: {}", e);
+ ApiShared.LOGGER.error("getVanillaRenderedChunks Error: ", e);
usingBackupGetVanillaRenderedChunks = true;
}
}
return getMaximumRenderedChunks();
}
-
- @Override
- public int[] getLightmapPixels()
- {
- LightTexture tex = GAME_RENDERER.lightTexture();
- tex.tick(); // This call makes no sense, but it fixes pause menu flicker bug
- NativeImage lightMapPixels = tex.lightPixels;
- LightMapWrapper lightMap = new LightMapWrapper(lightMapPixels);
-
-
- int lightMapHeight = getLightmapTextureHeight();
- int lightMapWidth = getLightmapTextureWidth();
-
- int[] pixels = new int[lightMapWidth * lightMapHeight];
- for (int u = 0; u < lightMapWidth; u++)
- {
- for (int v = 0; v < lightMapWidth; v++)
- {
- // 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));
-
- // these should both create a totally white image
+
+ @Override
+ public int[] getLightmapPixels()
+ {
+ LightTexture tex = GAME_RENDERER.lightTexture();
+ tex.tick(); // This call makes no sense, but it fixes pause menu flicker bug
+ NativeImage lightMapPixels = tex.lightPixels;
+ LightMapWrapper lightMap = new LightMapWrapper(lightMapPixels);
+
+
+ int lightMapHeight = getLightmapTextureHeight();
+ int lightMapWidth = getLightmapTextureWidth();
+
+ int[] pixels = new int[lightMapWidth * lightMapHeight];
+ for (int u = 0; u < lightMapWidth; u++)
+ {
+ for (int v = 0; v < lightMapWidth; v++)
+ {
+ // 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));
+
+ // these should both create a totally white image
// int col =
// Integer.MAX_VALUE;
// int col =
@@ -222,82 +245,82 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
// (0b11111111 << 8) + // green
// (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
-
- // 2D array stored in a 1D array.
- // Thank you Tim from College ;)
- pixels[u * lightMapWidth + v] = col;
- }
- }
-
- return pixels;
- }
-
-
- @Override
- public int getLightmapTextureHeight()
- {
- int height = -1;
-
- LightTexture lightTexture = GAME_RENDERER.lightTexture();
- if (lightTexture != null)
- {
- NativeImage tex = lightTexture.lightPixels;
- if (tex != null)
- {
- height = tex.getHeight();
- }
- }
-
- return height;
- }
-
- @Override
- public int getLightmapTextureWidth()
- {
- int width = -1;
-
- LightTexture lightTexture = GAME_RENDERER.lightTexture();
- if (lightTexture != null)
- {
- NativeImage tex = lightTexture.lightPixels;
- if (tex != null)
- {
- width = tex.getWidth();
- }
- }
-
- return width;
- }
-
-
- @Override
- public int getLightmapGLFormat() {
- int glFormat = -1;
-
- LightTexture lightTexture = GAME_RENDERER.lightTexture();
- if (lightTexture != null) {
- NativeImage tex = lightTexture.lightPixels;
- if (tex != null) {
- glFormat = tex.format().glFormat();
- }
- }
-
- return glFormat;
- }
-
- @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;
- }
-
+
+ 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 ;)
+ pixels[u * lightMapWidth + v] = col;
+ }
+ }
+
+ return pixels;
+ }
+
+
+ @Override
+ public int getLightmapTextureHeight()
+ {
+ int height = -1;
+
+ LightTexture lightTexture = GAME_RENDERER.lightTexture();
+ if (lightTexture != null)
+ {
+ NativeImage tex = lightTexture.lightPixels;
+ if (tex != null)
+ {
+ height = tex.getHeight();
+ }
+ }
+
+ return height;
+ }
+
+ @Override
+ public int getLightmapTextureWidth()
+ {
+ int width = -1;
+
+ LightTexture lightTexture = GAME_RENDERER.lightTexture();
+ if (lightTexture != null)
+ {
+ NativeImage tex = lightTexture.lightPixels;
+ if (tex != null)
+ {
+ width = tex.getWidth();
+ }
+ }
+
+ return width;
+ }
+
+
+ @Override
+ public int getLightmapGLFormat() {
+ int glFormat = -1;
+
+ LightTexture lightTexture = GAME_RENDERER.lightTexture();
+ if (lightTexture != null) {
+ NativeImage tex = lightTexture.lightPixels;
+ if (tex != null) {
+ glFormat = tex.format().glFormat();
+ }
+ }
+
+ return glFormat;
+ }
+
+ @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;
+ }
+
@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/WorldWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/world/WorldWrapper.java
index 22c578721..cdc85e6a0 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;
@@ -50,12 +51,12 @@ public class WorldWrapper implements IWorldWrapper
private static final ConcurrentMap worldWrapperMap = new ConcurrentHashMap<>();
private final LevelAccessor world;
public final WorldType worldType;
-
-
+
+
public WorldWrapper(LevelAccessor newWorld)
{
world = newWorld;
-
+
if (world.getClass() == ServerLevel.class)
worldType = WorldType.ServerWorld;
else if (world.getClass() == ClientLevel.class)
@@ -63,8 +64,8 @@ public class WorldWrapper implements IWorldWrapper
else
worldType = WorldType.Unknown;
}
-
-
+
+
@Nullable
public static WorldWrapper getWorldWrapper(LevelAccessor world)
{
@@ -72,56 +73,56 @@ public class WorldWrapper implements IWorldWrapper
//first we check if the biome has already been wrapped
if(worldWrapperMap.containsKey(world) && worldWrapperMap.get(world) != null)
return worldWrapperMap.get(world);
-
-
+
+
//if it hasn't been created yet, we create it and save it in the map
WorldWrapper worldWrapper = new WorldWrapper(world);
worldWrapperMap.put(world, worldWrapper);
-
+
//we return the newly created wrapper
return worldWrapper;
}
-
+
public static void clearMap()
{
worldWrapperMap.clear();
}
-
+
@Override
public WorldType getWorldType()
{
return worldType;
}
-
+
@Override
public DimensionTypeWrapper getDimensionType()
{
return DimensionTypeWrapper.getDimensionTypeWrapper(world.dimensionType());
}
-
+
@Override
public int getBlockLight(int x, int y, int z)
{
return world.getBrightness(LightLayer.BLOCK, new BlockPos(x,y,z));
}
-
+
@Override
public int getSkyLight(int x, int y, int z)
{
return world.getBrightness(LightLayer.SKY, new BlockPos(x,y,z));
}
-
+
public LevelAccessor getWorld()
{
return world;
}
-
+
@Override
public boolean hasCeiling()
{
return world.dimensionType().hasCeiling();
}
-
+
@Override
public boolean hasSkyLight()
{
@@ -133,7 +134,7 @@ public class WorldWrapper implements IWorldWrapper
{
return world.getHeight();
}
-
+
@Override
public short getMinHeight()
{
@@ -146,21 +147,21 @@ public class WorldWrapper implements IWorldWrapper
{
if (worldType != WorldType.ServerWorld)
throw new UnsupportedOperationException("getSaveFolder can only be called for ServerWorlds.");
-
+
ServerChunkCache chunkSource = ((ServerLevel) world).getChunkSource();
return chunkSource.getDataStorage().dataFolder;
}
-
-
+
+
/** @throws UnsupportedOperationException if the WorldWrapper isn't for a ServerWorld */
public ServerLevel getServerWorld() throws UnsupportedOperationException
{
if (worldType != WorldType.ServerWorld)
throw new UnsupportedOperationException("getSaveFolder can only be called for ServerWorlds.");
-
+
return (ServerLevel) world;
}
-
+
@Override
public int getSeaLevel()
{
@@ -169,11 +170,18 @@ public class WorldWrapper implements IWorldWrapper
}
@Override
- public IChunkWrapper tryGetChunk(AbstractChunkPosWrapper pos) {
- ChunkAccess chunk = world.getChunk(pos.getX(), pos.getZ(), ChunkStatus.EMPTY, false);
- if (chunk == null) return null;
- return new ChunkWrapper(chunk, world);
+ public IChunkWrapper tryGetChunk(AbstractChunkPosWrapper pos) {
+ ChunkAccess chunk = world.getChunk(pos.getX(), pos.getZ(), ChunkStatus.EMPTY, false);
+ if (chunk == null) return null;
+ 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 142c859cf..5945ddee4 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
@@ -20,14 +20,13 @@
package com.seibel.lod.common.wrappers.worldGeneration;
import com.seibel.lod.core.api.ApiShared;
-import com.seibel.lod.core.api.ClientApi;
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.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.objects.lod.LodDimension;
-import com.seibel.lod.core.util.GridList;
+import com.seibel.lod.core.util.gridList.ArrayGridList;
import com.seibel.lod.core.util.LodThreadFactory;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
@@ -191,7 +190,6 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
if (e.endNano != 0)
{
lodTime.add(e.endNano - preTime);
- preTime = e.endNano;
}
}
@@ -215,7 +213,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);
@@ -230,12 +228,13 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
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);
@@ -384,22 +383,20 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
if (ENABLE_EVENT_LOGGING)
ApiShared.LOGGER.info("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) ->
{
@@ -418,23 +415,19 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
params.biomes, null);
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);
-
+ 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)
{
@@ -466,14 +459,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);
ChunkWrapper wrappedChunk = new ChunkWrapper(target, region);
if (!wrappedChunk.isLightCorrect()) {
throw new RuntimeException("The generated chunk somehow has isLightCorrect() returning false");
@@ -521,8 +512,8 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
}
}
- public GridList generateDirect(GenerationEvent e, GridList subRange, Steps step,
- LightedWorldGenRegion region)
+ public void generateDirect(GenerationEvent e, ArrayGridList subRange, Steps step,
+ LightedWorldGenRegion region)
{
try
{
@@ -535,38 +526,37 @@ 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;
}
finally
{
diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GlobalParameters.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GlobalParameters.java
index 9c0977a13..47085aca1 100644
--- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GlobalParameters.java
+++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GlobalParameters.java
@@ -5,7 +5,6 @@ import com.mojang.datafixers.DataFixer;
import com.seibel.lod.core.builders.lodBuilding.LodBuilder;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.objects.lod.LodDimension;
-import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
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 599af6dcf..000000000
--- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/WorldGeneratorWrapper.java
+++ /dev/null
@@ -1,153 +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.wrapperInterfaces.chunk.AbstractChunkPosWrapper;
-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.world.level.chunk.*;
-/* */
-/* */ import net.minecraft.server.level.ServerLevel;
-/* */
-/* */
-/* */
-/* */
-/* */
-/* */
-/* */
-/* */
-/* */
-
-/**
- * @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 wants 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: Update this 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)
- */
-}
\ No newline at end of file
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 8f85309a2..b482312d7 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
@@ -15,6 +15,12 @@ import java.util.Locale;
import java.util.Map;
import java.util.Objects;
+#if MC_VERSION_1_18_2
+import net.minecraft.core.Holder;
+import net.minecraft.core.RegistryAccess;
+import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
+#endif
+
import net.minecraft.core.Registry;
import net.minecraft.core.SectionPos;
import net.minecraft.nbt.CompoundTag;
@@ -54,7 +60,7 @@ public class ChunkLoader
private static final String TAG_UPGRADE_DATA = "UpgradeData";
private static final String BLOCK_TICKS_TAG = "block_ticks";
private static final String FLUID_TICKS_TAG = "fluid_ticks";
-
+
private static BlendingData readBlendingData(CompoundTag chunkData)
{
BlendingData blendingData = null;
@@ -66,12 +72,17 @@ public class ChunkLoader
}
return blendingData;
}
-
+
private static LevelChunkSection[] readSections(LevelAccessor level, LevelLightEngine lightEngine, ChunkPos chunkPos, CompoundTag chunkData)
{
Registry biomes = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY);
+ #if MC_VERSION_1_18_1
Codec> biomeCodec = PalettedContainer.codec(
biomes, biomes.byNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getOrThrow(Biomes.PLAINS));
+ #elif MC_VERSION_1_18_2
+ Codec>> biomeCodec = PalettedContainer.codec(
+ biomes.asHolderIdMap(), biomes.holderByNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getHolderOrThrow(Biomes.PLAINS));
+ #endif
int i = level.getSectionsCount();
LevelChunkSection[] chunkSections = new LevelChunkSection[i];
@@ -88,15 +99,26 @@ public class ChunkLoader
if (sectionId >= 0 && sectionId < chunkSections.length)
{
PalettedContainer blockStateContainer;
+ #if MC_VERSION_1_18_1
PalettedContainer biomeContainer;
+ #elif MC_VERSION_1_18_2
+ PalettedContainer> biomeContainer;
+ #endif
blockStateContainer = tagSection.contains("block_states", 10)
? BLOCK_STATE_CODEC.parse(NbtOps.INSTANCE, tagSection.getCompound("block_states")).promotePartial(string -> logErrors(chunkPos, sectionYPos, string)).getOrThrow(false, LOGGER::error)
: new PalettedContainer(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES);
+ #if MC_VERSION_1_18_1
biomeContainer = tagSection.contains("biomes", 10)
? biomeCodec.parse(NbtOps.INSTANCE, tagSection.getCompound("biomes")).promotePartial(string -> logErrors(chunkPos, sectionYPos, string)).getOrThrow(false, LOGGER::error)
: new PalettedContainer(biomes, biomes.getOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES);
+ #elif MC_VERSION_1_18_2
+ biomeContainer = tagSection.contains("biomes", 10)
+ ? biomeCodec.parse(NbtOps.INSTANCE, tagSection.getCompound("biomes")).promotePartial(string -> logErrors(chunkPos, i, (String) string)).getOrThrow(false, LOGGER::error)
+ : new PalettedContainer>(biomes.asHolderIdMap(), biomes.getHolderOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES);
+ #endif
+
chunkSections[sectionId] = new LevelChunkSection(sectionYPos, blockStateContainer, biomeContainer);
}
@@ -111,7 +133,7 @@ public class ChunkLoader
}
return chunkSections;
}
-
+
private static void readHeightmaps(LevelChunk chunk, CompoundTag chunkData)
{
CompoundTag tagHeightmaps = chunkData.getCompound("Heightmaps");
@@ -124,6 +146,7 @@ public class ChunkLoader
Heightmap.primeHeightmaps(chunk, ChunkStatus.FULL.heightmapsAfter());
}
+ #if MC_VERSION_1_18_1
private static Map, StructureStart>> unpackStructureStart(StructurePieceSerializationContext structurePieceSerializationContext, CompoundTag compoundTag, long l)
{
HashMap, StructureStart>> map = Maps.newHashMap();
@@ -171,15 +194,67 @@ public class ChunkLoader
}
return map;
}
+ #elif MC_VERSION_1_18_2
+ private static Map, StructureStart> unpackStructureStart(StructurePieceSerializationContext structurePieceSerializationContext, CompoundTag compoundTag, long l) {
+ Map, StructureStart> map = Maps.newHashMap();
+ Registry> structStartRegistry = structurePieceSerializationContext.registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY);
+ CompoundTag compoundTag2 = compoundTag.getCompound("starts");
+ for (String string : compoundTag2.getAllKeys()) {
+ ResourceLocation resourceLocation = ResourceLocation.tryParse(string);
+ ConfiguredStructureFeature, ?> structureFeature = structStartRegistry.get(resourceLocation);
+// String string2 = string.toLowerCase(Locale.ROOT);
+// ConfiguredStructureFeature, ?> structureFeature = StructureFeature.STRUCTURES_REGISTRY.get(string2);
+ if (structureFeature == null) {
+ LOGGER.error("Unknown structure start: {}", resourceLocation);
+ continue;
+ }
+ StructureStart structureStart = StructureFeature.loadStaticStart(structurePieceSerializationContext, compoundTag2.getCompound(string), l);
+ if (structureStart == null)
+ continue;
+ map.put(structureFeature, structureStart);
+ }
+ return map;
+ }
+
+ private static Map, LongSet> unpackStructureReferences(RegistryAccess registryAccess, ChunkPos chunkPos, CompoundTag compoundTag)
+ {
+ Map, LongSet> map = Maps.newHashMap();
+ Registry> structRegistry = registryAccess.registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY);
+ CompoundTag compoundTag2 = compoundTag.getCompound("References");
+ for (String string : compoundTag2.getAllKeys())
+ {
+ ResourceLocation resourceLocation = ResourceLocation.tryParse(string);
+ ConfiguredStructureFeature, ?> structureFeature = structRegistry.get(resourceLocation);
+// String string2 = string.toLowerCase(Locale.ROOT);
+// ConfiguredStructureFeature, ?> structureFeature = StructureFeature.STRUCTURES_REGISTRY.get(string2);
+ if (structureFeature == null)
+ {
+ LOGGER.warn("Found reference to unknown structure '{}' in chunk {}, discarding", resourceLocation, chunkPos);
+ continue;
+ }
+ map.put(structureFeature, new LongOpenHashSet(Arrays.stream(compoundTag2.getLongArray(string)).filter(l ->
+ {
+ ChunkPos chunkPos2 = new ChunkPos(l);
+ if (chunkPos2.getChessboardDistance(chunkPos) > 8)
+ {
+ LOGGER.warn("Found invalid structure reference [ {} @ {} ] for chunk {}.", resourceLocation, chunkPos2, chunkPos);
+ return false;
+ }
+ return true;
+ }).toArray()));
+ }
+ return map;
+ }
+ #endif
private static void readStructures(WorldGenLevel level, LevelChunk chunk, CompoundTag chunkData)
{
CompoundTag tagStructures = chunkData.getCompound("structures");
chunk.setAllStarts(
unpackStructureStart(StructurePieceSerializationContext.fromLevel(level.getLevel()), tagStructures, level.getSeed()));
- chunk.setAllReferences(unpackStructureReferences(chunk.getPos(), tagStructures));
+ chunk.setAllReferences(unpackStructureReferences(#if MC_VERSION_1_18_2 level.registryAccess() ,#endif chunk.getPos(), tagStructures));
}
-
+
private static void readPostPocessings(LevelChunk chunk, CompoundTag chunkData)
{
ListTag tagPostProcessings = chunkData.getList("PostProcessing", 9);
@@ -192,32 +267,32 @@ public class ChunkLoader
}
}
}
-
+
public static ChunkStatus.ChunkType readChunkType(CompoundTag compoundTag)
{
return ChunkStatus.byName(compoundTag.getString("Status")).getChunkType();
}
-
+
public static LevelChunk read(WorldGenLevel level, LevelLightEngine lightEngine, ChunkPos chunkPos, CompoundTag chunkData)
{
-
+
ChunkPos actualPos = new ChunkPos(chunkData.getInt("xPos"), chunkData.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);
return null;
}
-
+
ChunkStatus.ChunkType chunkType = readChunkType(chunkData);
BlendingData blendingData = readBlendingData(chunkData);
if (chunkType == ChunkStatus.ChunkType.PROTOCHUNK && (blendingData == null || !blendingData.oldNoise()))
return null;
-
+
// Prepare the light engine
boolean isLightOn = chunkData.getBoolean("isLightOn");
if (isLightOn)
level.getLightEngine().retainData(chunkPos, true);
-
+
// Read params for making the LevelChunk
UpgradeData upgradeData = chunkData.contains(TAG_UPGRADE_DATA, 10)
? new UpgradeData(chunkData.getCompound(TAG_UPGRADE_DATA), level)
@@ -228,10 +303,10 @@ public class ChunkLoader
string -> Registry.FLUID.getOptional(ResourceLocation.tryParse(string)), chunkPos);
long inhabitedTime = chunkData.getLong("InhabitedTime");
LevelChunkSection[] chunkSections = readSections(level, lightEngine, actualPos, chunkData);
-
+
// Make chunk
LevelChunk chunk = new LevelChunk((Level) level, chunkPos, upgradeData, blockTicks, fluidTicks, inhabitedTime, chunkSections, null, blendingData);
-
+
// Set some states after object creation
chunk.setLightCorrect(isLightOn);
readHeightmaps(chunk, chunkData);
@@ -239,7 +314,7 @@ public class ChunkLoader
readPostPocessings(chunk, chunkData);
return chunk;
}
-
+
private static void logErrors(ChunkPos chunkPos, int i, String string)
{
LOGGER.error("Distant Horizons: Recoverable errors when loading section [" + chunkPos.x + ", " + i + ", " + chunkPos.z + "]: " + string);
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 cc78f587e..d754a6d0f 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
@@ -61,12 +61,12 @@ public class LightedWorldGenRegion extends WorldGenRegion {
writeRadius = i;
cache = list;
size = Mth.floor(Math.sqrt(list.size()));
-
- this.tintCaches = Util.make(new Object2ObjectArrayMap(3), object2ObjectArrayMap -> {
- object2ObjectArrayMap.put(BiomeColors.GRASS_COLOR_RESOLVER, new BlockTintCache((pos) -> {return calculateBlockTint(pos, BiomeColors.GRASS_COLOR_RESOLVER);}));
- object2ObjectArrayMap.put(BiomeColors.FOLIAGE_COLOR_RESOLVER, new BlockTintCache((pos) -> {return calculateBlockTint(pos, BiomeColors.FOLIAGE_COLOR_RESOLVER);}));
- object2ObjectArrayMap.put(BiomeColors.WATER_COLOR_RESOLVER, new BlockTintCache((pos) -> {return calculateBlockTint(pos, BiomeColors.WATER_COLOR_RESOLVER);}));
- });
+
+ this.tintCaches = Util.make(new Object2ObjectArrayMap(3), object2ObjectArrayMap -> {
+ object2ObjectArrayMap.put(BiomeColors.GRASS_COLOR_RESOLVER, new BlockTintCache((pos) -> {return calculateBlockTint(pos, BiomeColors.GRASS_COLOR_RESOLVER);}));
+ object2ObjectArrayMap.put(BiomeColors.FOLIAGE_COLOR_RESOLVER, new BlockTintCache((pos) -> {return calculateBlockTint(pos, BiomeColors.FOLIAGE_COLOR_RESOLVER);}));
+ object2ObjectArrayMap.put(BiomeColors.WATER_COLOR_RESOLVER, new BlockTintCache((pos) -> {return calculateBlockTint(pos, BiomeColors.WATER_COLOR_RESOLVER);}));
+ });
}
// Bypass BCLib mixin overrides.
@@ -90,6 +90,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) {
@@ -231,20 +238,29 @@ public class LightedWorldGenRegion extends WorldGenRegion {
return (getBrightness(LightLayer.SKY, blockPos) >= getMaxLightLevel());
}
-
+
+
private final Object2ObjectArrayMap tintCaches;
-
+
public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver)
{
BlockTintCache blockTintCache = (BlockTintCache) this.tintCaches.get(colorResolver);
return blockTintCache.getColor(blockPos);
}
+ private Biome _getBiome(BlockPos pos) {
+ #if MC_VERSION_1_18_2
+ return getBiome(pos).value();
+ #elif MC_VERSION_1_18_1
+ return getBiome(pos);
+ #endif
+ }
+
public int calculateBlockTint(BlockPos blockPos, ColorResolver colorResolver)
{
int i = (Minecraft.getInstance()).options.biomeBlendRadius;
if (i == 0)
- return colorResolver.getColor((Biome) getBiome(blockPos), blockPos.getX(), blockPos.getZ());
+ return colorResolver.getColor((Biome) _getBiome(blockPos), blockPos.getX(), blockPos.getZ());
int j = (i * 2 + 1) * (i * 2 + 1);
int k = 0;
int l = 0;
@@ -254,11 +270,12 @@ public class LightedWorldGenRegion extends WorldGenRegion {
while (cursor3D.advance())
{
mutableBlockPos.set(cursor3D.nextX(), cursor3D.nextY(), cursor3D.nextZ());
- int n = colorResolver.getColor((Biome) getBiome((BlockPos) mutableBlockPos), mutableBlockPos.getX(), mutableBlockPos.getZ());
+ int n = colorResolver.getColor((Biome) _getBiome((BlockPos) mutableBlockPos), mutableBlockPos.getX(), mutableBlockPos.getZ());
k += (n & 0xFF0000) >> 16;
l += (n & 0xFF00) >> 8;
m += n & 0xFF;
}
return (k / j & 0xFF) << 16 | (l / j & 0xFF) << 8 | m / j & 0xFF;
}
+
}
\ No newline at end of file
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 ee14b5ee5..a17fa172e 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
@@ -4,7 +4,7 @@ import java.util.ArrayList;
import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment;
import com.seibel.lod.common.wrappers.worldGeneration.ThreadedParameters;
-import com.seibel.lod.core.util.GridList;
+import com.seibel.lod.core.util.gridList.ArrayGridList;
import net.minecraft.ReportedException;
import net.minecraft.server.level.WorldGenRegion;
@@ -30,7 +30,7 @@ public final class StepFeatures {
public final ChunkStatus STATUS = ChunkStatus.FEATURES;
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion,
- GridList chunks) {
+ 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 b2d1a84bd..90ef6ef5b 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,7 +2,7 @@ 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;
@@ -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 76ee5a3ba..564f2d77b 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
@@ -22,9 +22,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/levelgen/NoiseBasedChunkGenerator settings Ljava/util/function/Supplier;
+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 method net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator doFill (Lnet/minecraft/world/level/levelgen/blending/Blender;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;II)Lnet/minecraft/world/level/chunk/ChunkAccess;
-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 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/lighting/LayerLightEngine queueSectionData (JLnet/minecraft/world/level/chunk/DataLayer;Z)V
# lod generation from save file
diff --git a/core b/core
index bca2b6180..6cd0281d0 160000
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit bca2b61800b613b630def131e9c9f85f9736493d
+Subproject commit 6cd0281d0e1a2a76be26d166c3127b2521e8fd79
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 c238f165d..ef7c35924 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.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
@@ -29,6 +30,7 @@ import com.seibel.lod.common.wrappers.world.WorldWrapper;
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
+import com.seibel.lod.fabric.mixins.MixinUtilBackgroudThread;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
@@ -43,6 +45,7 @@ import net.minecraft.world.level.chunk.LevelChunk;
import java.util.HashSet;
import java.util.List;
+import java.util.function.Supplier;
import org.lwjgl.glfw.GLFW;
@@ -59,6 +62,7 @@ public class ClientProxy
private final EventApi eventApi = EventApi.INSTANCE;
private final ClientApi clientApi = ClientApi.INSTANCE;
+ public static Supplier isGenerationThreadChecker = null;
/**
* Registers Fabric Events
@@ -88,6 +92,8 @@ 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/Main.java b/fabric/src/main/java/com/seibel/lod/fabric/Main.java
index 16cddd4b7..b4b61d90f 100644
--- a/fabric/src/main/java/com/seibel/lod/fabric/Main.java
+++ b/fabric/src/main/java/com/seibel/lod/fabric/Main.java
@@ -82,7 +82,7 @@ public class Main implements ClientModInitializer
if (SingletonHandler.get(IModChecker.class).isModLoaded("optifine")) {
ModAccessorHandler.bind(IOptifineAccessor.class, new OptifineAccessor());
}
-
+
ModAccessorHandler.finishBinding();
}
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 e2a1536e1..327aaadca 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
@@ -3,14 +3,12 @@ package com.seibel.lod.fabric.mixins;
import java.util.concurrent.ExecutorService;
import java.util.function.Supplier;
+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;
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;
@@ -23,7 +21,7 @@ public class MixinUtilBackgroudThread
at = @At("HEAD"), cancellable = true)
private static void overrideUtil$wrapThreadWithTaskName(String string, Runnable r, CallbackInfoReturnable ci)
{
- if (DependencySetupDoneCheck.isDone && BatchGenerationEnvironment.isCurrentThreadDistantGeneratorThread())
+ if (ClientProxy.isGenerationThreadChecker != null && ClientProxy.isGenerationThreadChecker.get())
{
//ApiShared.LOGGER.info("util wrapThreadWithTaskName(Runnable) triggered");
ci.setReturnValue(r);
@@ -33,7 +31,7 @@ public class MixinUtilBackgroudThread
at = @At("HEAD"), cancellable = true)
private static void overrideUtil$wrapThreadWithTaskNameForSupplier(String string, Supplier> r, CallbackInfoReturnable> ci)
{
- if (DependencySetupDoneCheck.isDone && BatchGenerationEnvironment.isCurrentThreadDistantGeneratorThread())
+ if (ClientProxy.isGenerationThreadChecker != null && ClientProxy.isGenerationThreadChecker.get())
{
//ApiShared.LOGGER.info("util wrapThreadWithTaskName(Supplier) triggered");
ci.setReturnValue(r);
@@ -43,7 +41,7 @@ public class MixinUtilBackgroudThread
@Inject(method = "backgroundExecutor", at = @At("HEAD"), cancellable = true)
private static void overrideUtil$backgroundExecutor(CallbackInfoReturnable ci)
{
- if (DependencySetupDoneCheck.isDone && BatchGenerationEnvironment.isCurrentThreadDistantGeneratorThread())
+ if (ClientProxy.isGenerationThreadChecker != null && ClientProxy.isGenerationThreadChecker.get())
{
//ApiShared.LOGGER.info("util backgroundExecutor triggered");
ci.setReturnValue(new DummyRunExecutorService());
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..5af847ea4 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
@@ -24,6 +24,7 @@ import com.mojang.math.Matrix4f;
import com.seibel.lod.common.wrappers.McObjectConverter;
import com.seibel.lod.core.api.ClientApi;
import com.seibel.lod.core.objects.math.Mat4f;
+import net.minecraft.client.Camera;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.RenderType;
import org.spongepowered.asm.mixin.Mixin;
@@ -61,7 +62,25 @@ 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("RETURN"),
+ method = "renderSky",
+ cancellable = true)
+ private void renderLod(PoseStack modelViewMatrixStack, Matrix4f projectionMatrix, float f,
+ #if MC_VERSION_1_18_2 Camera camera, boolean bl,#endif Runnable r, CallbackInfo callback) {
+
+ Mat4f mcModelViewMatrix = McObjectConverter.Convert(modelViewMatrixStack.last().pose());
+ Mat4f mcProjectionMatrix = McObjectConverter.Convert(projectionMatrix);
+
+ ClientApi.INSTANCE.renderLods(mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
+
+ }
+
+ /*
+
+ // HEAD or RETURN
+ @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 +91,6 @@ public class MixinWorldRenderer
ClientApi.INSTANCE.renderLods(mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
}
- }
+ //callback.cancel();
+ }*/
}
diff --git a/fabric/src/main/java/com/seibel/lod/fabric/mixins/events/MixinClientLevel.java b/fabric/src/main/java/com/seibel/lod/fabric/mixins/events/MixinClientLevel.java
index e08fed0d5..df7e92345 100644
--- a/fabric/src/main/java/com/seibel/lod/fabric/mixins/events/MixinClientLevel.java
+++ b/fabric/src/main/java/com/seibel/lod/fabric/mixins/events/MixinClientLevel.java
@@ -4,6 +4,9 @@ import com.seibel.lod.fabric.Main;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.renderer.LevelRenderer;
+#if MC_VERSION_1_18_2
+import net.minecraft.core.Holder;
+#endif
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.dimension.DimensionType;
@@ -18,12 +21,21 @@ import java.util.function.Supplier;
* This class is used for world loading events
* @author Ran
*/
+
@Mixin(ClientLevel.class)
public class MixinClientLevel {
+ #if MC_VERSION_1_18_2
+ @Inject(method = "", at = @At("TAIL"))
+ private void loadWorldEvent(ClientPacketListener clientPacketListener, ClientLevel.ClientLevelData clientLevelData, ResourceKey resourceKey, Holder holder, int i, int j, Supplier supplier, LevelRenderer levelRenderer, boolean bl, long l, CallbackInfo ci) {
+ Main.client_proxy.worldLoadEvent((ClientLevel) (Object) this);
+ }
+ #elif MC_VERSION_1_18_1
@Inject(method = "", at = @At("TAIL"))
private void loadWorldEvent(ClientPacketListener clientPacketListener, ClientLevel.ClientLevelData clientLevelData, ResourceKey resourceKey, DimensionType dimensionType, int i, int j, Supplier supplier, LevelRenderer levelRenderer, boolean bl, long l, CallbackInfo ci) {
Main.client_proxy.worldLoadEvent((ClientLevel) (Object) this);
}
+ #endif
+
@Inject(method = "setLightReady", at = @At("HEAD"))
private void onChunkLightReady(int x, int z, CallbackInfo ci) {
ClientLevel l = (ClientLevel) (Object) this;
diff --git a/fabric/src/main/java/com/seibel/lod/fabric/wrappers/FabricDependencySetup.java b/fabric/src/main/java/com/seibel/lod/fabric/wrappers/FabricDependencySetup.java
index 11ed7342e..f412b35d0 100644
--- a/fabric/src/main/java/com/seibel/lod/fabric/wrappers/FabricDependencySetup.java
+++ b/fabric/src/main/java/com/seibel/lod/fabric/wrappers/FabricDependencySetup.java
@@ -2,12 +2,12 @@ package com.seibel.lod.fabric.wrappers;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
+import com.seibel.lod.common.wrappers.config.LodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker;
import com.seibel.lod.fabric.wrappers.modAccessor.ModChecker;
-import com.seibel.lod.common.wrappers.config.LodConfigWrapperSingleton;
/**
- * Binds all necessary dependencies so we
+ * Binds all necessary dependencies, so we
* can access them in Core.
* This needs to be called before any Core classes
* are loaded.
@@ -21,11 +21,11 @@ public class FabricDependencySetup
public static void createInitialBindings()
{
SingletonHandler.bind(IModChecker.class, ModChecker.INSTANCE);
+
SingletonHandler.bind(ILodConfigWrapperSingleton.class, LodConfigWrapperSingleton.INSTANCE);
}
-
- public static void finishBinding()
- {
+
+ public static void finishBinding() {
SingletonHandler.finishBinding();
}
}
diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json
index deff79ab6..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.18", "1.18.1"],
- "java": ">=17"
+ "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 72ea391c0..0bc4ff7be 100644
--- a/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java
+++ b/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java
@@ -89,6 +89,8 @@ public class ForgeMain implements LodForgeMethodCaller
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/wrappers/ForgeDependencySetup.java b/forge/src/main/java/com/seibel/lod/forge/wrappers/ForgeDependencySetup.java
index aba936f72..bd1a13df8 100644
--- a/forge/src/main/java/com/seibel/lod/forge/wrappers/ForgeDependencySetup.java
+++ b/forge/src/main/java/com/seibel/lod/forge/wrappers/ForgeDependencySetup.java
@@ -1,5 +1,6 @@
package com.seibel.lod.forge.wrappers;
+import com.seibel.lod.common.LodCommonMain;
import com.seibel.lod.common.wrappers.config.LodConfigWrapperSingleton;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
@@ -14,16 +15,17 @@ import com.seibel.lod.forge.wrappers.modAccessor.ModChecker;
*
* @author James Seibel
* @author Ran
- * @version 3-5-2022
+ * @version 12-1-2021
*/
public class ForgeDependencySetup
{
public static void createInitialBindings()
{
SingletonHandler.bind(IModChecker.class, ModChecker.INSTANCE);
+
SingletonHandler.bind(ILodConfigWrapperSingleton.class, LodConfigWrapperSingleton.INSTANCE);
}
-
+
public static void finishBinding()
{
SingletonHandler.finishBinding();
diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml
index 38d065a59..e3764750e 100644
--- a/forge/src/main/resources/META-INF/mods.toml
+++ b/forge/src/main/resources/META-INF/mods.toml
@@ -1,6 +1,6 @@
modLoader="javafml" #//mandatory
-loaderVersion="[37,40)" # // mandatory. This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
+loaderVersion="[36,41)" # // mandatory. This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
license="GNU GPLv3"
issueTrackerURL="${issues}"
diff --git a/gradle.properties b/gradle.properties
index 43e9a1e7c..1188a0d96 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,13 +1,11 @@
org.gradle.jvmargs=-Xmx2048M
+org.gradle.daemon=false
-minecraft_version=1.18.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
-# Fabric loader
-fabric_loader_version=0.13.2
-fabric_api_version=0.46.4+1.18
- # Fabric mod versions
- modmenu_version=3.0.1
- 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
+# Global Plugin versions
+toml_version=3.6.4
+manifold_version=2022.1.7
- # 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.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
+##### FOR IDE SUPPORT AND TELL IDE TO USE CERTIAN MC VERSION: SWITCH THIS:
+mcVer=1.18.2
\ No newline at end of file