Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1e6eb4c096 | |||
| 618707533b | |||
| 2d7e2e2444 |
@@ -60,15 +60,16 @@ public class DhApi
|
|||||||
*
|
*
|
||||||
* Note: Don't use this string in your code. It may change and is only for reference.
|
* Note: Don't use this string in your code. It may change and is only for reference.
|
||||||
*/
|
*/
|
||||||
public static final String READ_ME =
|
public static final String READ_ME =
|
||||||
"""
|
"If you don't see Javadocs something is wrong. \n" +
|
||||||
If you don't see Javadocs something is wrong.
|
"If you are only using the full DH Mod in your build script, you won't have access to our javadocs and could potentially call into unsafe code. \n" +
|
||||||
If you are only using the full DH Mod in your build script, you won't have access to our javadocs and could potentially call into unsafe code.
|
"\n" +
|
||||||
|
"Please use the API jar in your build script as a compile time dependency " +
|
||||||
Please use the API jar in your build script as a compile time dependency and the full DH jar as a runtime dependency.
|
"and the full DH jar as a runtime dependency. \n" +
|
||||||
|
"\n" +
|
||||||
Please refer to the example API project or the DH Developer Wiki for additional information and suggested setup.
|
"Please refer to the example API project or the DH Developer Wiki for additional information " +
|
||||||
"""; // DH Dev note: no links were included to prevent link rot.
|
"and suggested setup. \n" + // DH Dev note: no links were included to prevent link rot.
|
||||||
|
"";
|
||||||
public static String readMe() { return READ_ME; }
|
public static String readMe() { return READ_ME; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+24
-13
@@ -56,23 +56,34 @@ public enum EDhApiDebugRendering
|
|||||||
|
|
||||||
public static EDhApiDebugRendering next(EDhApiDebugRendering type)
|
public static EDhApiDebugRendering next(EDhApiDebugRendering type)
|
||||||
{
|
{
|
||||||
return switch (type) {
|
switch (type)
|
||||||
case OFF -> SHOW_DETAIL;
|
{
|
||||||
case SHOW_DETAIL -> SHOW_BLOCK_MATERIAL;
|
case OFF:
|
||||||
case SHOW_BLOCK_MATERIAL -> SHOW_OVERLAPPING_QUADS;
|
return SHOW_DETAIL;
|
||||||
case SHOW_OVERLAPPING_QUADS -> SHOW_RENDER_SOURCE_FLAG;
|
case SHOW_DETAIL:
|
||||||
default -> OFF;
|
return SHOW_BLOCK_MATERIAL;
|
||||||
};
|
case SHOW_BLOCK_MATERIAL:
|
||||||
|
return SHOW_OVERLAPPING_QUADS;
|
||||||
|
case SHOW_OVERLAPPING_QUADS:
|
||||||
|
return SHOW_RENDER_SOURCE_FLAG;
|
||||||
|
default:
|
||||||
|
return OFF;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EDhApiDebugRendering previous(EDhApiDebugRendering type)
|
public static EDhApiDebugRendering previous(EDhApiDebugRendering type)
|
||||||
{
|
{
|
||||||
return switch (type) {
|
switch (type)
|
||||||
case OFF -> SHOW_RENDER_SOURCE_FLAG;
|
{
|
||||||
case SHOW_RENDER_SOURCE_FLAG -> SHOW_OVERLAPPING_QUADS;
|
case OFF:
|
||||||
case SHOW_OVERLAPPING_QUADS -> SHOW_DETAIL;
|
return SHOW_RENDER_SOURCE_FLAG;
|
||||||
default -> OFF;
|
case SHOW_RENDER_SOURCE_FLAG:
|
||||||
};
|
return SHOW_OVERLAPPING_QUADS;
|
||||||
|
case SHOW_OVERLAPPING_QUADS:
|
||||||
|
return SHOW_DETAIL;
|
||||||
|
default:
|
||||||
|
return OFF;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-10
@@ -42,21 +42,29 @@ public enum EDhApiRendererMode
|
|||||||
/** Used by the config GUI to cycle through the available rendering options */
|
/** Used by the config GUI to cycle through the available rendering options */
|
||||||
public static EDhApiRendererMode next(EDhApiRendererMode type)
|
public static EDhApiRendererMode next(EDhApiRendererMode type)
|
||||||
{
|
{
|
||||||
return switch (type) {
|
switch (type)
|
||||||
case DEFAULT -> DEBUG;
|
{
|
||||||
case DEBUG -> DISABLED;
|
case DEFAULT:
|
||||||
default -> DEFAULT;
|
return DEBUG;
|
||||||
};
|
case DEBUG:
|
||||||
|
return DISABLED;
|
||||||
|
default:
|
||||||
|
return DEFAULT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Used by the config GUI to cycle through the available rendering options */
|
/** Used by the config GUI to cycle through the available rendering options */
|
||||||
public static EDhApiRendererMode previous(EDhApiRendererMode type)
|
public static EDhApiRendererMode previous(EDhApiRendererMode type)
|
||||||
{
|
{
|
||||||
return switch (type) {
|
switch (type)
|
||||||
case DEFAULT -> DISABLED;
|
{
|
||||||
case DEBUG -> DEFAULT;
|
case DEFAULT:
|
||||||
default -> DEBUG;
|
return DISABLED;
|
||||||
};
|
case DEBUG:
|
||||||
|
return DEFAULT;
|
||||||
|
default:
|
||||||
|
return DEBUG;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
-9
@@ -36,13 +36,4 @@ public interface IDhApiGpuBuffersConfig extends IDhApiConfigGroup
|
|||||||
/** Defines how geometry data is uploaded to the GPU. */
|
/** Defines how geometry data is uploaded to the GPU. */
|
||||||
IDhApiConfigValue<EDhApiGpuUploadMethod> gpuUploadMethod();
|
IDhApiConfigValue<EDhApiGpuUploadMethod> gpuUploadMethod();
|
||||||
|
|
||||||
/**
|
|
||||||
* Defines how long we should wait after uploading one
|
|
||||||
* Megabyte of geometry data to the GPU before uploading
|
|
||||||
* the next Megabyte of data. <br>
|
|
||||||
* This can be set to a non-zero number to reduce stuttering caused by
|
|
||||||
* uploading buffers to the GPU.
|
|
||||||
*/
|
|
||||||
IDhApiConfigValue<Integer> gpuUploadPerMegabyteInMilliseconds();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-29
@@ -79,34 +79,11 @@ public interface IDhApiWrapperFactory
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
///**
|
||||||
* Constructs a {@link IDhApiBiomeWrapper} for use by other DhApi methods.
|
// * Specifically designed to be used with the API.
|
||||||
*
|
// *
|
||||||
* @param resourceLocationString example: "minecraft:plains"
|
// * @throws ClassCastException with instructions on expected objects if the object couldn't be cast
|
||||||
*
|
// */
|
||||||
* @param levelWrapper Expects a {@link IDhApiLevelWrapper} returned by one of DH's {@link DhApi.Delayed#worldProxy} methods. <br>
|
//IChunkWrapper createChunkWrapper(Object[] objectArray) throws ClassCastException;
|
||||||
* A custom implementation of {@link IDhApiLevelWrapper} will not be accepted.
|
|
||||||
*
|
|
||||||
* @throws IOException if the resourceLocationString wasn't able to be parsed or converted into a valid {@link IDhApiBiomeWrapper}
|
|
||||||
* @throws ClassCastException if the wrong levelWrapper type was given
|
|
||||||
*
|
|
||||||
* @since API 3.0.0
|
|
||||||
*/
|
|
||||||
IDhApiBiomeWrapper getBiomeWrapper(String resourceLocationString, IDhApiLevelWrapper levelWrapper) throws IOException, ClassCastException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a {@link IDhApiBlockStateWrapper} for use by other DhApi methods.
|
|
||||||
* This returns the default blockstate for the given resource location.
|
|
||||||
*
|
|
||||||
* @param resourceLocationString examples: "minecraft:bedrock", "minecraft:stone", "minecraft:grass_block"
|
|
||||||
* @param levelWrapper Expects a {@link IDhApiBlockStateWrapper} returned by one of DH's {@link DhApi.Delayed#worldProxy} methods. <br>
|
|
||||||
* A custom implementation of {@link IDhApiBlockStateWrapper} will not be accepted.
|
|
||||||
*
|
|
||||||
* @throws IOException if the resourceLocationString wasn't able to be parsed or converted into a valid {@link IDhApiBlockStateWrapper}
|
|
||||||
* @throws ClassCastException if the wrong levelWrapper type was given
|
|
||||||
*
|
|
||||||
* @since API 3.0.0
|
|
||||||
*/
|
|
||||||
IDhApiBlockStateWrapper getDefaultBlockStateWrapper(String resourceLocationString, IDhApiLevelWrapper levelWrapper) throws IOException, ClassCastException;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-48
@@ -22,8 +22,6 @@ package com.seibel.distanthorizons.api.interfaces.override.worldGenerator;
|
|||||||
import com.seibel.distanthorizons.api.enums.EDhApiDetailLevel;
|
import com.seibel.distanthorizons.api.enums.EDhApiDetailLevel;
|
||||||
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGeneratorMode;
|
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGeneratorMode;
|
||||||
import com.seibel.distanthorizons.api.interfaces.override.IDhApiOverrideable;
|
import com.seibel.distanthorizons.api.interfaces.override.IDhApiOverrideable;
|
||||||
import com.seibel.distanthorizons.api.objects.data.DhApiChunk;
|
|
||||||
import com.seibel.distanthorizons.api.objects.data.DhApiTerrainDataPoint;
|
|
||||||
import com.seibel.distanthorizons.coreapi.util.BitShiftUtil;
|
import com.seibel.distanthorizons.coreapi.util.BitShiftUtil;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
@@ -79,41 +77,13 @@ public abstract class AbstractDhApiChunkWorldGenerator implements Closeable, IDh
|
|||||||
}, worldGeneratorThreadPool);
|
}, worldGeneratorThreadPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final CompletableFuture<Void> generateApiChunks(
|
|
||||||
int chunkPosMinX,
|
|
||||||
int chunkPosMinZ,
|
|
||||||
byte granularity,
|
|
||||||
byte targetDataDetail,
|
|
||||||
EDhApiDistantGeneratorMode generatorMode,
|
|
||||||
ExecutorService worldGeneratorThreadPool,
|
|
||||||
Consumer<DhApiChunk> resultConsumer
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return CompletableFuture.runAsync(() ->
|
|
||||||
{
|
|
||||||
// TODO what does this mean?
|
|
||||||
int genChunkWidth = BitShiftUtil.powerOfTwo(granularity - 4);
|
|
||||||
|
|
||||||
for (int chunkX = chunkPosMinX; chunkX < chunkPosMinX + genChunkWidth; chunkX++)
|
|
||||||
{
|
|
||||||
for (int chunkZ = chunkPosMinZ; chunkZ < chunkPosMinZ + genChunkWidth; chunkZ++)
|
|
||||||
{
|
|
||||||
DhApiChunk apiChunk = this.generateApiChunk(chunkX, chunkZ, generatorMode);
|
|
||||||
resultConsumer.accept(apiChunk);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, worldGeneratorThreadPool);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called to generate terrain over a given area
|
* This method is called to generate terrain over a given area
|
||||||
* from a thread defined by Distant Horizons. <br><br>
|
* from a thread defined by Distant Horizons. <br><br>
|
||||||
*
|
*
|
||||||
* @param chunkPosX the chunk X position in the level (not to be confused with the chunk's BlockPos in the level)
|
* @param chunkPosX the chunk X position in the level (not to be confused with the chunk's BlockPos in the level)
|
||||||
* @param chunkPosZ the chunk Z position in the level (not to be confused with the chunk's BlockPos in the level)
|
* @param chunkPosZ the chunk Z position in the level (not to be confused with the chunk's BlockPos in the level)
|
||||||
* @param generatorMode how far into the world gen pipeline this method should run. See {@link EDhApiDistantGeneratorMode} for additional documentation.
|
* @param generatorMode how far into the world gen pipeline this method run. See {@link EDhApiDistantGeneratorMode} for additional documentation.
|
||||||
*
|
*
|
||||||
* @return See {@link IDhApiWorldGenerator#generateChunks(int, int, byte, byte, EDhApiDistantGeneratorMode, ExecutorService, Consumer) IDhApiWorldGenerator.generateChunks}
|
* @return See {@link IDhApiWorldGenerator#generateChunks(int, int, byte, byte, EDhApiDistantGeneratorMode, ExecutorService, Consumer) IDhApiWorldGenerator.generateChunks}
|
||||||
* for the list of Object's this method should return along with additional documentation.
|
* for the list of Object's this method should return along with additional documentation.
|
||||||
@@ -122,21 +92,4 @@ public abstract class AbstractDhApiChunkWorldGenerator implements Closeable, IDh
|
|||||||
*/
|
*/
|
||||||
public abstract Object[] generateChunk(int chunkPosX, int chunkPosZ, EDhApiDistantGeneratorMode generatorMode);
|
public abstract Object[] generateChunk(int chunkPosX, int chunkPosZ, EDhApiDistantGeneratorMode generatorMode);
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called to generate terrain over a given area
|
|
||||||
* from a thread defined by Distant Horizons. <br><br>
|
|
||||||
*
|
|
||||||
* @param chunkPosX the chunk X position in the level (not to be confused with the chunk's BlockPos in the level)
|
|
||||||
* @param chunkPosZ the chunk Z position in the level (not to be confused with the chunk's BlockPos in the level)
|
|
||||||
* @param generatorMode how far into the world gen pipeline this method should run. See {@link EDhApiDistantGeneratorMode} for additional documentation.
|
|
||||||
*
|
|
||||||
* @return A {@link DhApiChunk} with the generated {@link DhApiTerrainDataPoint} including air blocks.
|
|
||||||
* Note: if air blocks aren't included with the proper lighting, lower detail levels will appear as black/unlit.
|
|
||||||
*
|
|
||||||
* @see IDhApiWorldGenerator#generateApiChunks(int, int, byte, byte, EDhApiDistantGeneratorMode, ExecutorService, Consumer)
|
|
||||||
*
|
|
||||||
* @since API 3.0.0
|
|
||||||
*/
|
|
||||||
public abstract DhApiChunk generateApiChunk(int chunkPosX, int chunkPosZ, EDhApiDistantGeneratorMode generatorMode);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -154,7 +154,6 @@ public interface IDhApiWorldGenerator extends Closeable, IDhApiOverrideable
|
|||||||
*
|
*
|
||||||
* After the {@link DhApiChunk} has been generated, it should be passed into the
|
* After the {@link DhApiChunk} has been generated, it should be passed into the
|
||||||
* resultConsumer's {@link Consumer#accept(Object)} method.
|
* resultConsumer's {@link Consumer#accept(Object)} method.
|
||||||
* Note: if air blocks aren't included in the with the {@link DhApiChunk} with proper lighting, lower detail levels will appear as black/unlit.
|
|
||||||
*
|
*
|
||||||
* @implNote the default implementation of this method throws an {@link UnsupportedOperationException},
|
* @implNote the default implementation of this method throws an {@link UnsupportedOperationException},
|
||||||
* and must be overridden when {@link #getReturnType()} returns {@link EDhApiWorldGeneratorReturnType#API_CHUNKS}.
|
* and must be overridden when {@link #getReturnType()} returns {@link EDhApiWorldGeneratorReturnType#API_CHUNKS}.
|
||||||
|
|||||||
@@ -59,12 +59,12 @@ public class DhApiResult<T>
|
|||||||
|
|
||||||
|
|
||||||
public static <Pt> DhApiResult<Pt> createSuccess() { return new DhApiResult<>(true, ""); }
|
public static <Pt> DhApiResult<Pt> createSuccess() { return new DhApiResult<>(true, ""); }
|
||||||
public static <Pt> DhApiResult<Pt> createSuccess(Pt payload) { return new DhApiResult<>(true, "", payload); }
|
public static <Pt> DhApiResult<Pt> createSuccess(Pt payload) { return new DhApiResult<Pt>(true, "", payload); }
|
||||||
// There is no createSuccess(String message) method because it would be too easy to confuse with createSuccess(Pt payload) when returning null
|
// There is no createSuccess(String message) method because it would be too easy to confuse with createSuccess(Pt payload) when returning null
|
||||||
public static <Pt> DhApiResult<Pt> createSuccess(String message, Pt payload) { return new DhApiResult<>(true, message, payload); }
|
public static <Pt> DhApiResult<Pt> createSuccess(String message, Pt payload) { return new DhApiResult<Pt>(true, message, payload); }
|
||||||
|
|
||||||
// there is no createFail() since all fail results should give a reason for their failure
|
// there is no createFail() since all fail results should give a reason for their failure
|
||||||
public static <Pt> DhApiResult<Pt> createFail(String message) { return new DhApiResult<>(false, message); }
|
public static <Pt> DhApiResult<Pt> createFail(String message) { return new DhApiResult<>(false, message); }
|
||||||
public static <Pt> DhApiResult<Pt> createFail(String message, Pt payload) { return new DhApiResult<>(false, message, payload); }
|
public static <Pt> DhApiResult<Pt> createFail(String message, Pt payload) { return new DhApiResult<Pt>(false, message, payload); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import java.util.List;
|
|||||||
* Contains a list of {@link DhApiTerrainDataPoint} representing the blocks in a Minecraft chunk.
|
* Contains a list of {@link DhApiTerrainDataPoint} representing the blocks in a Minecraft chunk.
|
||||||
*
|
*
|
||||||
* @author Builderb0y, James Seibel
|
* @author Builderb0y, James Seibel
|
||||||
* @version 2024-7-21
|
* @version 2023-12-21
|
||||||
* @since API 2.0.0
|
* @since API 2.0.0
|
||||||
*
|
*
|
||||||
* @see IDhApiWrapperFactory
|
* @see IDhApiWrapperFactory
|
||||||
@@ -41,8 +41,8 @@ public class DhApiChunk
|
|||||||
public final int chunkPosX;
|
public final int chunkPosX;
|
||||||
public final int chunkPosZ;
|
public final int chunkPosZ;
|
||||||
|
|
||||||
public final int bottomYBlockPos;
|
|
||||||
public final int topYBlockPos;
|
public final int topYBlockPos;
|
||||||
|
public final int bottomYBlockPos;
|
||||||
|
|
||||||
private final List<List<DhApiTerrainDataPoint>> dataPoints;
|
private final List<List<DhApiTerrainDataPoint>> dataPoints;
|
||||||
|
|
||||||
@@ -52,12 +52,12 @@ public class DhApiChunk
|
|||||||
// constructors //
|
// constructors //
|
||||||
//==============//
|
//==============//
|
||||||
|
|
||||||
public DhApiChunk(int chunkPosX, int chunkPosZ, int bottomYBlockPos, int topYBlockPos)
|
public DhApiChunk(int chunkPosX, int chunkPosZ, int topYBlockPos, int bottomYBlockPos)
|
||||||
{
|
{
|
||||||
this.chunkPosX = chunkPosX;
|
this.chunkPosX = chunkPosX;
|
||||||
this.chunkPosZ = chunkPosZ;
|
this.chunkPosZ = chunkPosZ;
|
||||||
this.bottomYBlockPos = bottomYBlockPos;
|
|
||||||
this.topYBlockPos = topYBlockPos;
|
this.topYBlockPos = topYBlockPos;
|
||||||
|
this.bottomYBlockPos = bottomYBlockPos;
|
||||||
|
|
||||||
// populate the array to prevent null pointers
|
// populate the array to prevent null pointers
|
||||||
this.dataPoints = new ArrayList<>(16 * 16); // 256
|
this.dataPoints = new ArrayList<>(16 * 16); // 256
|
||||||
|
|||||||
+4
-4
@@ -26,7 +26,7 @@ import com.seibel.distanthorizons.api.interfaces.block.IDhApiBlockStateWrapper;
|
|||||||
* Holds a single datapoint of terrain data.
|
* Holds a single datapoint of terrain data.
|
||||||
*
|
*
|
||||||
* @author James Seibel
|
* @author James Seibel
|
||||||
* @version 2024-7-20
|
* @version 2022-11-13
|
||||||
* @since API 1.0.0
|
* @since API 1.0.0
|
||||||
*/
|
*/
|
||||||
public class DhApiTerrainDataPoint
|
public class DhApiTerrainDataPoint
|
||||||
@@ -42,22 +42,22 @@ public class DhApiTerrainDataPoint
|
|||||||
|
|
||||||
public final int blockLightLevel;
|
public final int blockLightLevel;
|
||||||
public final int skyLightLevel;
|
public final int skyLightLevel;
|
||||||
public final int bottomYBlockPos;
|
|
||||||
public final int topYBlockPos;
|
public final int topYBlockPos;
|
||||||
|
public final int bottomYBlockPos;
|
||||||
|
|
||||||
public final IDhApiBlockStateWrapper blockStateWrapper;
|
public final IDhApiBlockStateWrapper blockStateWrapper;
|
||||||
public final IDhApiBiomeWrapper biomeWrapper;
|
public final IDhApiBiomeWrapper biomeWrapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public DhApiTerrainDataPoint(byte detailLevel, int blockLightLevel, int skyLightLevel, int bottomYBlockPos, int topYBlockPos, IDhApiBlockStateWrapper blockStateWrapper, IDhApiBiomeWrapper biomeWrapper)
|
public DhApiTerrainDataPoint(byte detailLevel, int blockLightLevel, int skyLightLevel, int topYBlockPos, int bottomYBlockPos, IDhApiBlockStateWrapper blockStateWrapper, IDhApiBiomeWrapper biomeWrapper)
|
||||||
{
|
{
|
||||||
this.detailLevel = detailLevel;
|
this.detailLevel = detailLevel;
|
||||||
|
|
||||||
this.blockLightLevel = blockLightLevel;
|
this.blockLightLevel = blockLightLevel;
|
||||||
this.skyLightLevel = skyLightLevel;
|
this.skyLightLevel = skyLightLevel;
|
||||||
this.bottomYBlockPos = bottomYBlockPos;
|
|
||||||
this.topYBlockPos = topYBlockPos;
|
this.topYBlockPos = topYBlockPos;
|
||||||
|
this.bottomYBlockPos = bottomYBlockPos;
|
||||||
|
|
||||||
this.blockStateWrapper = blockStateWrapper;
|
this.blockStateWrapper = blockStateWrapper;
|
||||||
this.biomeWrapper = biomeWrapper;
|
this.biomeWrapper = biomeWrapper;
|
||||||
|
|||||||
+2
-1
@@ -163,8 +163,9 @@ public class ApiEventInjector extends DependencyInjector<IDhApiEvent> implements
|
|||||||
DhApiEventParam<T> eventParam = createEventParamWrapper(event, input);
|
DhApiEventParam<T> eventParam = createEventParamWrapper(event, input);
|
||||||
event.fireEvent(eventParam);
|
event.fireEvent(eventParam);
|
||||||
|
|
||||||
if (eventParam instanceof DhApiCancelableEventParam<T> cancelableEventParam)
|
if (eventParam instanceof DhApiCancelableEventParam)
|
||||||
{
|
{
|
||||||
|
DhApiCancelableEventParam<T> cancelableEventParam = (DhApiCancelableEventParam<T>) eventParam;
|
||||||
cancelEvent |= cancelableEventParam.isEventCanceled();
|
cancelEvent |= cancelableEventParam.isEventCanceled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -87,7 +87,7 @@ public class DependencyInjector<BindableType extends IBindable> implements IDepe
|
|||||||
// make sure the hashSet has an array to hold the dependency
|
// make sure the hashSet has an array to hold the dependency
|
||||||
if (!this.dependencies.containsKey(dependencyInterface))
|
if (!this.dependencies.containsKey(dependencyInterface))
|
||||||
{
|
{
|
||||||
this.dependencies.put(dependencyInterface, new ArrayList<>());
|
this.dependencies.put(dependencyInterface, new ArrayList<BindableType>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the dependency
|
// add the dependency
|
||||||
@@ -134,7 +134,7 @@ public class DependencyInjector<BindableType extends IBindable> implements IDepe
|
|||||||
@Override
|
@Override
|
||||||
public <T extends BindableType> T get(Class<T> interfaceClass) throws ClassCastException
|
public <T extends BindableType> T get(Class<T> interfaceClass) throws ClassCastException
|
||||||
{
|
{
|
||||||
return (T) this.getInternalLogic(interfaceClass, false).getFirst();
|
return (T) this.getInternalLogic(interfaceClass, false).get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -146,7 +146,7 @@ public class DependencyInjector<BindableType extends IBindable> implements IDepe
|
|||||||
@Override
|
@Override
|
||||||
public <T extends BindableType> T get(Class<T> interfaceClass, boolean allowIncompleteDependencies) throws ClassCastException
|
public <T extends BindableType> T get(Class<T> interfaceClass, boolean allowIncompleteDependencies) throws ClassCastException
|
||||||
{
|
{
|
||||||
return (T) this.getInternalLogic(interfaceClass, allowIncompleteDependencies).getFirst();
|
return (T) this.getInternalLogic(interfaceClass, allowIncompleteDependencies).get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -175,7 +175,7 @@ public class DependencyInjector<BindableType extends IBindable> implements IDepe
|
|||||||
|
|
||||||
|
|
||||||
// return an empty list to prevent null pointers
|
// return an empty list to prevent null pointers
|
||||||
ArrayList<T> emptyList = new ArrayList<>();
|
ArrayList<T> emptyList = new ArrayList<T>();
|
||||||
emptyList.add(null);
|
emptyList.add(null);
|
||||||
return emptyList;
|
return emptyList;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -64,14 +64,14 @@ public class OverridePriorityListContainer implements IBindable
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// last item should have the highest priority
|
// last item should have the highest priority
|
||||||
return this.overridePairList.getLast().override;
|
return this.overridePairList.get(this.overridePairList.size() - 1).override;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public IDhApiOverrideable getOverrideWithHighestPriority()
|
public IDhApiOverrideable getOverrideWithHighestPriority()
|
||||||
{
|
{
|
||||||
if (this.overridePairList.size() != 0)
|
if (this.overridePairList.size() != 0)
|
||||||
{
|
{
|
||||||
return this.overridePairList.getFirst().override;
|
return this.overridePairList.get(0).override;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-2
@@ -67,11 +67,10 @@ public interface IConfigEntry<T>
|
|||||||
* Checks if the option is valid
|
* Checks if the option is valid
|
||||||
*
|
*
|
||||||
* 0 == valid
|
* 0 == valid
|
||||||
* 2 == invalid
|
|
||||||
* 1 == number too high
|
* 1 == number too high
|
||||||
* -1 == number too low
|
* -1 == number too low
|
||||||
*/
|
*/
|
||||||
byte isValid(); // TODO replace with an enum
|
byte isValid();
|
||||||
/** Checks if a value is valid */
|
/** Checks if a value is valid */
|
||||||
byte isValid(T value);
|
byte isValid(T value);
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.coreapi.util;
|
package com.seibel.distanthorizons.coreapi.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.text.CharacterIterator;
|
||||||
|
import java.text.StringCharacterIterator;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,4 +86,25 @@ public class StringUtil
|
|||||||
return new String(hexChars);
|
return new String(hexChars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Source:
|
||||||
|
* https://stackoverflow.com/questions/3758606/how-can-i-convert-byte-size-into-a-human-readable-format-in-java#3758880
|
||||||
|
*/
|
||||||
|
public static String convertByteCountToHumanReadableSI(long bytes)
|
||||||
|
{
|
||||||
|
if (-1000 < bytes && bytes < 1000)
|
||||||
|
{
|
||||||
|
return bytes + " B";
|
||||||
|
}
|
||||||
|
|
||||||
|
CharacterIterator ci = new StringCharacterIterator("kMGTPE");
|
||||||
|
while (bytes <= -999_950 || bytes >= 999_950)
|
||||||
|
{
|
||||||
|
bytes /= 1000;
|
||||||
|
ci.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.format("%.1f %cB", bytes / 1000.0, ci.current());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-3
@@ -10,7 +10,7 @@ application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
downgradedArtifact // Used by DH to specify that we want to implement the shadowed core JAR file instead of the regular JAR file
|
shadowedArtifact // Used by DH to specify that we want to implement the shadowed core JAR file instead of the regular JAR file
|
||||||
shade
|
shade
|
||||||
implementation.extendsFrom shade
|
implementation.extendsFrom shade
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,9 @@ dependencies { // All of these dependencies are in Vanilla Minecraft, but we nee
|
|||||||
runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"
|
runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"
|
||||||
runtimeOnly "org.lwjgl:lwjgl-stb::$lwjglNatives"
|
runtimeOnly "org.lwjgl:lwjgl-stb::$lwjglNatives"
|
||||||
runtimeOnly "org.lwjgl:lwjgl-tinyfd::$lwjglNatives"
|
runtimeOnly "org.lwjgl:lwjgl-tinyfd::$lwjglNatives"
|
||||||
implementation "org.joml:joml:${rootProject.joml_version}"
|
|
||||||
|
// FIXME for some reason this line doesn't actually shade in the library
|
||||||
|
// shade "it.unimi.dsi:fastutil:${rootProject.fastutil_version}" // Add our own fastutil version
|
||||||
|
|
||||||
|
|
||||||
// Some other dependencies
|
// Some other dependencies
|
||||||
@@ -47,8 +49,15 @@ dependencies { // All of these dependencies are in Vanilla Minecraft, but we nee
|
|||||||
implementation("com.google.code.findbugs:jsr305:3.0.2")
|
implementation("com.google.code.findbugs:jsr305:3.0.2")
|
||||||
implementation("com.google.common:google-collect:0.5")
|
implementation("com.google.common:google-collect:0.5")
|
||||||
implementation("com.google.guava:guava:31.1-jre")
|
implementation("com.google.guava:guava:31.1-jre")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
artifacts {
|
artifacts {
|
||||||
downgradedArtifact shadeDowngradedApi // Setup the configuration downgradedArtifact to be the `shadeDowngradedApi` which downgrades the core to a specified Java version
|
shadowedArtifact shadowJar // Setup the configuration shadowedArtifact to be the shadowJar
|
||||||
|
}
|
||||||
|
|
||||||
|
shadowJar {
|
||||||
|
def librariesLocation = "DistantHorizons.libraries"
|
||||||
|
// relocate "it.unimi.dsi.fastutil", "${librariesLocation}.unimi.dsi.fastutil"
|
||||||
|
mergeServiceFiles()
|
||||||
}
|
}
|
||||||
+7
-7
@@ -35,30 +35,30 @@ public class DhApiAmbientOcclusionConfig implements IDhApiAmbientOcclusionConfig
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Boolean> enabled()
|
public IDhApiConfigValue<Boolean> enabled()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Ssao.enabled); }
|
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Graphics.Ssao.enabled); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Integer> sampleCount()
|
public IDhApiConfigValue<Integer> sampleCount()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Ssao.sampleCount); }
|
{ return new DhApiConfigValue<Integer, Integer>(Config.Client.Advanced.Graphics.Ssao.sampleCount); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> radius()
|
public IDhApiConfigValue<Double> radius()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Ssao.radius); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Ssao.radius); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> strength()
|
public IDhApiConfigValue<Double> strength()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Ssao.strength); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Ssao.strength); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> bias()
|
public IDhApiConfigValue<Double> bias()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Ssao.bias); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Ssao.bias); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> minLight()
|
public IDhApiConfigValue<Double> minLight()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Ssao.minLight); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Ssao.minLight); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Integer> blurRadius()
|
public IDhApiConfigValue<Integer> blurRadius()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Ssao.blurRadius); }
|
{ return new DhApiConfigValue<Integer, Integer>(Config.Client.Advanced.Graphics.Ssao.blurRadius); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -34,18 +34,18 @@ public class DhApiDebuggingConfig implements IDhApiDebuggingConfig
|
|||||||
|
|
||||||
|
|
||||||
public IDhApiConfigValue<EDhApiDebugRendering> debugRendering()
|
public IDhApiConfigValue<EDhApiDebugRendering> debugRendering()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Debugging.debugRendering); }
|
{ return new DhApiConfigValue<EDhApiDebugRendering, EDhApiDebugRendering>(Config.Client.Advanced.Debugging.debugRendering); }
|
||||||
|
|
||||||
public IDhApiConfigValue<Boolean> debugKeybindings()
|
public IDhApiConfigValue<Boolean> debugKeybindings()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Debugging.enableDebugKeybindings); }
|
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Debugging.enableDebugKeybindings); }
|
||||||
|
|
||||||
public IDhApiConfigValue<Boolean> renderWireframe()
|
public IDhApiConfigValue<Boolean> renderWireframe()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Debugging.renderWireframe); }
|
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Debugging.renderWireframe); }
|
||||||
|
|
||||||
public IDhApiConfigValue<Boolean> lodOnlyMode()
|
public IDhApiConfigValue<Boolean> lodOnlyMode()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Debugging.lodOnlyMode); }
|
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Debugging.lodOnlyMode); }
|
||||||
|
|
||||||
public IDhApiConfigValue<Boolean> debugWireframeRendering()
|
public IDhApiConfigValue<Boolean> debugWireframeRendering()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Debugging.DebugWireframe.enableRendering); }
|
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Debugging.DebugWireframe.enableRendering); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -35,26 +35,26 @@ public class DhApiFarFogConfig implements IDhApiFarFogConfig
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> farFogStartDistance()
|
public IDhApiConfigValue<Double> farFogStartDistance()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.farFogStart); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.farFogStart); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> farFogEndDistance()
|
public IDhApiConfigValue<Double> farFogEndDistance()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.farFogEnd); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.farFogEnd); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> farFogMinThickness()
|
public IDhApiConfigValue<Double> farFogMinThickness()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.farFogMin); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.farFogMin); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> farFogMaxThickness()
|
public IDhApiConfigValue<Double> farFogMaxThickness()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.farFogMax); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.farFogMax); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<EDhApiFogFalloff> farFogFalloff()
|
public IDhApiConfigValue<EDhApiFogFalloff> farFogFalloff()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.farFogFalloff); }
|
{ return new DhApiConfigValue<EDhApiFogFalloff, EDhApiFogFalloff>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.farFogFalloff); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> farFogDensity()
|
public IDhApiConfigValue<Double> farFogDensity()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.farFogDensity); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.farFogDensity); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -35,12 +35,12 @@ public class DhApiGenericRenderingConfig implements IDhApiGenericRenderingConfig
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Boolean> renderingEnabled()
|
public IDhApiConfigValue<Boolean> renderingEnabled()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.GenericRendering.enableRendering); }
|
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Graphics.GenericRendering.enableRendering); }
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Boolean> beaconRenderingEnabled()
|
public IDhApiConfigValue<Boolean> beaconRenderingEnabled()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.GenericRendering.enableBeaconRendering); }
|
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Graphics.GenericRendering.enableBeaconRendering); }
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Boolean> cloudRenderingEnabled()
|
public IDhApiConfigValue<Boolean> cloudRenderingEnabled()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.GenericRendering.enableCloudRendering); }
|
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Graphics.GenericRendering.enableCloudRendering); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
-3
@@ -36,7 +36,4 @@ public class DhApiGpuBuffersConfig implements IDhApiGpuBuffersConfig
|
|||||||
public IDhApiConfigValue<EDhApiGpuUploadMethod> gpuUploadMethod()
|
public IDhApiConfigValue<EDhApiGpuUploadMethod> gpuUploadMethod()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.GpuBuffers.gpuUploadMethod); }
|
{ return new DhApiConfigValue<>(Config.Client.Advanced.GpuBuffers.gpuUploadMethod); }
|
||||||
|
|
||||||
public IDhApiConfigValue<Integer> gpuUploadPerMegabyteInMilliseconds()
|
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.GpuBuffers.gpuUploadPerMegabyteInMilliseconds); }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-20
@@ -56,15 +56,15 @@ public class DhApiGraphicsConfig implements IDhApiGraphicsConfig
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Integer> chunkRenderDistance()
|
public IDhApiConfigValue<Integer> chunkRenderDistance()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Quality.lodChunkRenderDistanceRadius); }
|
{ return new DhApiConfigValue<Integer, Integer>(Config.Client.Advanced.Graphics.Quality.lodChunkRenderDistanceRadius); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Boolean> renderingEnabled()
|
public IDhApiConfigValue<Boolean> renderingEnabled()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.quickEnableRendering); }
|
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.quickEnableRendering); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<EDhApiRendererMode> renderingMode()
|
public IDhApiConfigValue<EDhApiRendererMode> renderingMode()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Debugging.rendererMode); }
|
{ return new DhApiConfigValue<EDhApiRendererMode, EDhApiRendererMode>(Config.Client.Advanced.Debugging.rendererMode); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -74,27 +74,27 @@ public class DhApiGraphicsConfig implements IDhApiGraphicsConfig
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<EDhApiMaxHorizontalResolution> maxHorizontalResolution()
|
public IDhApiConfigValue<EDhApiMaxHorizontalResolution> maxHorizontalResolution()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Quality.maxHorizontalResolution); }
|
{ return new DhApiConfigValue<EDhApiMaxHorizontalResolution, EDhApiMaxHorizontalResolution>(Config.Client.Advanced.Graphics.Quality.maxHorizontalResolution); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<EDhApiVerticalQuality> verticalQuality()
|
public IDhApiConfigValue<EDhApiVerticalQuality> verticalQuality()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Quality.verticalQuality); }
|
{ return new DhApiConfigValue<EDhApiVerticalQuality, EDhApiVerticalQuality>(Config.Client.Advanced.Graphics.Quality.verticalQuality); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<EDhApiHorizontalQuality> horizontalQuality()
|
public IDhApiConfigValue<EDhApiHorizontalQuality> horizontalQuality()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Quality.horizontalQuality); }
|
{ return new DhApiConfigValue<EDhApiHorizontalQuality, EDhApiHorizontalQuality>(Config.Client.Advanced.Graphics.Quality.horizontalQuality); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<EDhApiTransparency> transparency()
|
public IDhApiConfigValue<EDhApiTransparency> transparency()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Quality.transparency); }
|
{ return new DhApiConfigValue<EDhApiTransparency, EDhApiTransparency>(Config.Client.Advanced.Graphics.Quality.transparency); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<EDhApiBlocksToAvoid> blocksToAvoid()
|
public IDhApiConfigValue<EDhApiBlocksToAvoid> blocksToAvoid()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Quality.blocksToIgnore); }
|
{ return new DhApiConfigValue<EDhApiBlocksToAvoid, EDhApiBlocksToAvoid>(Config.Client.Advanced.Graphics.Quality.blocksToIgnore); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Boolean> tintWithAvoidedBlocks()
|
public IDhApiConfigValue<Boolean> tintWithAvoidedBlocks()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Quality.tintWithAvoidedBlocks); }
|
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Graphics.Quality.tintWithAvoidedBlocks); }
|
||||||
|
|
||||||
// TODO re-implement
|
// TODO re-implement
|
||||||
// @Override
|
// @Override
|
||||||
@@ -109,47 +109,47 @@ public class DhApiGraphicsConfig implements IDhApiGraphicsConfig
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> overdrawPreventionRadius()
|
public IDhApiConfigValue<Double> overdrawPreventionRadius()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.AdvancedGraphics.overdrawPrevention); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.AdvancedGraphics.overdrawPrevention); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> brightnessMultiplier()
|
public IDhApiConfigValue<Double> brightnessMultiplier()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.AdvancedGraphics.brightnessMultiplier); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.AdvancedGraphics.brightnessMultiplier); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> saturationMultiplier()
|
public IDhApiConfigValue<Double> saturationMultiplier()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.AdvancedGraphics.saturationMultiplier); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.AdvancedGraphics.saturationMultiplier); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Boolean> caveCullingEnabled()
|
public IDhApiConfigValue<Boolean> caveCullingEnabled()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.AdvancedGraphics.enableCaveCulling); }
|
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Graphics.AdvancedGraphics.enableCaveCulling); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Integer> caveCullingHeight()
|
public IDhApiConfigValue<Integer> caveCullingHeight()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.AdvancedGraphics.caveCullingHeight); }
|
{ return new DhApiConfigValue<Integer, Integer>(Config.Client.Advanced.Graphics.AdvancedGraphics.caveCullingHeight); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Integer> earthCurvatureRatio()
|
public IDhApiConfigValue<Integer> earthCurvatureRatio()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.AdvancedGraphics.earthCurveRatio); }
|
{ return new DhApiConfigValue<Integer, Integer>(Config.Client.Advanced.Graphics.AdvancedGraphics.earthCurveRatio); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Boolean> lodOnlyMode()
|
public IDhApiConfigValue<Boolean> lodOnlyMode()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Debugging.lodOnlyMode); }
|
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Debugging.lodOnlyMode); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> lodBias()
|
public IDhApiConfigValue<Double> lodBias()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.AdvancedGraphics.lodBias); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.AdvancedGraphics.lodBias); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<EDhApiLodShading> lodShading()
|
public IDhApiConfigValue<EDhApiLodShading> lodShading()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.AdvancedGraphics.lodShading); }
|
{ return new DhApiConfigValue<EDhApiLodShading, EDhApiLodShading>(Config.Client.Advanced.Graphics.AdvancedGraphics.lodShading); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Boolean> disableFrustumCulling()
|
public IDhApiConfigValue<Boolean> disableFrustumCulling()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.AdvancedGraphics.disableFrustumCulling); }
|
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Graphics.AdvancedGraphics.disableFrustumCulling); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Boolean> disableShadowFrustumCulling()
|
public IDhApiConfigValue<Boolean> disableShadowFrustumCulling()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.AdvancedGraphics.disableShadowPassFrustumCulling); }
|
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Graphics.AdvancedGraphics.disableShadowPassFrustumCulling); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -37,38 +37,38 @@ public class DhApiHeightFogConfig implements IDhApiHeightFogConfig
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<EDhApiHeightFogMixMode> heightFogMixMode()
|
public IDhApiConfigValue<EDhApiHeightFogMixMode> heightFogMixMode()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogMixMode); }
|
{ return new DhApiConfigValue<EDhApiHeightFogMixMode, EDhApiHeightFogMixMode>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogMixMode); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<EDhApiHeightFogMode> heightFogMode()
|
public IDhApiConfigValue<EDhApiHeightFogMode> heightFogMode()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogMode); }
|
{ return new DhApiConfigValue<EDhApiHeightFogMode, EDhApiHeightFogMode>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogMode); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> heightFogBaseHeight()
|
public IDhApiConfigValue<Double> heightFogBaseHeight()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogBaseHeight); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogBaseHeight); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> heightFogStartingHeightPercent()
|
public IDhApiConfigValue<Double> heightFogStartingHeightPercent()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogStart); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogStart); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> heightFogEndingHeightPercent()
|
public IDhApiConfigValue<Double> heightFogEndingHeightPercent()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogEnd); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogEnd); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> heightFogMinThickness()
|
public IDhApiConfigValue<Double> heightFogMinThickness()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogMin); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogMin); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> heightFogMaxThickness()
|
public IDhApiConfigValue<Double> heightFogMaxThickness()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogMax); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogMax); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<EDhApiFogFalloff> heightFogFalloff()
|
public IDhApiConfigValue<EDhApiFogFalloff> heightFogFalloff()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogFalloff); }
|
{ return new DhApiConfigValue<EDhApiFogFalloff, EDhApiFogFalloff>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogFalloff); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> heightFogDensity()
|
public IDhApiConfigValue<Double> heightFogDensity()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogDensity); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.Fog.AdvancedFog.HeightFog.heightFogDensity); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -34,14 +34,14 @@ public class DhApiMultiThreadingConfig implements IDhApiMultiThreadingConfig
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Integer> worldGeneratorThreads()
|
public IDhApiConfigValue<Integer> worldGeneratorThreads()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.MultiThreading.numberOfWorldGenerationThreads); }
|
{ return new DhApiConfigValue<Integer, Integer>(Config.Client.Advanced.MultiThreading.numberOfWorldGenerationThreads); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Integer> fileHandlerThreads()
|
public IDhApiConfigValue<Integer> fileHandlerThreads()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.MultiThreading.numberOfFileHandlerThreads); }
|
{ return new DhApiConfigValue<Integer, Integer>(Config.Client.Advanced.MultiThreading.numberOfFileHandlerThreads); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Integer> lodBuilderThreads()
|
public IDhApiConfigValue<Integer> lodBuilderThreads()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.MultiThreading.numberOfLodBuilderThreads); }
|
{ return new DhApiConfigValue<Integer, Integer>(Config.Client.Advanced.MultiThreading.numberOfLodBuilderThreads); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -34,9 +34,9 @@ public class DhApiMultiplayerConfig implements IDhApiMultiplayerConfig
|
|||||||
|
|
||||||
|
|
||||||
public IDhApiConfigValue<EDhApiServerFolderNameMode> folderSavingMode()
|
public IDhApiConfigValue<EDhApiServerFolderNameMode> folderSavingMode()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Multiplayer.serverFolderNameMode); }
|
{ return new DhApiConfigValue<EDhApiServerFolderNameMode, EDhApiServerFolderNameMode>(Config.Client.Advanced.Multiplayer.serverFolderNameMode); }
|
||||||
|
|
||||||
public IDhApiConfigValue<Double> multiverseSimilarityRequirement()
|
public IDhApiConfigValue<Double> multiverseSimilarityRequirement()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Multiplayer.multiverseSimilarityRequiredPercent); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Multiplayer.multiverseSimilarityRequiredPercent); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -34,18 +34,18 @@ public class DhApiNoiseTextureConfig implements IDhApiNoiseTextureConfig
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Boolean> noiseEnabled()
|
public IDhApiConfigValue<Boolean> noiseEnabled()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseEnabled); }
|
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseEnabled); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Integer> noiseSteps()
|
public IDhApiConfigValue<Integer> noiseSteps()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseSteps); }
|
{ return new DhApiConfigValue<Integer, Integer>(Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseSteps); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Double> noiseIntensity()
|
public IDhApiConfigValue<Double> noiseIntensity()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseIntensity); }
|
{ return new DhApiConfigValue<Double, Double>(Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseIntensity); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDhApiConfigValue<Integer> noiseDropoff()
|
public IDhApiConfigValue<Integer> noiseDropoff()
|
||||||
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseDropoff); }
|
{ return new DhApiConfigValue<Integer, Integer>(Config.Client.Advanced.Graphics.NoiseTextureSettings.noiseDropoff); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -187,20 +187,22 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
|
|||||||
return DhApiResult.createFail("Unable to get terrain data before the world has loaded.");
|
return DhApiResult.createFail("Unable to get terrain data before the world has loaded.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(levelWrapper instanceof ILevelWrapper coreLevelWrapper))
|
if (!(levelWrapper instanceof ILevelWrapper))
|
||||||
{
|
{
|
||||||
// custom level wrappers aren't supported,
|
// custom level wrappers aren't supported,
|
||||||
// the API user must get a level wrapper from our code somewhere
|
// the API user must get a level wrapper from our code somewhere
|
||||||
return DhApiResult.createFail("Unsupported [" + IDhApiLevelWrapper.class.getSimpleName() + "] implementation, only the core class [" + IDhLevel.class.getSimpleName() + "] is a valid parameter.");
|
return DhApiResult.createFail("Unsupported [" + IDhApiLevelWrapper.class.getSimpleName() + "] implementation, only the core class [" + IDhLevel.class.getSimpleName() + "] is a valid parameter.");
|
||||||
}
|
}
|
||||||
|
ILevelWrapper coreLevelWrapper = (ILevelWrapper) levelWrapper;
|
||||||
|
|
||||||
|
|
||||||
if (!(apiDataCache instanceof DhApiTerrainDataCache dataCache))
|
if (!(apiDataCache instanceof DhApiTerrainDataCache))
|
||||||
{
|
{
|
||||||
// custom level wrappers aren't supported,
|
// custom level wrappers aren't supported,
|
||||||
// the API user must get a level wrapper from our code somewhere
|
// the API user must get a level wrapper from our code somewhere
|
||||||
return DhApiResult.createFail("Unsupported [" + IDhApiTerrainDataCache.class.getSimpleName() + "] implementation, only the core class [" + DhApiTerrainDataCache.class.getSimpleName() + "] is a valid parameter.");
|
return DhApiResult.createFail("Unsupported [" + IDhApiTerrainDataCache.class.getSimpleName() + "] implementation, only the core class [" + DhApiTerrainDataCache.class.getSimpleName() + "] is a valid parameter.");
|
||||||
}
|
}
|
||||||
|
DhApiTerrainDataCache dataCache = (DhApiTerrainDataCache) apiDataCache;
|
||||||
|
|
||||||
|
|
||||||
IDhLevel level = currentWorld.getLevel(coreLevelWrapper);
|
IDhLevel level = currentWorld.getLevel(coreLevelWrapper);
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import com.seibel.distanthorizons.api.DhApi;
|
|||||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiRenderPass;
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiRenderPass;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.*;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.*;
|
||||||
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
||||||
import com.seibel.distanthorizons.core.file.structure.ClientOnlySaveStructure;
|
|
||||||
import com.seibel.distanthorizons.core.level.IKeyedClientLevelManager;
|
import com.seibel.distanthorizons.core.level.IKeyedClientLevelManager;
|
||||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||||
import com.seibel.distanthorizons.core.render.DhApiRenderProxy;
|
import com.seibel.distanthorizons.core.render.DhApiRenderProxy;
|
||||||
@@ -54,7 +53,6 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
@@ -127,28 +125,9 @@ public class ClientApi
|
|||||||
public synchronized void onClientOnlyConnected()
|
public synchronized void onClientOnlyConnected()
|
||||||
{
|
{
|
||||||
// only continue if the client is connected to a different server
|
// only continue if the client is connected to a different server
|
||||||
boolean connectedToServer = MC.clientConnectedToDedicatedServer();
|
if (MC.clientConnectedToDedicatedServer())
|
||||||
boolean connectedToReplay = MC.connectedToReplay();
|
|
||||||
if (connectedToServer || connectedToReplay)
|
|
||||||
{
|
{
|
||||||
if (connectedToServer)
|
LOGGER.info("Client on ClientOnly mode connecting.");
|
||||||
{
|
|
||||||
LOGGER.info("Client on ClientOnly mode connecting.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOGGER.info("Replay on ClientServer mode connecting.");
|
|
||||||
|
|
||||||
if (Config.Client.Advanced.Logging.showReplayWarningOnStartup.get())
|
|
||||||
{
|
|
||||||
MC.sendChatMessage("\u00A76" + "Distant Horizons: Replay detected." + "\u00A7r"); // gold color
|
|
||||||
MC.sendChatMessage("DH may behave strangely or have missing functionality.");
|
|
||||||
MC.sendChatMessage("In order to use pre-generated LODs, put your DH database(s) in:");
|
|
||||||
MC.sendChatMessage("\u00A77"+".Minecraft" + File.separator + ClientOnlySaveStructure.SERVER_DATA_FOLDER_NAME + File.separator + ClientOnlySaveStructure.REPLAY_SERVER_FOLDER_NAME + File.separator + "DIMENSION_NAME"+"\u00A7r"); // light gray color
|
|
||||||
MC.sendChatMessage("This can be disabled in DH's config under Advanced -> Logging.");
|
|
||||||
MC.sendChatMessage("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// firing after clientLevelLoadEvent
|
// firing after clientLevelLoadEvent
|
||||||
// TODO if level has prepped to load it should fire level load event
|
// TODO if level has prepped to load it should fire level load event
|
||||||
|
|||||||
@@ -172,10 +172,11 @@ public class SharedApi
|
|||||||
AbstractDhWorld dhWorld = SharedApi.getAbstractDhWorld();
|
AbstractDhWorld dhWorld = SharedApi.getAbstractDhWorld();
|
||||||
if (dhWorld == null)
|
if (dhWorld == null)
|
||||||
{
|
{
|
||||||
if (level instanceof IClientLevelWrapper clientLevel)
|
if (level instanceof IClientLevelWrapper)
|
||||||
{
|
{
|
||||||
// If the client world isn't loaded yet, keep track of which chunks were loaded so we can use them later.
|
// If the client world isn't loaded yet, keep track of which chunks were loaded so we can use them later.
|
||||||
// This may happen if the client world and client level load events happen out of order
|
// This may happen if the client world and client level load events happen out of order
|
||||||
|
IClientLevelWrapper clientLevel = (IClientLevelWrapper) level;
|
||||||
ClientApi.INSTANCE.waitingChunkByClientLevelAndPos.replace(new Pair<>(clientLevel, chunkWrapper.getChunkPos()), chunkWrapper);
|
ClientApi.INSTANCE.waitingChunkByClientLevelAndPos.replace(new Pair<>(clientLevel, chunkWrapper.getChunkPos()), chunkWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,9 +187,10 @@ public class SharedApi
|
|||||||
IDhLevel dhLevel = dhWorld.getLevel(level);
|
IDhLevel dhLevel = dhWorld.getLevel(level);
|
||||||
if (dhLevel == null)
|
if (dhLevel == null)
|
||||||
{
|
{
|
||||||
if (level instanceof IClientLevelWrapper clientLevel)
|
if (level instanceof IClientLevelWrapper)
|
||||||
{
|
{
|
||||||
// the client level isn't loaded yet
|
// the client level isn't loaded yet
|
||||||
|
IClientLevelWrapper clientLevel = (IClientLevelWrapper) level;
|
||||||
ClientApi.INSTANCE.waitingChunkByClientLevelAndPos.replace(new Pair<>(clientLevel, chunkWrapper.getChunkPos()), chunkWrapper);
|
ClientApi.INSTANCE.waitingChunkByClientLevelAndPos.replace(new Pair<>(clientLevel, chunkWrapper.getChunkPos()), chunkWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,20 +20,17 @@
|
|||||||
package com.seibel.distanthorizons.core.config;
|
package com.seibel.distanthorizons.core.config;
|
||||||
|
|
||||||
|
|
||||||
import com.seibel.distanthorizons.api.DhApi;
|
|
||||||
import com.seibel.distanthorizons.api.enums.config.*;
|
import com.seibel.distanthorizons.api.enums.config.*;
|
||||||
import com.seibel.distanthorizons.api.enums.config.quickOptions.*;
|
import com.seibel.distanthorizons.api.enums.config.quickOptions.*;
|
||||||
import com.seibel.distanthorizons.api.enums.rendering.*;
|
import com.seibel.distanthorizons.api.enums.rendering.*;
|
||||||
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGeneratorMode;
|
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGeneratorMode;
|
||||||
import com.seibel.distanthorizons.core.config.eventHandlers.*;
|
import com.seibel.distanthorizons.core.config.eventHandlers.*;
|
||||||
import com.seibel.distanthorizons.core.config.eventHandlers.presets.*;
|
import com.seibel.distanthorizons.core.config.eventHandlers.presets.*;
|
||||||
import com.seibel.distanthorizons.core.config.listeners.ConfigChangeListener;
|
|
||||||
import com.seibel.distanthorizons.core.config.types.*;
|
import com.seibel.distanthorizons.core.config.types.*;
|
||||||
import com.seibel.distanthorizons.core.config.types.enums.*;
|
import com.seibel.distanthorizons.core.config.types.enums.*;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.pos.DhSectionPos;
|
import com.seibel.distanthorizons.core.pos.DhSectionPos;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.IWrapperFactory;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper;
|
||||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
import com.seibel.distanthorizons.coreapi.util.StringUtil;
|
import com.seibel.distanthorizons.coreapi.util.StringUtil;
|
||||||
@@ -613,10 +610,8 @@ public class Config
|
|||||||
+ " does not have a ceiling.")
|
+ " does not have a ceiling.")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static ConfigEntry<Integer> caveCullingHeight = new ConfigEntry.Builder<Integer>()
|
public static ConfigEntry<Integer> caveCullingHeight = new ConfigEntry.Builder<Integer>()
|
||||||
.setMinDefaultMax(-4096, 40, 4096)
|
.setMinDefaultMax(-4096, 40, 4096)
|
||||||
.setAppearance(EConfigEntryAppearance.ONLY_IN_API)
|
|
||||||
.comment(""
|
.comment(""
|
||||||
+ "At what Y value should cave culling start?")
|
+ "At what Y value should cave culling start?")
|
||||||
.build();
|
.build();
|
||||||
@@ -848,47 +843,13 @@ public class Config
|
|||||||
+ "")
|
+ "")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static ConfigEntry<String> ignoredRenderBlockCsv = new ConfigEntry.Builder<String>()
|
//public static ConfigEntry<Boolean> showMigrationChatWarning = new ConfigEntry.Builder<Boolean>()
|
||||||
.set("minecraft:barrier,minecraft:structure_void,minecraft:light,minecraft:tripwire")
|
// .set(true)
|
||||||
.comment(""
|
// .comment(""
|
||||||
+ "A comma separated list of block resource locations that won't be rendered by DH. \n"
|
// + "Determines if a message should be displayed in the chat when LOD migration starts. \n"
|
||||||
+ "Note: air is always included in this list. \n"
|
// + "")
|
||||||
+ "")
|
// .build();
|
||||||
.build();
|
|
||||||
|
|
||||||
public static ConfigEntry<String> ignoredRenderCaveBlockCsv = new ConfigEntry.Builder<String>()
|
|
||||||
.set("minecraft:glow_lichen,minecraft:rail,minecraft:water,minecraft:lava,minecraft:bubble_column")
|
|
||||||
.comment(""
|
|
||||||
+ "A comma separated list of block resource locations that shouldn't be rendered \n"
|
|
||||||
+ "if they are in a 0 sky light underground area. \n"
|
|
||||||
+ "Note: air is always included in this list. \n"
|
|
||||||
+ "")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
ignoredRenderBlockCsv.addListener(new ConfigChangeListener<>(Config.Client.Advanced.LodBuilding.ignoredRenderBlockCsv,
|
|
||||||
(blockCsv) ->
|
|
||||||
{
|
|
||||||
IWrapperFactory wrapperFactory = SingletonInjector.INSTANCE.get(IWrapperFactory.class);
|
|
||||||
if (wrapperFactory != null)
|
|
||||||
{
|
|
||||||
wrapperFactory.resetRendererIgnoredBlocksSet();
|
|
||||||
DhApi.Delayed.renderProxy.clearRenderDataCache();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
ignoredRenderCaveBlockCsv.addListener(new ConfigChangeListener<>(Config.Client.Advanced.LodBuilding.ignoredRenderCaveBlockCsv,
|
|
||||||
(blockCsv) ->
|
|
||||||
{
|
|
||||||
IWrapperFactory wrapperFactory = SingletonInjector.INSTANCE.get(IWrapperFactory.class);
|
|
||||||
if (wrapperFactory != null)
|
|
||||||
{
|
|
||||||
wrapperFactory.resetRendererIgnoredCaveBlocks();
|
|
||||||
DhApi.Delayed.renderProxy.clearRenderDataCache();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Multiplayer
|
public static class Multiplayer
|
||||||
@@ -1093,20 +1054,6 @@ public class Config
|
|||||||
+ "")
|
+ "")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static ConfigEntry<Integer> gpuUploadPerMegabyteInMilliseconds = new ConfigEntry.Builder<Integer>()
|
|
||||||
.setMinDefaultMax(0, 0, 50)
|
|
||||||
.comment(""
|
|
||||||
+ "How long should a buffer wait per Megabyte of data uploaded? \n"
|
|
||||||
+ "Helpful resource for frame times: https://fpstoms.com \n"
|
|
||||||
+ "\n"
|
|
||||||
+ "Longer times may reduce stuttering but will make LODs \n"
|
|
||||||
+ "transition and load slower. Change this to [0] for no timeout. \n"
|
|
||||||
+ "\n"
|
|
||||||
+ "NOTE:\n"
|
|
||||||
+ "Before changing this config, try changing the \"GPU Upload method\" first. \n"
|
|
||||||
+ "")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AutoUpdater
|
public static class AutoUpdater
|
||||||
@@ -1210,13 +1157,6 @@ public class Config
|
|||||||
+ "memory allocated to run DH well.")
|
+ "memory allocated to run DH well.")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static ConfigEntry<Boolean> showReplayWarningOnStartup = new ConfigEntry.Builder<Boolean>()
|
|
||||||
.set(true)
|
|
||||||
.comment(""
|
|
||||||
+ "If enabled, a chat message will be displayed when a replay is started \n"
|
|
||||||
+ "giving some basic information about how DH will function.")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Debugging
|
public static class Debugging
|
||||||
@@ -1497,25 +1437,27 @@ public class Config
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static ConfigEntry<List<String>> listTest = new ConfigEntry.Builder<List<String>>()
|
public static ConfigEntry<List<String>> listTest = new ConfigEntry.Builder<List<String>>()
|
||||||
.set(new ArrayList<>(Arrays.asList("option 1", "option 2", "option 3")))
|
.set(new ArrayList<String>(Arrays.asList("option 1", "option 2", "option 3")))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static ConfigEntry<Map<String, String>> mapTest = new ConfigEntry.Builder<Map<String, String>>()
|
public static ConfigEntry<Map<String, String>> mapTest = new ConfigEntry.Builder<Map<String, String>>()
|
||||||
.set(new HashMap<>())
|
.set(new HashMap<String, String>())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static ConfigUIButton uiButtonTest = new ConfigUIButton(() ->
|
public static ConfigUIButton uiButtonTest = new ConfigUIButton(() ->
|
||||||
new Thread(() ->
|
{
|
||||||
|
new Thread(() ->
|
||||||
|
{
|
||||||
|
if (!GraphicsEnvironment.isHeadless())
|
||||||
{
|
{
|
||||||
if (!GraphicsEnvironment.isHeadless())
|
JOptionPane.showMessageDialog(null, "Button pressed!", "UITester dialog", JOptionPane.INFORMATION_MESSAGE);
|
||||||
{
|
}
|
||||||
JOptionPane.showMessageDialog(null, "Button pressed!", "UITester dialog", JOptionPane.INFORMATION_MESSAGE);
|
else
|
||||||
}
|
{
|
||||||
else
|
LOGGER.info("button pressed!");
|
||||||
{
|
}
|
||||||
LOGGER.info("button pressed!");
|
});
|
||||||
}
|
});
|
||||||
}));
|
|
||||||
|
|
||||||
public static ConfigCategory categoryTest = new ConfigCategory.Builder().set(CategoryTest.class).build();
|
public static ConfigCategory categoryTest = new ConfigCategory.Builder().set(CategoryTest.class).build();
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class ConfigBase
|
|||||||
* <br> Map<String, T>
|
* <br> Map<String, T>
|
||||||
* <br> HashMap<String, T>
|
* <br> HashMap<String, T>
|
||||||
*/
|
*/
|
||||||
public static final List<Class<?>> acceptableInputs = new ArrayList<>()
|
public static final List<Class<?>> acceptableInputs = new ArrayList<Class<?>>()
|
||||||
{{
|
{{
|
||||||
add(Boolean.class);
|
add(Boolean.class);
|
||||||
add(Byte.class);
|
add(Byte.class);
|
||||||
@@ -149,7 +149,7 @@ public class ConfigBase
|
|||||||
LOGGER.warn(exception);
|
LOGGER.warn(exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractConfigType<?, ?> entry = entries.getLast();
|
AbstractConfigType<?, ?> entry = entries.get(entries.size() - 1);
|
||||||
entry.category = category;
|
entry.category = category;
|
||||||
entry.name = field.getName();
|
entry.name = field.getName();
|
||||||
entry.configBase = this;
|
entry.configBase = this;
|
||||||
@@ -160,7 +160,7 @@ public class ConfigBase
|
|||||||
{
|
{
|
||||||
LOGGER.error("Invalid variable type at [" + (category.isEmpty() ? "" : category + ".") + field.getName() + "].");
|
LOGGER.error("Invalid variable type at [" + (category.isEmpty() ? "" : category + ".") + field.getName() + "].");
|
||||||
LOGGER.error("Type [" + entry.getType() + "] is not one of these types [" + acceptableInputs.toString() + "]");
|
LOGGER.error("Type [" + entry.getType() + "] is not one of these types [" + acceptableInputs.toString() + "]");
|
||||||
entries.removeLast(); // Delete the entry if it is invalid so the game can still run
|
entries.remove(entries.size() - 1); // Delete the entry if it is invalid so the game can still run
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import java.util.Map;
|
|||||||
public class NumberUtil
|
public class NumberUtil
|
||||||
{
|
{
|
||||||
// Is there no better way of doing this?
|
// Is there no better way of doing this?
|
||||||
public static Map<Class<?>, Number> minValues = new HashMap<>()
|
public static Map<Class<?>, Number> minValues = new HashMap<Class<?>, Number>()
|
||||||
{{
|
{{
|
||||||
put(Byte.class, Byte.MIN_VALUE);
|
put(Byte.class, Byte.MIN_VALUE);
|
||||||
put(Short.class, Short.MIN_VALUE);
|
put(Short.class, Short.MIN_VALUE);
|
||||||
@@ -41,7 +41,7 @@ public class NumberUtil
|
|||||||
put(Double.class, Double.MIN_VALUE);
|
put(Double.class, Double.MIN_VALUE);
|
||||||
put(Float.class, Float.MIN_VALUE);
|
put(Float.class, Float.MIN_VALUE);
|
||||||
}};
|
}};
|
||||||
public static Map<Class<?>, Number> maxValues = new HashMap<>()
|
public static Map<Class<?>, Number> maxValues = new HashMap<Class<?>, Number>()
|
||||||
{{
|
{{
|
||||||
put(Byte.class, Byte.MAX_VALUE);
|
put(Byte.class, Byte.MAX_VALUE);
|
||||||
put(Short.class, Short.MAX_VALUE);
|
put(Short.class, Short.MAX_VALUE);
|
||||||
|
|||||||
+2
-2
@@ -35,8 +35,8 @@ public class QuickRenderToggleConfigEventHandler
|
|||||||
/** private since we only ever need one handler at a time */
|
/** private since we only ever need one handler at a time */
|
||||||
private QuickRenderToggleConfigEventHandler()
|
private QuickRenderToggleConfigEventHandler()
|
||||||
{
|
{
|
||||||
this.quickRenderChangeListener = new ConfigChangeListener<>(Config.Client.quickEnableRendering, (val) -> Config.Client.Advanced.Debugging.rendererMode.set(Config.Client.quickEnableRendering.get() ? EDhApiRendererMode.DEFAULT : EDhApiRendererMode.DISABLED));
|
this.quickRenderChangeListener = new ConfigChangeListener<>(Config.Client.quickEnableRendering, (val) -> { Config.Client.Advanced.Debugging.rendererMode.set(Config.Client.quickEnableRendering.get() ? EDhApiRendererMode.DEFAULT : EDhApiRendererMode.DISABLED); });
|
||||||
this.rendererModeChangeListener = new ConfigChangeListener<>(Config.Client.Advanced.Debugging.rendererMode, (val) -> Config.Client.quickEnableRendering.set(Config.Client.Advanced.Debugging.rendererMode.get() != EDhApiRendererMode.DISABLED));
|
this.rendererModeChangeListener = new ConfigChangeListener<>(Config.Client.Advanced.Debugging.rendererMode, (val) -> { Config.Client.quickEnableRendering.set(Config.Client.Advanced.Debugging.rendererMode.get() != EDhApiRendererMode.DISABLED); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -32,7 +32,7 @@ public class ResetConfigEventHandler
|
|||||||
/** private since we only ever need one handler at a time */
|
/** private since we only ever need one handler at a time */
|
||||||
private ResetConfigEventHandler()
|
private ResetConfigEventHandler()
|
||||||
{
|
{
|
||||||
this.configChangeListener = new ConfigChangeListener<>(Config.Client.ResetConfirmation.resetAllSettings, this::doStuff);
|
this.configChangeListener = new ConfigChangeListener<>(Config.Client.ResetConfirmation.resetAllSettings, (resetSettings) -> { doStuff(resetSettings); });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -57,7 +57,7 @@ public abstract class AbstractPresetConfigEventHandler<TPresetEnum extends Enum<
|
|||||||
|
|
||||||
public AbstractPresetConfigEventHandler()
|
public AbstractPresetConfigEventHandler()
|
||||||
{
|
{
|
||||||
configGui.addOnScreenChangeListener(this::onConfigUiClosed);
|
configGui.addOnScreenChangeListener(() -> this.onConfigUiClosed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -216,7 +216,7 @@ public abstract class AbstractPresetConfigEventHandler<TPresetEnum extends Enum<
|
|||||||
possiblePrestList.add(this.getCustomPresetEnum());
|
possiblePrestList.add(this.getCustomPresetEnum());
|
||||||
}
|
}
|
||||||
|
|
||||||
return possiblePrestList.getFirst();
|
return possiblePrestList.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -41,7 +41,7 @@ public class RenderQualityPresetConfigEventHandler extends AbstractPresetConfigE
|
|||||||
|
|
||||||
|
|
||||||
private final ConfigEntryWithPresetOptions<EDhApiQualityPreset, EDhApiMaxHorizontalResolution> drawResolution = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.Graphics.Quality.maxHorizontalResolution,
|
private final ConfigEntryWithPresetOptions<EDhApiQualityPreset, EDhApiMaxHorizontalResolution> drawResolution = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.Graphics.Quality.maxHorizontalResolution,
|
||||||
new HashMap<>()
|
new HashMap<EDhApiQualityPreset, EDhApiMaxHorizontalResolution>()
|
||||||
{{
|
{{
|
||||||
this.put(EDhApiQualityPreset.MINIMUM, EDhApiMaxHorizontalResolution.TWO_BLOCKS);
|
this.put(EDhApiQualityPreset.MINIMUM, EDhApiMaxHorizontalResolution.TWO_BLOCKS);
|
||||||
this.put(EDhApiQualityPreset.LOW, EDhApiMaxHorizontalResolution.BLOCK);
|
this.put(EDhApiQualityPreset.LOW, EDhApiMaxHorizontalResolution.BLOCK);
|
||||||
@@ -50,7 +50,7 @@ public class RenderQualityPresetConfigEventHandler extends AbstractPresetConfigE
|
|||||||
this.put(EDhApiQualityPreset.EXTREME, EDhApiMaxHorizontalResolution.BLOCK);
|
this.put(EDhApiQualityPreset.EXTREME, EDhApiMaxHorizontalResolution.BLOCK);
|
||||||
}});
|
}});
|
||||||
private final ConfigEntryWithPresetOptions<EDhApiQualityPreset, EDhApiVerticalQuality> verticalQuality = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.Graphics.Quality.verticalQuality,
|
private final ConfigEntryWithPresetOptions<EDhApiQualityPreset, EDhApiVerticalQuality> verticalQuality = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.Graphics.Quality.verticalQuality,
|
||||||
new HashMap<>()
|
new HashMap<EDhApiQualityPreset, EDhApiVerticalQuality>()
|
||||||
{{
|
{{
|
||||||
this.put(EDhApiQualityPreset.MINIMUM, EDhApiVerticalQuality.HEIGHT_MAP);
|
this.put(EDhApiQualityPreset.MINIMUM, EDhApiVerticalQuality.HEIGHT_MAP);
|
||||||
this.put(EDhApiQualityPreset.LOW, EDhApiVerticalQuality.LOW);
|
this.put(EDhApiQualityPreset.LOW, EDhApiVerticalQuality.LOW);
|
||||||
@@ -59,7 +59,7 @@ public class RenderQualityPresetConfigEventHandler extends AbstractPresetConfigE
|
|||||||
this.put(EDhApiQualityPreset.EXTREME, EDhApiVerticalQuality.EXTREME);
|
this.put(EDhApiQualityPreset.EXTREME, EDhApiVerticalQuality.EXTREME);
|
||||||
}});
|
}});
|
||||||
private final ConfigEntryWithPresetOptions<EDhApiQualityPreset, EDhApiHorizontalQuality> horizontalQuality = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.Graphics.Quality.horizontalQuality,
|
private final ConfigEntryWithPresetOptions<EDhApiQualityPreset, EDhApiHorizontalQuality> horizontalQuality = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.Graphics.Quality.horizontalQuality,
|
||||||
new HashMap<>()
|
new HashMap<EDhApiQualityPreset, EDhApiHorizontalQuality>()
|
||||||
{{
|
{{
|
||||||
this.put(EDhApiQualityPreset.MINIMUM, EDhApiHorizontalQuality.LOWEST);
|
this.put(EDhApiQualityPreset.MINIMUM, EDhApiHorizontalQuality.LOWEST);
|
||||||
this.put(EDhApiQualityPreset.LOW, EDhApiHorizontalQuality.LOW);
|
this.put(EDhApiQualityPreset.LOW, EDhApiHorizontalQuality.LOW);
|
||||||
@@ -68,7 +68,7 @@ public class RenderQualityPresetConfigEventHandler extends AbstractPresetConfigE
|
|||||||
this.put(EDhApiQualityPreset.EXTREME, EDhApiHorizontalQuality.EXTREME);
|
this.put(EDhApiQualityPreset.EXTREME, EDhApiHorizontalQuality.EXTREME);
|
||||||
}});
|
}});
|
||||||
private final ConfigEntryWithPresetOptions<EDhApiQualityPreset, EDhApiTransparency> transparency = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.Graphics.Quality.transparency,
|
private final ConfigEntryWithPresetOptions<EDhApiQualityPreset, EDhApiTransparency> transparency = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.Graphics.Quality.transparency,
|
||||||
new HashMap<>()
|
new HashMap<EDhApiQualityPreset, EDhApiTransparency>()
|
||||||
{{
|
{{
|
||||||
this.put(EDhApiQualityPreset.MINIMUM, EDhApiTransparency.DISABLED);
|
this.put(EDhApiQualityPreset.MINIMUM, EDhApiTransparency.DISABLED);
|
||||||
this.put(EDhApiQualityPreset.LOW, EDhApiTransparency.DISABLED); // should be fake if/when fake is fixed
|
this.put(EDhApiQualityPreset.LOW, EDhApiTransparency.DISABLED); // should be fake if/when fake is fixed
|
||||||
@@ -77,7 +77,7 @@ public class RenderQualityPresetConfigEventHandler extends AbstractPresetConfigE
|
|||||||
this.put(EDhApiQualityPreset.EXTREME, EDhApiTransparency.COMPLETE);
|
this.put(EDhApiQualityPreset.EXTREME, EDhApiTransparency.COMPLETE);
|
||||||
}});
|
}});
|
||||||
private final ConfigEntryWithPresetOptions<EDhApiQualityPreset, Boolean> ssaoEnabled = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.Graphics.Ssao.enabled,
|
private final ConfigEntryWithPresetOptions<EDhApiQualityPreset, Boolean> ssaoEnabled = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.Graphics.Ssao.enabled,
|
||||||
new HashMap<>()
|
new HashMap<EDhApiQualityPreset, Boolean>()
|
||||||
{{
|
{{
|
||||||
this.put(EDhApiQualityPreset.MINIMUM, false);
|
this.put(EDhApiQualityPreset.MINIMUM, false);
|
||||||
this.put(EDhApiQualityPreset.LOW, false);
|
this.put(EDhApiQualityPreset.LOW, false);
|
||||||
@@ -106,7 +106,7 @@ public class RenderQualityPresetConfigEventHandler extends AbstractPresetConfigE
|
|||||||
for (ConfigEntryWithPresetOptions<EDhApiQualityPreset, ?> config : this.configList)
|
for (ConfigEntryWithPresetOptions<EDhApiQualityPreset, ?> config : this.configList)
|
||||||
{
|
{
|
||||||
// ignore try-using, the listener should only ever be added once and should never be removed
|
// ignore try-using, the listener should only ever be added once and should never be removed
|
||||||
new ConfigChangeListener<>(config.configEntry, (val) -> this.onConfigValueChanged());
|
new ConfigChangeListener<>(config.configEntry, (val) -> { this.onConfigValueChanged(); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -42,7 +42,7 @@ public class ThreadPresetConfigEventHandler extends AbstractPresetConfigEventHan
|
|||||||
|
|
||||||
public static int getWorldGenDefaultThreadCount() { return getThreadCountByPercent(0.1); }
|
public static int getWorldGenDefaultThreadCount() { return getThreadCountByPercent(0.1); }
|
||||||
private final ConfigEntryWithPresetOptions<EDhApiThreadPreset, Integer> worldGenThreadCount = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.MultiThreading.numberOfWorldGenerationThreads,
|
private final ConfigEntryWithPresetOptions<EDhApiThreadPreset, Integer> worldGenThreadCount = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.MultiThreading.numberOfWorldGenerationThreads,
|
||||||
new HashMap<>()
|
new HashMap<EDhApiThreadPreset, Integer>()
|
||||||
{{
|
{{
|
||||||
this.put(EDhApiThreadPreset.MINIMAL_IMPACT, 1);
|
this.put(EDhApiThreadPreset.MINIMAL_IMPACT, 1);
|
||||||
this.put(EDhApiThreadPreset.LOW_IMPACT, getWorldGenDefaultThreadCount());
|
this.put(EDhApiThreadPreset.LOW_IMPACT, getWorldGenDefaultThreadCount());
|
||||||
@@ -52,7 +52,7 @@ public class ThreadPresetConfigEventHandler extends AbstractPresetConfigEventHan
|
|||||||
}});
|
}});
|
||||||
public static double getWorldGenDefaultRunTimeRatio() { return 0.5; }
|
public static double getWorldGenDefaultRunTimeRatio() { return 0.5; }
|
||||||
private final ConfigEntryWithPresetOptions<EDhApiThreadPreset, Double> worldGenRunTime = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.MultiThreading.runTimeRatioForWorldGenerationThreads,
|
private final ConfigEntryWithPresetOptions<EDhApiThreadPreset, Double> worldGenRunTime = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.MultiThreading.runTimeRatioForWorldGenerationThreads,
|
||||||
new HashMap<>()
|
new HashMap<EDhApiThreadPreset, Double>()
|
||||||
{{
|
{{
|
||||||
this.put(EDhApiThreadPreset.MINIMAL_IMPACT, 0.1);
|
this.put(EDhApiThreadPreset.MINIMAL_IMPACT, 0.1);
|
||||||
this.put(EDhApiThreadPreset.LOW_IMPACT, getWorldGenDefaultRunTimeRatio());
|
this.put(EDhApiThreadPreset.LOW_IMPACT, getWorldGenDefaultRunTimeRatio());
|
||||||
@@ -64,7 +64,7 @@ public class ThreadPresetConfigEventHandler extends AbstractPresetConfigEventHan
|
|||||||
|
|
||||||
public static int getFileHandlerDefaultThreadCount() { return getThreadCountByPercent(0.1); }
|
public static int getFileHandlerDefaultThreadCount() { return getThreadCountByPercent(0.1); }
|
||||||
private final ConfigEntryWithPresetOptions<EDhApiThreadPreset, Integer> fileHandlerThreadCount = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.MultiThreading.numberOfFileHandlerThreads,
|
private final ConfigEntryWithPresetOptions<EDhApiThreadPreset, Integer> fileHandlerThreadCount = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.MultiThreading.numberOfFileHandlerThreads,
|
||||||
new HashMap<>()
|
new HashMap<EDhApiThreadPreset, Integer>()
|
||||||
{{
|
{{
|
||||||
this.put(EDhApiThreadPreset.MINIMAL_IMPACT, 1);
|
this.put(EDhApiThreadPreset.MINIMAL_IMPACT, 1);
|
||||||
this.put(EDhApiThreadPreset.LOW_IMPACT, getFileHandlerDefaultThreadCount());
|
this.put(EDhApiThreadPreset.LOW_IMPACT, getFileHandlerDefaultThreadCount());
|
||||||
@@ -74,7 +74,7 @@ public class ThreadPresetConfigEventHandler extends AbstractPresetConfigEventHan
|
|||||||
}});
|
}});
|
||||||
public static double getFileHandlerDefaultRunTimeRatio() { return 0.5; }
|
public static double getFileHandlerDefaultRunTimeRatio() { return 0.5; }
|
||||||
private final ConfigEntryWithPresetOptions<EDhApiThreadPreset, Double> fileHandlerRunTime = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.MultiThreading.runTimeRatioForFileHandlerThreads,
|
private final ConfigEntryWithPresetOptions<EDhApiThreadPreset, Double> fileHandlerRunTime = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.MultiThreading.runTimeRatioForFileHandlerThreads,
|
||||||
new HashMap<>()
|
new HashMap<EDhApiThreadPreset, Double>()
|
||||||
{{
|
{{
|
||||||
this.put(EDhApiThreadPreset.MINIMAL_IMPACT, 0.25);
|
this.put(EDhApiThreadPreset.MINIMAL_IMPACT, 0.25);
|
||||||
this.put(EDhApiThreadPreset.LOW_IMPACT, getFileHandlerDefaultRunTimeRatio());
|
this.put(EDhApiThreadPreset.LOW_IMPACT, getFileHandlerDefaultRunTimeRatio());
|
||||||
@@ -86,7 +86,7 @@ public class ThreadPresetConfigEventHandler extends AbstractPresetConfigEventHan
|
|||||||
|
|
||||||
public static int getUpdatePropagatorDefaultThreadCount() { return getThreadCountByPercent(0.10); }
|
public static int getUpdatePropagatorDefaultThreadCount() { return getThreadCountByPercent(0.10); }
|
||||||
private final ConfigEntryWithPresetOptions<EDhApiThreadPreset, Integer> UpdatePropagatorThreadCount = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.MultiThreading.numberOfUpdatePropagatorThreads,
|
private final ConfigEntryWithPresetOptions<EDhApiThreadPreset, Integer> UpdatePropagatorThreadCount = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.MultiThreading.numberOfUpdatePropagatorThreads,
|
||||||
new HashMap<>()
|
new HashMap<EDhApiThreadPreset, Integer>()
|
||||||
{{
|
{{
|
||||||
this.put(EDhApiThreadPreset.MINIMAL_IMPACT, 1);
|
this.put(EDhApiThreadPreset.MINIMAL_IMPACT, 1);
|
||||||
this.put(EDhApiThreadPreset.LOW_IMPACT, getUpdatePropagatorDefaultThreadCount());
|
this.put(EDhApiThreadPreset.LOW_IMPACT, getUpdatePropagatorDefaultThreadCount());
|
||||||
@@ -96,7 +96,7 @@ public class ThreadPresetConfigEventHandler extends AbstractPresetConfigEventHan
|
|||||||
}});
|
}});
|
||||||
public static double getUpdatePropagatorDefaultRunTimeRatio() { return 0.25; }
|
public static double getUpdatePropagatorDefaultRunTimeRatio() { return 0.25; }
|
||||||
private final ConfigEntryWithPresetOptions<EDhApiThreadPreset, Double> UpdatePropagatorRunTime = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.MultiThreading.runTimeRatioForUpdatePropagatorThreads,
|
private final ConfigEntryWithPresetOptions<EDhApiThreadPreset, Double> UpdatePropagatorRunTime = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.MultiThreading.runTimeRatioForUpdatePropagatorThreads,
|
||||||
new HashMap<>()
|
new HashMap<EDhApiThreadPreset, Double>()
|
||||||
{{
|
{{
|
||||||
this.put(EDhApiThreadPreset.MINIMAL_IMPACT, 0.1);
|
this.put(EDhApiThreadPreset.MINIMAL_IMPACT, 0.1);
|
||||||
this.put(EDhApiThreadPreset.LOW_IMPACT, getUpdatePropagatorDefaultRunTimeRatio());
|
this.put(EDhApiThreadPreset.LOW_IMPACT, getUpdatePropagatorDefaultRunTimeRatio());
|
||||||
@@ -108,7 +108,7 @@ public class ThreadPresetConfigEventHandler extends AbstractPresetConfigEventHan
|
|||||||
|
|
||||||
public static int getLodBuilderDefaultThreadCount() { return getThreadCountByPercent(0.1); }
|
public static int getLodBuilderDefaultThreadCount() { return getThreadCountByPercent(0.1); }
|
||||||
private final ConfigEntryWithPresetOptions<EDhApiThreadPreset, Integer> lodBuilderThreadCount = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.MultiThreading.numberOfLodBuilderThreads,
|
private final ConfigEntryWithPresetOptions<EDhApiThreadPreset, Integer> lodBuilderThreadCount = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.MultiThreading.numberOfLodBuilderThreads,
|
||||||
new HashMap<>()
|
new HashMap<EDhApiThreadPreset, Integer>()
|
||||||
{{
|
{{
|
||||||
this.put(EDhApiThreadPreset.MINIMAL_IMPACT, 1);
|
this.put(EDhApiThreadPreset.MINIMAL_IMPACT, 1);
|
||||||
this.put(EDhApiThreadPreset.LOW_IMPACT, getLodBuilderDefaultThreadCount());
|
this.put(EDhApiThreadPreset.LOW_IMPACT, getLodBuilderDefaultThreadCount());
|
||||||
@@ -118,7 +118,7 @@ public class ThreadPresetConfigEventHandler extends AbstractPresetConfigEventHan
|
|||||||
}});
|
}});
|
||||||
public static double getLodBuilderDefaultRunTimeRatio() { return 0.25; }
|
public static double getLodBuilderDefaultRunTimeRatio() { return 0.25; }
|
||||||
private final ConfigEntryWithPresetOptions<EDhApiThreadPreset, Double> lodBuilderRunTime = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.MultiThreading.runTimeRatioForLodBuilderThreads,
|
private final ConfigEntryWithPresetOptions<EDhApiThreadPreset, Double> lodBuilderRunTime = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.MultiThreading.runTimeRatioForLodBuilderThreads,
|
||||||
new HashMap<>()
|
new HashMap<EDhApiThreadPreset, Double>()
|
||||||
{{
|
{{
|
||||||
this.put(EDhApiThreadPreset.MINIMAL_IMPACT, 0.1);
|
this.put(EDhApiThreadPreset.MINIMAL_IMPACT, 0.1);
|
||||||
this.put(EDhApiThreadPreset.LOW_IMPACT, getLodBuilderDefaultRunTimeRatio());
|
this.put(EDhApiThreadPreset.LOW_IMPACT, getLodBuilderDefaultRunTimeRatio());
|
||||||
@@ -153,7 +153,7 @@ public class ThreadPresetConfigEventHandler extends AbstractPresetConfigEventHan
|
|||||||
for (ConfigEntryWithPresetOptions<EDhApiThreadPreset, ?> config : this.configList)
|
for (ConfigEntryWithPresetOptions<EDhApiThreadPreset, ?> config : this.configList)
|
||||||
{
|
{
|
||||||
// ignore try-using, the listeners should only ever be added once and should never be removed
|
// ignore try-using, the listeners should only ever be added once and should never be removed
|
||||||
new ConfigChangeListener<>(config.configEntry, (val) -> this.onConfigValueChanged());
|
new ConfigChangeListener<>(config.configEntry, (val) -> { this.onConfigValueChanged(); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ import java.util.Map;
|
|||||||
public class ConfigTypeConverters
|
public class ConfigTypeConverters
|
||||||
{
|
{
|
||||||
// Once you've made a converter add it to here where the first value is the type you want to convert and the 2nd value is the converter
|
// Once you've made a converter add it to here where the first value is the type you want to convert and the 2nd value is the converter
|
||||||
public static final Map<Class<?>, ConverterBase> convertObjects = new HashMap<>()
|
public static final Map<Class<?>, ConverterBase> convertObjects = new HashMap<Class<?>, ConverterBase>()
|
||||||
{{
|
{{
|
||||||
this.put(Short.class, new ShortConverter());
|
this.put(Short.class, new ShortConverter());
|
||||||
this.put(Long.class, new LongConverter());
|
this.put(Long.class, new LongConverter());
|
||||||
|
|||||||
+20
-15
@@ -73,28 +73,33 @@ public final class EmbeddedFrameUtil
|
|||||||
|
|
||||||
private static String getEmbeddedFrameImpl()
|
private static String getEmbeddedFrameImpl()
|
||||||
{
|
{
|
||||||
return switch (EPlatform.get())
|
switch (EPlatform.get())
|
||||||
{
|
{
|
||||||
case LINUX -> "sun.awt.X11.XEmbeddedFrame";
|
case LINUX:
|
||||||
case WINDOWS -> "sun.awt.windows.WEmbeddedFrame";
|
return "sun.awt.X11.XEmbeddedFrame";
|
||||||
case MACOS -> "sun.lwawt.macosx.CViewEmbeddedFrame";
|
case WINDOWS:
|
||||||
default -> throw new IllegalStateException();
|
return "sun.awt.windows.WEmbeddedFrame";
|
||||||
};
|
case MACOS:
|
||||||
|
return "sun.lwawt.macosx.CViewEmbeddedFrame";
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long getEmbeddedFrameHandle(long window)
|
private static long getEmbeddedFrameHandle(long window)
|
||||||
{
|
{
|
||||||
return switch (EPlatform.get())
|
switch (EPlatform.get())
|
||||||
{
|
{
|
||||||
case LINUX -> glfwGetX11Window(window);
|
case LINUX:
|
||||||
case WINDOWS -> glfwGetWin32Window(window);
|
return glfwGetX11Window(window);
|
||||||
case MACOS ->
|
case WINDOWS:
|
||||||
{
|
return glfwGetWin32Window(window);
|
||||||
|
case MACOS:
|
||||||
long objc_msgSend = ObjCRuntime.getLibrary().getFunctionAddress("objc_msgSend");
|
long objc_msgSend = ObjCRuntime.getLibrary().getFunctionAddress("objc_msgSend");
|
||||||
yield invokePPP(glfwGetCocoaWindow(window), sel_getUid("contentView"), objc_msgSend);
|
return invokePPP(glfwGetCocoaWindow(window), sel_getUid("contentView"), objc_msgSend);
|
||||||
}
|
default:
|
||||||
default -> throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Frame embeddedFrameCreate(long window)
|
public static Frame embeddedFrameCreate(long window)
|
||||||
|
|||||||
@@ -256,38 +256,20 @@ public class ConfigEntry<T> extends AbstractConfigType<T, ConfigEntry<T>> implem
|
|||||||
public byte isValid(T value, T min, T max)
|
public byte isValid(T value, T min, T max)
|
||||||
{
|
{
|
||||||
if (this.configBase.disableMinMax)
|
if (this.configBase.disableMinMax)
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
else if (min == null && max == null)
|
if (value == null || this.value == null || value.getClass() != this.value.getClass()) // If the 2 variables aren't the same type then it will be invalid
|
||||||
{
|
|
||||||
// no validation is needed for this field
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if (value == null || this.value == null
|
|
||||||
|| value.getClass() != this.value.getClass())
|
|
||||||
{
|
|
||||||
// If the 2 variables aren't the same type then it will be invalid
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
if (Number.class.isAssignableFrom(value.getClass()))
|
||||||
else if (Number.class.isAssignableFrom(value.getClass()))
|
{ // Only check min max if it is a number
|
||||||
{
|
|
||||||
// Only check min max if it is a number
|
|
||||||
if (max != null && NumberUtil.greaterThan((Number) value, (Number) max))
|
if (max != null && NumberUtil.greaterThan((Number) value, (Number) max))
|
||||||
{
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
if (min != null && NumberUtil.lessThan((Number) value, (Number) min))
|
if (min != null && NumberUtil.lessThan((Number) value, (Number) min))
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
return 0;
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This should normally not be called since set() automatically calls this */
|
/** This should normally not be called since set() automatically calls this */
|
||||||
|
|||||||
+2
-1
@@ -516,9 +516,10 @@ public class FullDataPointIdMap
|
|||||||
if (otherObj == this)
|
if (otherObj == this)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!(otherObj instanceof Entry other))
|
if (!(otherObj instanceof Entry))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Entry other = (Entry) otherObj;
|
||||||
return other.biome.getSerialString().equals(this.biome.getSerialString())
|
return other.biome.getSerialString().equals(this.biome.getSerialString())
|
||||||
&& other.blockState.getSerialString().equals(this.blockState.getSerialString());
|
&& other.blockState.getSerialString().equals(this.blockState.getSerialString());
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -62,8 +62,6 @@ public class FullDataSourceV2 implements IDataSource<IDhLevel>
|
|||||||
|
|
||||||
/** measured in data columns */
|
/** measured in data columns */
|
||||||
public static final int WIDTH = 64;
|
public static final int WIDTH = 64;
|
||||||
/** how many chunks wide this datasource is. */
|
|
||||||
public static final int NUMB_OF_CHUNKS_WIDE = WIDTH / LodUtil.CHUNK_WIDTH;
|
|
||||||
|
|
||||||
public static final byte DATA_FORMAT_VERSION = 1;
|
public static final byte DATA_FORMAT_VERSION = 1;
|
||||||
|
|
||||||
@@ -927,10 +925,11 @@ public class FullDataSourceV2 implements IDataSource<IDhLevel>
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
if (!(obj instanceof FullDataSourceV2 other))
|
if (!(obj instanceof FullDataSourceV2))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
FullDataSourceV2 other = (FullDataSourceV2) obj;
|
||||||
|
|
||||||
if (other.pos != this.pos)
|
if (other.pos != this.pos)
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -182,7 +182,7 @@ public class ColumnRenderSource implements IDataSource<IDhClientLevel>
|
|||||||
EDhApiWorldGenerationStep worldGenStep = inputFullDataSource.getWorldGenStepAtRelativePos(x, z);
|
EDhApiWorldGenerationStep worldGenStep = inputFullDataSource.getWorldGenStepAtRelativePos(x, z);
|
||||||
if (dataColumn != null && worldGenStep != EDhApiWorldGenerationStep.EMPTY)
|
if (dataColumn != null && worldGenStep != EDhApiWorldGenerationStep.EMPTY)
|
||||||
{
|
{
|
||||||
FullDataToRenderDataTransformer.updateRenderDataViewWithFullDataColumn(
|
FullDataToRenderDataTransformer.convertColumnData(
|
||||||
level, inputFullDataSource.mapping,
|
level, inputFullDataSource.mapping,
|
||||||
minBlockPos.x + x,
|
minBlockPos.x + x,
|
||||||
minBlockPos.z + z,
|
minBlockPos.z + z,
|
||||||
|
|||||||
+22
-12
@@ -99,23 +99,33 @@ public final class BufferQuad
|
|||||||
|
|
||||||
if (compareDirection == BufferMergeDirectionEnum.EastWest)
|
if (compareDirection == BufferMergeDirectionEnum.EastWest)
|
||||||
{
|
{
|
||||||
return switch (this.direction.getAxis())
|
switch (this.direction.getAxis())
|
||||||
{
|
{
|
||||||
case X -> threeDimensionalCompare(this.x, this.y, this.z, quad.x, quad.y, quad.z);
|
case X:
|
||||||
case Y -> threeDimensionalCompare(this.y, this.z, this.x, quad.y, quad.z, quad.x);
|
return threeDimensionalCompare(this.x, this.y, this.z, quad.x, quad.y, quad.z);
|
||||||
case Z -> threeDimensionalCompare(this.z, this.y, this.x, quad.z, quad.y, quad.x);
|
case Y:
|
||||||
default -> throw new IllegalArgumentException("Invalid Axis enum: " + this.direction.getAxis());
|
return threeDimensionalCompare(this.y, this.z, this.x, quad.y, quad.z, quad.x);
|
||||||
};
|
case Z:
|
||||||
|
return threeDimensionalCompare(this.z, this.y, this.x, quad.z, quad.y, quad.x);
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Invalid Axis enum: " + this.direction.getAxis());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return switch (this.direction.getAxis())
|
switch (this.direction.getAxis())
|
||||||
{
|
{
|
||||||
case X -> threeDimensionalCompare(this.x, this.z, this.y, quad.x, quad.z, quad.y);
|
case X:
|
||||||
case Y -> threeDimensionalCompare(this.y, this.x, this.z, quad.y, quad.x, quad.z);
|
return threeDimensionalCompare(this.x, this.z, this.y, quad.x, quad.z, quad.y);
|
||||||
case Z -> threeDimensionalCompare(this.z, this.x, this.y, quad.z, quad.x, quad.y);
|
case Y:
|
||||||
default -> throw new IllegalArgumentException("Invalid Axis enum: " + this.direction.getAxis());
|
return threeDimensionalCompare(this.y, this.x, this.z, quad.y, quad.x, quad.z);
|
||||||
};
|
case Z:
|
||||||
|
return threeDimensionalCompare(this.z, this.x, this.y, quad.z, quad.x, quad.y);
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Invalid Axis enum: " + this.direction.getAxis());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
+96
-202
@@ -20,15 +20,11 @@
|
|||||||
package com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding;
|
package com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.pos.DhBlockPos;
|
import com.seibel.distanthorizons.core.pos.DhBlockPos;
|
||||||
import com.seibel.distanthorizons.core.render.glObject.GLProxy;
|
|
||||||
import com.seibel.distanthorizons.core.render.glObject.buffer.GLVertexBuffer;
|
|
||||||
import com.seibel.distanthorizons.core.render.renderer.LodRenderer;
|
import com.seibel.distanthorizons.core.render.renderer.LodRenderer;
|
||||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||||
import com.seibel.distanthorizons.core.util.objects.StatsMap;
|
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
|
||||||
import com.seibel.distanthorizons.core.util.*;
|
import com.seibel.distanthorizons.core.util.*;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||||
@@ -53,19 +49,18 @@ public class ColumnRenderBuffer implements AutoCloseable
|
|||||||
/** number of bytes a single quad takes */
|
/** number of bytes a single quad takes */
|
||||||
public static final int QUADS_BYTE_SIZE = LodUtil.LOD_VERTEX_FORMAT.getByteSize() * 4;
|
public static final int QUADS_BYTE_SIZE = LodUtil.LOD_VERTEX_FORMAT.getByteSize() * 4;
|
||||||
/** how big a single VBO can be in bytes */
|
/** how big a single VBO can be in bytes */
|
||||||
public static final int MAX_VBO_BYTE_SIZE = 10 * 1024 * 1024; // 10 MB
|
public static final int MAX_VBO_BYTE_SIZE = 1024 * 1024; // 1 MB
|
||||||
public static final int MAX_QUADS_PER_BUFFER = MAX_VBO_BYTE_SIZE / QUADS_BYTE_SIZE;
|
public static final int MAX_QUADS_PER_BUFFER = MAX_VBO_BYTE_SIZE / QUADS_BYTE_SIZE;
|
||||||
public static final int FULL_SIZED_BUFFER = MAX_QUADS_PER_BUFFER * QUADS_BYTE_SIZE;
|
public static final int FULL_SIZED_BUFFER = MAX_QUADS_PER_BUFFER * QUADS_BYTE_SIZE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public final DhBlockPos pos;
|
public final DhBlockPos pos;
|
||||||
|
|
||||||
public boolean buffersUploaded = false;
|
public boolean buffersUploaded = false;
|
||||||
|
|
||||||
private GLVertexBuffer[] vbos;
|
public SharedVbo.BufferSlice[] opaqueBufferSlices;
|
||||||
private GLVertexBuffer[] vbosTransparent;
|
public SharedVbo.BufferSlice[] transparentBufferSlices;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -76,14 +71,12 @@ public class ColumnRenderBuffer implements AutoCloseable
|
|||||||
public ColumnRenderBuffer(DhBlockPos pos)
|
public ColumnRenderBuffer(DhBlockPos pos)
|
||||||
{
|
{
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
this.vbos = new GLVertexBuffer[0];
|
this.opaqueBufferSlices = new SharedVbo.BufferSlice[0];
|
||||||
this.vbosTransparent = new GLVertexBuffer[0];
|
this.transparentBufferSlices = new SharedVbo.BufferSlice[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==================//
|
//==================//
|
||||||
// buffer uploading //
|
// buffer uploading //
|
||||||
//==================//
|
//==================//
|
||||||
@@ -128,193 +121,132 @@ public class ColumnRenderBuffer implements AutoCloseable
|
|||||||
}
|
}
|
||||||
private void uploadBuffersUsingUploadMethod(LodQuadBuilder builder, EDhApiGpuUploadMethod gpuUploadMethod) throws InterruptedException
|
private void uploadBuffersUsingUploadMethod(LodQuadBuilder builder, EDhApiGpuUploadMethod gpuUploadMethod) throws InterruptedException
|
||||||
{
|
{
|
||||||
if (gpuUploadMethod.useEarlyMapping)
|
//if (gpuUploadMethod.useEarlyMapping)
|
||||||
{
|
//{
|
||||||
this.uploadBuffersMapped(builder, gpuUploadMethod);
|
// this.uploadBuffersMapped(builder, gpuUploadMethod);
|
||||||
}
|
//}
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
this.uploadBuffersDirect(builder, gpuUploadMethod);
|
this.uploadBuffersDirect(builder);
|
||||||
}
|
//}
|
||||||
|
|
||||||
this.buffersUploaded = true;
|
this.buffersUploaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void uploadBuffersMapped(LodQuadBuilder builder, EDhApiGpuUploadMethod method)
|
//private void uploadBuffersMapped(LodQuadBuilder builder, EDhApiGpuUploadMethod method)
|
||||||
|
//{
|
||||||
|
// // opaque vbos //
|
||||||
|
//
|
||||||
|
// this.vbos = ColumnRenderBufferBuilder.resizeBuffer(this.vbos, builder.getCurrentNeededOpaqueVertexBufferCount());
|
||||||
|
// for (int i = 0; i < this.vbos.length; i++)
|
||||||
|
// {
|
||||||
|
// if (this.vbos[i] == null)
|
||||||
|
// {
|
||||||
|
// this.vbos[i] = new GLVertexBuffer(method.useBufferStorage);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// LodQuadBuilder.BufferFiller func = builder.makeOpaqueBufferFiller(method);
|
||||||
|
// for (GLVertexBuffer vbo : this.vbos)
|
||||||
|
// {
|
||||||
|
// func.fill(vbo);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// // transparent vbos //
|
||||||
|
//
|
||||||
|
// this.vbosTransparent = ColumnRenderBufferBuilder.resizeBuffer(this.vbosTransparent, builder.getCurrentNeededTransparentVertexBufferCount());
|
||||||
|
// for (int i = 0; i < this.vbosTransparent.length; i++)
|
||||||
|
// {
|
||||||
|
// if (this.vbosTransparent[i] == null)
|
||||||
|
// {
|
||||||
|
// this.vbosTransparent[i] = new GLVertexBuffer(method.useBufferStorage);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// LodQuadBuilder.BufferFiller transparentFillerFunc = builder.makeTransparentBufferFiller(method);
|
||||||
|
// for (GLVertexBuffer vbo : this.vbosTransparent)
|
||||||
|
// {
|
||||||
|
// transparentFillerFunc.fill(vbo);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
private void uploadBuffersDirect(LodQuadBuilder builder)
|
||||||
{
|
{
|
||||||
// opaque vbos //
|
int opaqueSliceCount = builder.getCurrentNeededOpaqueVertexBufferCount();
|
||||||
|
if (this.opaqueBufferSlices.length != opaqueSliceCount)
|
||||||
this.vbos = ColumnRenderBufferBuilder.resizeBuffer(this.vbos, builder.getCurrentNeededOpaqueVertexBufferCount());
|
|
||||||
for (int i = 0; i < this.vbos.length; i++)
|
|
||||||
{
|
{
|
||||||
if (this.vbos[i] == null)
|
SharedVbo.OPAQUE.deallocate(this.opaqueBufferSlices);
|
||||||
{
|
this.opaqueBufferSlices = new SharedVbo.BufferSlice[opaqueSliceCount];
|
||||||
this.vbos[i] = new GLVertexBuffer(method.useBufferStorage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LodQuadBuilder.BufferFiller func = builder.makeOpaqueBufferFiller(method);
|
|
||||||
for (GLVertexBuffer vbo : this.vbos)
|
|
||||||
{
|
|
||||||
func.fill(vbo);
|
|
||||||
}
|
}
|
||||||
|
uploadBuffersDirect(SharedVbo.OPAQUE, this.opaqueBufferSlices, builder.makeOpaqueVertexBuffers());
|
||||||
|
|
||||||
|
|
||||||
// transparent vbos //
|
int transparentSliceCount = builder.getCurrentNeededTransparentVertexBufferCount();
|
||||||
|
if (this.transparentBufferSlices.length != transparentSliceCount)
|
||||||
this.vbosTransparent = ColumnRenderBufferBuilder.resizeBuffer(this.vbosTransparent, builder.getCurrentNeededTransparentVertexBufferCount());
|
|
||||||
for (int i = 0; i < this.vbosTransparent.length; i++)
|
|
||||||
{
|
{
|
||||||
if (this.vbosTransparent[i] == null)
|
SharedVbo.TRANSPARENT.deallocate(this.transparentBufferSlices);
|
||||||
{
|
this.transparentBufferSlices = new SharedVbo.BufferSlice[transparentSliceCount];
|
||||||
this.vbosTransparent[i] = new GLVertexBuffer(method.useBufferStorage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LodQuadBuilder.BufferFiller transparentFillerFunc = builder.makeTransparentBufferFiller(method);
|
|
||||||
for (GLVertexBuffer vbo : this.vbosTransparent)
|
|
||||||
{
|
|
||||||
transparentFillerFunc.fill(vbo);
|
|
||||||
}
|
}
|
||||||
|
uploadBuffersDirect(SharedVbo.TRANSPARENT, this.transparentBufferSlices, builder.makeTransparentVertexBuffers());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void uploadBuffersDirect(LodQuadBuilder builder, EDhApiGpuUploadMethod method) throws InterruptedException
|
private static void uploadBuffersDirect(SharedVbo handler, SharedVbo.BufferSlice[] bufferSlices, Iterator<ByteBuffer> iter)
|
||||||
{
|
{
|
||||||
this.vbos = ColumnRenderBufferBuilder.resizeBuffer(this.vbos, builder.getCurrentNeededOpaqueVertexBufferCount());
|
int i = 0;
|
||||||
uploadBuffersDirect(this.vbos, builder.makeOpaqueVertexBuffers(), method);
|
|
||||||
|
|
||||||
this.vbosTransparent = ColumnRenderBufferBuilder.resizeBuffer(this.vbosTransparent, builder.getCurrentNeededTransparentVertexBufferCount());
|
|
||||||
uploadBuffersDirect(this.vbosTransparent, builder.makeTransparentVertexBuffers(), method);
|
|
||||||
}
|
|
||||||
private static void uploadBuffersDirect(GLVertexBuffer[] vbos, Iterator<ByteBuffer> iter, EDhApiGpuUploadMethod method) throws InterruptedException
|
|
||||||
{
|
|
||||||
long remainingMS = 0;
|
|
||||||
long MBPerMS = Config.Client.Advanced.GpuBuffers.gpuUploadPerMegabyteInMilliseconds.get();
|
|
||||||
int vboIndex = 0;
|
|
||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
{
|
{
|
||||||
if (vboIndex >= vbos.length)
|
if (i >= bufferSlices.length)
|
||||||
{
|
{
|
||||||
throw new RuntimeException("Too many vertex buffers!!");
|
throw new RuntimeException("Too many vertex buffers!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get or create the buffer
|
||||||
// get or create the VBO
|
if (bufferSlices[i] == null)
|
||||||
if (vbos[vboIndex] == null)
|
|
||||||
{
|
{
|
||||||
vbos[vboIndex] = new GLVertexBuffer(method.useBufferStorage);
|
bufferSlices[i] = handler.allocateSlice();
|
||||||
}
|
}
|
||||||
GLVertexBuffer vbo = vbos[vboIndex];
|
SharedVbo.BufferSlice slice = bufferSlices[i];
|
||||||
|
|
||||||
|
|
||||||
ByteBuffer bb = iter.next();
|
ByteBuffer buffer = iter.next();
|
||||||
int size = bb.limit() - bb.position();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
vbo.bind();
|
handler.updateBuffer(slice, buffer);
|
||||||
vbo.uploadBuffer(bb, size / LodUtil.LOD_VERTEX_FORMAT.getByteSize(), method, FULL_SIZED_BUFFER);
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
vbos[vboIndex] = null;
|
bufferSlices[i] = null;
|
||||||
vbo.close();
|
handler.deallocate(slice);
|
||||||
LOGGER.error("Failed to upload buffer: ", e);
|
LOGGER.error("Failed to upload buffer. Error: ["+e.getMessage()+"].", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
if (MBPerMS > 0)
|
|
||||||
{
|
|
||||||
// upload buffers over an extended period of time
|
|
||||||
// to hopefully prevent stuttering.
|
|
||||||
remainingMS += size * MBPerMS;
|
|
||||||
if (remainingMS >= TimeUnit.NANOSECONDS.convert(1000 / 60, TimeUnit.MILLISECONDS))
|
|
||||||
{
|
|
||||||
if (remainingMS > MAX_BUFFER_UPLOAD_TIMEOUT_NANOSECONDS)
|
|
||||||
{
|
|
||||||
remainingMS = MAX_BUFFER_UPLOAD_TIMEOUT_NANOSECONDS;
|
|
||||||
}
|
|
||||||
|
|
||||||
Thread.sleep(remainingMS / 1000000, (int) (remainingMS % 1000000));
|
|
||||||
remainingMS = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vboIndex++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vboIndex < vbos.length)
|
if (i < bufferSlices.length)
|
||||||
{
|
{
|
||||||
throw new RuntimeException("Too few vertex buffers!!");
|
throw new RuntimeException("Too few buffer chunks!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//========//
|
//========//
|
||||||
// render //
|
// render //
|
||||||
//========//
|
//========//
|
||||||
|
|
||||||
/** @return true if something was rendered, false otherwise */
|
//public void renderOpaque(LodRenderer renderContext, DhApiRenderParam renderEventParam)
|
||||||
public boolean renderOpaque(LodRenderer renderContext, DhApiRenderParam renderEventParam)
|
//{
|
||||||
{
|
// renderContext.setModelViewMatrixOffset(this.pos, renderEventParam);
|
||||||
boolean hasRendered = false;
|
// renderContext.drawSharedVbo(SharedVbo.OPAQUE, this.opaqueBufferSlices);
|
||||||
renderContext.setModelViewMatrixOffset(this.pos, renderEventParam);
|
//}
|
||||||
for (GLVertexBuffer vbo : this.vbos)
|
//
|
||||||
{
|
//public void renderTransparent(LodRenderer renderContext, DhApiRenderParam renderEventParam)
|
||||||
if (vbo == null)
|
//{
|
||||||
{
|
// renderContext.setModelViewMatrixOffset(this.pos, renderEventParam);
|
||||||
continue;
|
// renderContext.drawSharedVbo(SharedVbo.TRANSPARENT, this.transparentBufferSlices);
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (vbo.getVertexCount() == 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
hasRendered = true;
|
|
||||||
renderContext.drawVbo(vbo);
|
|
||||||
//LodRenderer.tickLogger.info("Vertex buffer: {}", vbo);
|
|
||||||
}
|
|
||||||
return hasRendered;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @return true if something was rendered, false otherwise */
|
|
||||||
public boolean renderTransparent(LodRenderer renderContext, DhApiRenderParam renderEventParam)
|
|
||||||
{
|
|
||||||
boolean hasRendered = false;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// can throw an IllegalStateException if the GL program was freed before it should've been
|
|
||||||
renderContext.setModelViewMatrixOffset(this.pos, renderEventParam);
|
|
||||||
|
|
||||||
for (GLVertexBuffer vbo : this.vbosTransparent)
|
|
||||||
{
|
|
||||||
if (vbo == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vbo.getVertexCount() == 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
hasRendered = true;
|
|
||||||
renderContext.drawVbo(vbo);
|
|
||||||
//LodRenderer.tickLogger.info("Vertex buffer: {}", vbo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (IllegalStateException e)
|
|
||||||
{
|
|
||||||
LOGGER.error("renderContext program doesn't exist for pos: "+this.pos, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return hasRendered;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -322,50 +254,28 @@ public class ColumnRenderBuffer implements AutoCloseable
|
|||||||
// misc methods //
|
// misc methods //
|
||||||
//==============//
|
//==============//
|
||||||
|
|
||||||
|
// TODO
|
||||||
/** can be used when debugging */
|
/** can be used when debugging */
|
||||||
public boolean hasNonNullVbos() { return this.vbos != null || this.vbosTransparent != null; }
|
public boolean hasNonNullVbos() { return false; } //this.vbos != null || this.vbosTransparent != null; }
|
||||||
|
|
||||||
/** can be used when debugging */
|
/** can be used when debugging */
|
||||||
public int vboBufferCount()
|
public int bufferSliceCount()
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
if (this.vbos != null)
|
if (this.opaqueBufferSlices != null)
|
||||||
{
|
{
|
||||||
count += this.vbos.length;
|
count += this.opaqueBufferSlices.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.vbosTransparent != null)
|
if (this.transparentBufferSlices != null)
|
||||||
{
|
{
|
||||||
count += this.vbosTransparent.length;
|
count += this.transparentBufferSlices.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void debugDumpStats(StatsMap statsMap)
|
|
||||||
{
|
|
||||||
statsMap.incStat("RenderBuffers");
|
|
||||||
statsMap.incStat("SimpleRenderBuffers");
|
|
||||||
for (GLVertexBuffer vertexBuffer : vbos)
|
|
||||||
{
|
|
||||||
if (vertexBuffer != null)
|
|
||||||
{
|
|
||||||
statsMap.incStat("VBOs");
|
|
||||||
if (vertexBuffer.getSize() == FULL_SIZED_BUFFER)
|
|
||||||
{
|
|
||||||
statsMap.incStat("FullsizedVBOs");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vertexBuffer.getSize() == 0)
|
|
||||||
{
|
|
||||||
GLProxy.GL_LOGGER.warn("VBO with size 0");
|
|
||||||
}
|
|
||||||
statsMap.incBytesStat("TotalUsage", vertexBuffer.getSize());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called when object is no longer in use.
|
* This method is called when object is no longer in use.
|
||||||
* Called either after uploadBuffers() returned false (On buffer Upload
|
* Called either after uploadBuffers() returned false (On buffer Upload
|
||||||
@@ -377,24 +287,8 @@ public class ColumnRenderBuffer implements AutoCloseable
|
|||||||
{
|
{
|
||||||
this.buffersUploaded = false;
|
this.buffersUploaded = false;
|
||||||
|
|
||||||
GLProxy.getInstance().queueRunningOnRenderThread(() ->
|
SharedVbo.OPAQUE.deallocate(this.opaqueBufferSlices);
|
||||||
{
|
SharedVbo.TRANSPARENT.deallocate(this.transparentBufferSlices);
|
||||||
for (GLVertexBuffer buffer : this.vbos)
|
|
||||||
{
|
|
||||||
if (buffer != null)
|
|
||||||
{
|
|
||||||
buffer.destroyAsync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (GLVertexBuffer buffer : this.vbosTransparent)
|
|
||||||
{
|
|
||||||
if (buffer != null)
|
|
||||||
{
|
|
||||||
buffer.destroyAsync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-30
@@ -82,14 +82,33 @@ public class ColumnRenderBufferBuilder
|
|||||||
{
|
{
|
||||||
boolean enableTransparency = Config.Client.Advanced.Graphics.Quality.transparency.get().transparencyEnabled;
|
boolean enableTransparency = Config.Client.Advanced.Graphics.Quality.transparency.get().transparencyEnabled;
|
||||||
|
|
||||||
|
//EVENT_LOGGER.trace("RenderRegion start QuadBuild @ " + renderSource.sectionPos);
|
||||||
|
boolean enableSkyLightCulling =
|
||||||
|
Config.Client.Advanced.Graphics.AdvancedGraphics.enableCaveCulling.get()
|
||||||
|
&& (
|
||||||
|
// dimensions with a ceiling will be all caves so we don't want cave culling
|
||||||
|
!clientLevel.getLevelWrapper().hasCeiling()
|
||||||
|
// the end has a lot of overhangs with 0 lighting above the void, which look broken with
|
||||||
|
// the current cave culling logic (this could probably be improved, but just skipping it works best for now)
|
||||||
|
&& !clientLevel.getLevelWrapper().getDimensionType().isTheEnd()
|
||||||
|
// FIXME temporary fix
|
||||||
|
// Cave culling is currently broken for any detail level above 0
|
||||||
|
&& DhSectionPos.getDetailLevel(renderSource.pos) == DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL
|
||||||
|
);
|
||||||
|
|
||||||
|
int skyLightCullingBelow = Config.Client.Advanced.Graphics.AdvancedGraphics.caveCullingHeight.get();
|
||||||
|
// FIXME: Clamp also to the max world height.
|
||||||
|
skyLightCullingBelow = Math.max(skyLightCullingBelow, clientLevel.getMinY());
|
||||||
|
|
||||||
|
|
||||||
long builderStartTime = System.currentTimeMillis();
|
long builderStartTime = System.currentTimeMillis();
|
||||||
|
|
||||||
LodQuadBuilder builder = new LodQuadBuilder(enableTransparency, clientLevel.getClientLevelWrapper());
|
LodQuadBuilder builder = new LodQuadBuilder(enableSkyLightCulling, (short) (skyLightCullingBelow - clientLevel.getMinY()), enableTransparency, clientLevel.getClientLevelWrapper());
|
||||||
makeLodRenderData(builder, renderSource, adjData);
|
makeLodRenderData(builder, renderSource, adjData);
|
||||||
|
|
||||||
long builderEndTime = System.currentTimeMillis();
|
long builderEndTime = System.currentTimeMillis();
|
||||||
long buildMs = builderEndTime - builderStartTime;
|
long buildMs = builderEndTime - builderStartTime;
|
||||||
//LOGGER.debug("RenderRegion end QuadBuild @ " + renderSource.pos + " took: " + buildMs);
|
LOGGER.debug("RenderRegion end QuadBuild @ " + renderSource.pos + " took: " + buildMs);
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
@@ -314,32 +333,4 @@ public class ColumnRenderBufferBuilder
|
|||||||
quadBuilder.finalizeData();
|
quadBuilder.finalizeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=================//
|
|
||||||
// vbo interaction //
|
|
||||||
//=================//
|
|
||||||
|
|
||||||
public static GLVertexBuffer[] resizeBuffer(GLVertexBuffer[] vbos, int newSize)
|
|
||||||
{
|
|
||||||
if (vbos.length == newSize)
|
|
||||||
{
|
|
||||||
return vbos;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLVertexBuffer[] newVbos = new GLVertexBuffer[newSize];
|
|
||||||
System.arraycopy(vbos, 0, newVbos, 0, Math.min(vbos.length, newSize));
|
|
||||||
if (newSize < vbos.length)
|
|
||||||
{
|
|
||||||
for (int i = newSize; i < vbos.length; i++)
|
|
||||||
{
|
|
||||||
if (vbos[i] != null)
|
|
||||||
{
|
|
||||||
vbos[i].close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return newVbos;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+53
-20
@@ -97,28 +97,61 @@ public class CubicLodTemplate
|
|||||||
case SHOW_BLOCK_MATERIAL:
|
case SHOW_BLOCK_MATERIAL:
|
||||||
{
|
{
|
||||||
|
|
||||||
color = switch (EDhApiBlockMaterial.getFromIndex(blockMaterialId))
|
switch (EDhApiBlockMaterial.getFromIndex(blockMaterialId))
|
||||||
{
|
{
|
||||||
case UNKNOWN, AIR -> // shouldn't normally be rendered, but just in case
|
case UNKNOWN:
|
||||||
ColorUtil.HOT_PINK;
|
case AIR: // shouldn't normally be rendered, but just in case
|
||||||
case LEAVES -> ColorUtil.DARK_GREEN;
|
color = ColorUtil.HOT_PINK;
|
||||||
case STONE -> ColorUtil.GRAY;
|
break;
|
||||||
case WOOD -> ColorUtil.BROWN;
|
|
||||||
case METAL -> ColorUtil.DARK_GRAY;
|
case LEAVES:
|
||||||
case DIRT -> ColorUtil.LIGHT_BROWN;
|
color = ColorUtil.DARK_GREEN;
|
||||||
case LAVA -> ColorUtil.ORANGE;
|
break;
|
||||||
case DEEPSLATE -> ColorUtil.BLACK;
|
case STONE:
|
||||||
case SNOW -> ColorUtil.WHITE;
|
color = ColorUtil.GRAY;
|
||||||
case SAND -> ColorUtil.TAN;
|
break;
|
||||||
case TERRACOTTA -> ColorUtil.DARK_ORANGE;
|
case WOOD:
|
||||||
case NETHER_STONE -> ColorUtil.DARK_RED;
|
color = ColorUtil.BROWN;
|
||||||
case WATER -> ColorUtil.BLUE;
|
break;
|
||||||
case GRASS -> ColorUtil.GREEN;
|
case METAL:
|
||||||
case ILLUMINATED -> ColorUtil.YELLOW;
|
color = ColorUtil.DARK_GRAY;
|
||||||
default ->
|
break;
|
||||||
|
case DIRT:
|
||||||
|
color = ColorUtil.LIGHT_BROWN;
|
||||||
|
break;
|
||||||
|
case LAVA:
|
||||||
|
color = ColorUtil.ORANGE;
|
||||||
|
break;
|
||||||
|
case DEEPSLATE:
|
||||||
|
color = ColorUtil.BLACK;
|
||||||
|
break;
|
||||||
|
case SNOW:
|
||||||
|
color = ColorUtil.WHITE;
|
||||||
|
break;
|
||||||
|
case SAND:
|
||||||
|
color = ColorUtil.TAN;
|
||||||
|
break;
|
||||||
|
case TERRACOTTA:
|
||||||
|
color = ColorUtil.DARK_ORANGE;
|
||||||
|
break;
|
||||||
|
case NETHER_STONE:
|
||||||
|
color = ColorUtil.DARK_RED;
|
||||||
|
break;
|
||||||
|
case WATER:
|
||||||
|
color = ColorUtil.BLUE;
|
||||||
|
break;
|
||||||
|
case GRASS:
|
||||||
|
color = ColorUtil.GREEN;
|
||||||
|
break;
|
||||||
|
case ILLUMINATED:
|
||||||
|
color = ColorUtil.YELLOW;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
// undefined color
|
// undefined color
|
||||||
ColorUtil.CYAN;
|
color = ColorUtil.CYAN;
|
||||||
};
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
fullBright = true;
|
fullBright = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
+11
-13
@@ -51,9 +51,7 @@ public class LodQuadBuilder
|
|||||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||||
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
|
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public final boolean skipQuadsWithZeroSkylight;
|
public final boolean skipQuadsWithZeroSkylight;
|
||||||
@Deprecated
|
|
||||||
public final short skyLightCullingBelow;
|
public final short skyLightCullingBelow;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -125,7 +123,7 @@ public class LodQuadBuilder
|
|||||||
// constructor //
|
// constructor //
|
||||||
//=============//
|
//=============//
|
||||||
|
|
||||||
public LodQuadBuilder(boolean doTransparency, IClientLevelWrapper clientLevelWrapper)
|
public LodQuadBuilder(boolean enableSkylightCulling, short skyLightCullingBelow, boolean doTransparency, IClientLevelWrapper clientLevelWrapper)
|
||||||
{
|
{
|
||||||
this.doTransparency = doTransparency;
|
this.doTransparency = doTransparency;
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
@@ -134,8 +132,8 @@ public class LodQuadBuilder
|
|||||||
this.transparentQuads[i] = new ArrayList<>();
|
this.transparentQuads[i] = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.skipQuadsWithZeroSkylight = false;
|
this.skipQuadsWithZeroSkylight = enableSkylightCulling;
|
||||||
this.skyLightCullingBelow = 0;
|
this.skyLightCullingBelow = skyLightCullingBelow;
|
||||||
this.clientLevelWrapper = clientLevelWrapper;
|
this.clientLevelWrapper = clientLevelWrapper;
|
||||||
|
|
||||||
this.debugRenderingMode = Config.Client.Advanced.Debugging.debugRendering.get();
|
this.debugRenderingMode = Config.Client.Advanced.Debugging.debugRendering.get();
|
||||||
@@ -168,8 +166,8 @@ public class LodQuadBuilder
|
|||||||
ArrayList<BufferQuad> quadList = (this.doTransparency && ColorUtil.getAlpha(color) < 255) ? this.transparentQuads[dir.ordinal()] : this.opaqueQuads[dir.ordinal()];
|
ArrayList<BufferQuad> quadList = (this.doTransparency && ColorUtil.getAlpha(color) < 255) ? this.transparentQuads[dir.ordinal()] : this.opaqueQuads[dir.ordinal()];
|
||||||
if (!quadList.isEmpty() &&
|
if (!quadList.isEmpty() &&
|
||||||
(
|
(
|
||||||
quadList.getLast().tryMerge(quad, BufferMergeDirectionEnum.EastWest)
|
quadList.get(quadList.size() - 1).tryMerge(quad, BufferMergeDirectionEnum.EastWest)
|
||||||
|| quadList.getLast().tryMerge(quad, BufferMergeDirectionEnum.NorthSouthOrUpDown))
|
|| quadList.get(quadList.size() - 1).tryMerge(quad, BufferMergeDirectionEnum.NorthSouthOrUpDown))
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.premergeCount++;
|
this.premergeCount++;
|
||||||
@@ -196,8 +194,8 @@ public class LodQuadBuilder
|
|||||||
// attempt to merge this quad with adjacent ones
|
// attempt to merge this quad with adjacent ones
|
||||||
if (!quadList.isEmpty() &&
|
if (!quadList.isEmpty() &&
|
||||||
(
|
(
|
||||||
quadList.getLast().tryMerge(quad, BufferMergeDirectionEnum.EastWest)
|
quadList.get(quadList.size() - 1).tryMerge(quad, BufferMergeDirectionEnum.EastWest)
|
||||||
|| quadList.getLast().tryMerge(quad, BufferMergeDirectionEnum.NorthSouthOrUpDown))
|
|| quadList.get(quadList.size() - 1).tryMerge(quad, BufferMergeDirectionEnum.NorthSouthOrUpDown))
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.premergeCount++;
|
this.premergeCount++;
|
||||||
@@ -215,8 +213,8 @@ public class LodQuadBuilder
|
|||||||
ArrayList<BufferQuad> qs = (doTransparency && ColorUtil.getAlpha(color) < 255)
|
ArrayList<BufferQuad> qs = (doTransparency && ColorUtil.getAlpha(color) < 255)
|
||||||
? transparentQuads[EDhDirection.DOWN.ordinal()] : opaqueQuads[EDhDirection.DOWN.ordinal()];
|
? transparentQuads[EDhDirection.DOWN.ordinal()] : opaqueQuads[EDhDirection.DOWN.ordinal()];
|
||||||
if (!qs.isEmpty() &&
|
if (!qs.isEmpty() &&
|
||||||
(qs.getLast().tryMerge(quad, BufferMergeDirectionEnum.EastWest)
|
(qs.get(qs.size() - 1).tryMerge(quad, BufferMergeDirectionEnum.EastWest)
|
||||||
|| qs.getLast().tryMerge(quad, BufferMergeDirectionEnum.NorthSouthOrUpDown))
|
|| qs.get(qs.size() - 1).tryMerge(quad, BufferMergeDirectionEnum.NorthSouthOrUpDown))
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
premergeCount++;
|
premergeCount++;
|
||||||
@@ -434,7 +432,7 @@ public class LodQuadBuilder
|
|||||||
|
|
||||||
public Iterator<ByteBuffer> makeOpaqueVertexBuffers()
|
public Iterator<ByteBuffer> makeOpaqueVertexBuffers()
|
||||||
{
|
{
|
||||||
return new Iterator<>()
|
return new Iterator<ByteBuffer>()
|
||||||
{
|
{
|
||||||
final ByteBuffer bb = ByteBuffer.allocateDirect(ColumnRenderBuffer.FULL_SIZED_BUFFER)
|
final ByteBuffer bb = ByteBuffer.allocateDirect(ColumnRenderBuffer.FULL_SIZED_BUFFER)
|
||||||
.order(ByteOrder.nativeOrder());
|
.order(ByteOrder.nativeOrder());
|
||||||
@@ -502,7 +500,7 @@ public class LodQuadBuilder
|
|||||||
|
|
||||||
public Iterator<ByteBuffer> makeTransparentVertexBuffers()
|
public Iterator<ByteBuffer> makeTransparentVertexBuffers()
|
||||||
{
|
{
|
||||||
return new Iterator<>()
|
return new Iterator<ByteBuffer>()
|
||||||
{
|
{
|
||||||
final ByteBuffer bb = ByteBuffer.allocateDirect(ColumnRenderBuffer.FULL_SIZED_BUFFER)
|
final ByteBuffer bb = ByteBuffer.allocateDirect(ColumnRenderBuffer.FULL_SIZED_BUFFER)
|
||||||
.order(ByteOrder.nativeOrder());
|
.order(ByteOrder.nativeOrder());
|
||||||
|
|||||||
+188
@@ -0,0 +1,188 @@
|
|||||||
|
package com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
|
import com.seibel.distanthorizons.core.logging.f3.F3Screen;
|
||||||
|
import com.seibel.distanthorizons.core.render.glObject.GLProxy;
|
||||||
|
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||||
|
import com.seibel.distanthorizons.coreapi.util.StringUtil;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.lwjgl.opengl.GL32;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.ArrayDeque;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
/** Used to allow multiple {@link ColumnRenderBuffer}'s to be put in a single VBO. */
|
||||||
|
public class SharedVbo
|
||||||
|
{
|
||||||
|
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||||
|
|
||||||
|
public static final SharedVbo OPAQUE = new SharedVbo(2_000_000_000L/*1GB*/, 1024 * 1024/*1MB*/);
|
||||||
|
public static final SharedVbo TRANSPARENT = new SharedVbo(2_000_000_000L/*1GB*/, 1024 * 1024/*1MB*/);
|
||||||
|
|
||||||
|
|
||||||
|
public final int vboId;
|
||||||
|
|
||||||
|
|
||||||
|
private final long bufferTotalByteSize;
|
||||||
|
/** the length of a single chunk of this VBO in bytes. */
|
||||||
|
private final int chunkByteSize;
|
||||||
|
|
||||||
|
private final ConcurrentHashMap<Long, BufferSlice> bufferSliceByStartingIndex = new ConcurrentHashMap<>();
|
||||||
|
private long nextMemoryAddress = 0L;
|
||||||
|
private final Queue<BufferSlice> availableSlices = new ArrayDeque<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=============//
|
||||||
|
// constructor //
|
||||||
|
//=============//
|
||||||
|
|
||||||
|
public SharedVbo(long totalSize, int chunkByteSize)
|
||||||
|
{
|
||||||
|
LodUtil.assertTrue(GLProxy.getInstance().runningOnRenderThread(), "Buffer Handler has to be created on the render thread.");
|
||||||
|
|
||||||
|
this.bufferTotalByteSize = totalSize;
|
||||||
|
this.chunkByteSize = chunkByteSize;
|
||||||
|
|
||||||
|
// Generate and bind the VBO
|
||||||
|
this.vboId = GL32.glGenBuffers();
|
||||||
|
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, this.vboId);
|
||||||
|
GL32.glBufferData(GL32.GL_ARRAY_BUFFER, this.bufferTotalByteSize, GL32.GL_DYNAMIC_DRAW);
|
||||||
|
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//============//
|
||||||
|
// allocation //
|
||||||
|
//============//
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public SharedVbo.BufferSlice allocateSlice()
|
||||||
|
{
|
||||||
|
BufferSlice availableSlice = this.availableSlices.poll();
|
||||||
|
if (availableSlice != null)
|
||||||
|
{
|
||||||
|
return availableSlice;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the first free chunk
|
||||||
|
for (long startingIndex = this.nextMemoryAddress; startingIndex < this.bufferTotalByteSize; startingIndex += this.chunkByteSize)
|
||||||
|
{
|
||||||
|
// check if this section is free
|
||||||
|
BufferSlice newSlice = new BufferSlice(startingIndex, this.chunkByteSize);
|
||||||
|
if (this.bufferSliceByStartingIndex.putIfAbsent(startingIndex, newSlice) == null)
|
||||||
|
{
|
||||||
|
this.nextMemoryAddress = startingIndex;
|
||||||
|
return newSlice;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null; // No free chunk found
|
||||||
|
}
|
||||||
|
public void deallocate(BufferSlice[] slices)
|
||||||
|
{
|
||||||
|
if (slices != null)
|
||||||
|
{
|
||||||
|
for (BufferSlice slice : slices)
|
||||||
|
{
|
||||||
|
if (slice != null)
|
||||||
|
{
|
||||||
|
this.bufferSliceByStartingIndex.remove(slice.startIndex);
|
||||||
|
this.availableSlices.add(slice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void deallocate(BufferSlice slice)
|
||||||
|
{
|
||||||
|
if (slice != null)
|
||||||
|
{
|
||||||
|
this.bufferSliceByStartingIndex.remove(slice.startIndex);
|
||||||
|
this.availableSlices.add(slice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void clear()
|
||||||
|
{
|
||||||
|
this.bufferSliceByStartingIndex.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=================//
|
||||||
|
// buffer handling //
|
||||||
|
//=================//
|
||||||
|
|
||||||
|
public void updateBuffer(BufferSlice chunk, ByteBuffer buffer)
|
||||||
|
{
|
||||||
|
int size = buffer.limit() - buffer.position();
|
||||||
|
if (size > chunk.length)
|
||||||
|
{
|
||||||
|
// if this was fired that means we didn't split up the buffer into the right size
|
||||||
|
// if this isn't stopped the buffer will overwrite an adjacent section and cause incorrect rendering
|
||||||
|
throw new RuntimeException("Programmer error: Uploaded buffer bigger than the allocated area. Allocated: ["+chunk.length+"], buffer: ["+size+"]");
|
||||||
|
}
|
||||||
|
|
||||||
|
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, this.vboId);
|
||||||
|
GL32.glBufferSubData(GL32.GL_ARRAY_BUFFER, chunk.startIndex, buffer);
|
||||||
|
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, 0);
|
||||||
|
chunk.vertexCount = size / LodUtil.LOD_VERTEX_FORMAT.getByteSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void bind() { GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, this.vboId); }
|
||||||
|
public void unbind() { GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, 0); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=======//
|
||||||
|
// debug //
|
||||||
|
//=======//
|
||||||
|
|
||||||
|
public String getDebugMenuString()
|
||||||
|
{
|
||||||
|
long maxChunkCount = (this.bufferTotalByteSize / this.chunkByteSize);
|
||||||
|
long chunkCount = 0;
|
||||||
|
long allocatedBytes = 0;
|
||||||
|
|
||||||
|
for (BufferSlice slice : this.bufferSliceByStartingIndex.values())
|
||||||
|
{
|
||||||
|
allocatedBytes += slice.length;
|
||||||
|
chunkCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Slices: ["+F3Screen.NUMBER_FORMAT.format(chunkCount)+"/"+F3Screen.NUMBER_FORMAT.format(maxChunkCount)+"], " +
|
||||||
|
"Mem: ["+StringUtil.convertByteCountToHumanReadableSI(allocatedBytes)+"/"+StringUtil.convertByteCountToHumanReadableSI(this.bufferTotalByteSize)+"]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//================//
|
||||||
|
// helper classes //
|
||||||
|
//================//
|
||||||
|
|
||||||
|
/** represents a single allocated slice of the parent VBO */
|
||||||
|
public static class BufferSlice
|
||||||
|
{
|
||||||
|
public final long startIndex;
|
||||||
|
public final int length;
|
||||||
|
|
||||||
|
public int vertexCount;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=============//
|
||||||
|
// constructor //
|
||||||
|
//=============//
|
||||||
|
|
||||||
|
public BufferSlice(long startIndex, int length)
|
||||||
|
{
|
||||||
|
this.startIndex = startIndex;
|
||||||
|
this.length = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+1
-1
@@ -199,7 +199,7 @@ public final class ColumnArrayView implements IColumnDataView
|
|||||||
for (int i = offset; i < end; i++)
|
for (int i = offset; i < end; i++)
|
||||||
{
|
{
|
||||||
long element = a.getLong(i);
|
long element = a.getLong(i);
|
||||||
int elementHash = Long.hashCode(element);
|
int elementHash = (int) (element ^ (element >>> 32));
|
||||||
result = 31 * result + elementHash;
|
result = 31 * result + elementHash;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
+93
-130
@@ -20,7 +20,6 @@
|
|||||||
package com.seibel.distanthorizons.core.dataObjects.transformers;
|
package com.seibel.distanthorizons.core.dataObjects.transformers;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiBlocksToAvoid;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiBlocksToAvoid;
|
||||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiBlockMaterial;
|
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap;
|
import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap;
|
||||||
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
|
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
|
||||||
@@ -111,85 +110,74 @@ public class FullDataToRenderDataTransformer
|
|||||||
}
|
}
|
||||||
|
|
||||||
columnSource.markNotEmpty();
|
columnSource.markNotEmpty();
|
||||||
int baseX = DhSectionPos.getMinCornerBlockX(pos);
|
|
||||||
int baseZ = DhSectionPos.getMinCornerBlockZ(pos);
|
|
||||||
|
|
||||||
for (int x = 0; x < DhSectionPos.getWidthCountForLowerDetailedSection(pos, dataDetail); x++)
|
if (dataDetail == columnSource.getDataDetailLevel())
|
||||||
{
|
{
|
||||||
for (int z = 0; z < DhSectionPos.getWidthCountForLowerDetailedSection(pos, dataDetail); z++)
|
int baseX = DhSectionPos.getMinCornerBlockX(pos);
|
||||||
{
|
int baseZ = DhSectionPos.getMinCornerBlockZ(pos);
|
||||||
throwIfThreadInterrupted();
|
|
||||||
|
for (int x = 0; x < DhSectionPos.getWidthCountForLowerDetailedSection(pos, dataDetail); x++)
|
||||||
ColumnArrayView columnArrayView = columnSource.getVerticalDataPointView(x, z);
|
{
|
||||||
LongArrayList dataColumn = fullDataSource.get(x, z);
|
for (int z = 0; z < DhSectionPos.getWidthCountForLowerDetailedSection(pos, dataDetail); z++)
|
||||||
updateRenderDataViewWithFullDataColumn(level, fullDataSource.mapping, baseX + x, baseZ + z, columnArrayView, dataColumn);
|
{
|
||||||
}
|
throwIfThreadInterrupted();
|
||||||
}
|
|
||||||
|
ColumnArrayView columnArrayView = columnSource.getVerticalDataPointView(x, z);
|
||||||
columnSource.fillDebugFlag(0, 0, ColumnRenderSource.SECTION_SIZE, ColumnRenderSource.SECTION_SIZE, ColumnRenderSource.DebugSourceFlag.FULL);
|
LongArrayList dataColumn = fullDataSource.get(x, z);
|
||||||
|
convertColumnData(level, fullDataSource.mapping, baseX + x, baseZ + z, columnArrayView, dataColumn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
columnSource.fillDebugFlag(0, 0, ColumnRenderSource.SECTION_SIZE, ColumnRenderSource.SECTION_SIZE, ColumnRenderSource.DebugSourceFlag.FULL);
|
||||||
|
|
||||||
return columnSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Updates the given {@link ColumnArrayView} to match the incoming Full data {@link LongArrayList} */
|
|
||||||
public static void updateRenderDataViewWithFullDataColumn(
|
|
||||||
IDhClientLevel level,
|
|
||||||
FullDataPointIdMap fullDataMapping, int blockX, int blockZ,
|
|
||||||
ColumnArrayView columnArrayView,
|
|
||||||
LongArrayList fullDataColumn)
|
|
||||||
{
|
|
||||||
if (fullDataColumn == null || fullDataColumn.size() == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int dataTotalLength = fullDataColumn.size();
|
|
||||||
if (dataTotalLength > columnArrayView.verticalSize())
|
|
||||||
{
|
|
||||||
ColumnArrayView totalColumnData = new ColumnArrayView(new LongArrayList(new long[dataTotalLength]), dataTotalLength, 0, dataTotalLength);
|
|
||||||
iterateAndConvert(level, fullDataMapping, blockX, blockZ, totalColumnData, fullDataColumn);
|
|
||||||
columnArrayView.changeVerticalSizeFrom(totalColumnData);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iterateAndConvert(level, fullDataMapping, blockX, blockZ, columnArrayView, fullDataColumn); //Directly use the arrayView since it fits.
|
throw new UnsupportedOperationException("To be implemented");
|
||||||
|
//FIXME: Implement different size creation of renderData
|
||||||
|
}
|
||||||
|
return columnSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//================//
|
||||||
|
// helper methods //
|
||||||
|
//================//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called in loops that may run for an extended period of time. <br>
|
||||||
|
* This is necessary to allow canceling these transformers since running
|
||||||
|
* them after the client has left a given world will throw exceptions.
|
||||||
|
*/
|
||||||
|
private static void throwIfThreadInterrupted() throws InterruptedException
|
||||||
|
{
|
||||||
|
if (Thread.interrupted())
|
||||||
|
{
|
||||||
|
throw new InterruptedException(FullDataToRenderDataTransformer.class.getSimpleName() + " task interrupted.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO what does this mean?
|
||||||
private static void iterateAndConvert(
|
private static void iterateAndConvert(
|
||||||
IDhClientLevel level, FullDataPointIdMap fullDataMapping,
|
IDhClientLevel level, FullDataPointIdMap fullDataMapping,
|
||||||
int blockX, int blockZ,
|
int blockX, int blockZ,
|
||||||
ColumnArrayView renderColumnData, LongArrayList fullColumnData)
|
ColumnArrayView renderColumnData, LongArrayList fullColumnData)
|
||||||
{
|
{
|
||||||
boolean ignoreNonCollidingBlocks = (Config.Client.Advanced.Graphics.Quality.blocksToIgnore.get() == EDhApiBlocksToAvoid.NON_COLLIDING);
|
boolean avoidSolidBlocks = (Config.Client.Advanced.Graphics.Quality.blocksToIgnore.get() == EDhApiBlocksToAvoid.NON_COLLIDING);
|
||||||
boolean colorBelowWithAvoidedBlocks = Config.Client.Advanced.Graphics.Quality.tintWithAvoidedBlocks.get();
|
boolean colorBelowWithAvoidedBlocks = Config.Client.Advanced.Graphics.Quality.tintWithAvoidedBlocks.get();
|
||||||
|
|
||||||
HashSet<IBlockStateWrapper> blockStatesToIgnore = WRAPPER_FACTORY.getRendererIgnoredBlocks(level.getLevelWrapper());
|
HashSet<IBlockStateWrapper> blockStatesToIgnore = WRAPPER_FACTORY.getRendererIgnoredBlocks(level.getLevelWrapper());
|
||||||
HashSet<IBlockStateWrapper> caveBlockStatesToIgnore = WRAPPER_FACTORY.getRendererIgnoredCaveBlocks(level.getLevelWrapper());
|
|
||||||
|
|
||||||
boolean caveCullingEnabled =
|
|
||||||
Config.Client.Advanced.Graphics.AdvancedGraphics.enableCaveCulling.get()
|
|
||||||
&& (
|
|
||||||
// dimensions with a ceiling will be all caves so we don't want cave culling
|
|
||||||
!level.getLevelWrapper().hasCeiling()
|
|
||||||
// the end has a lot of overhangs with 0 lighting above the void, which look broken with
|
|
||||||
// the current cave culling logic (this could probably be improved, but just skipping it works best for now)
|
|
||||||
&& !level.getLevelWrapper().getDimensionType().isTheEnd()
|
|
||||||
);
|
|
||||||
|
|
||||||
boolean isVoid = true;
|
boolean isVoid = true;
|
||||||
|
|
||||||
int colorToApplyToNextBlock = -1;
|
int colorToApplyToNextBlock = -1;
|
||||||
int lastColor = 0;
|
int lastColor = 0;
|
||||||
int lastBottom = -10000;
|
int lastBottom = -10000;
|
||||||
|
|
||||||
int skylightToApplyToNextBlock = -1;
|
int skylightToApplyToNextBlock = -1;
|
||||||
int blocklightToApplyToNextBlock = -1;
|
int blocklightToApplyToNextBlock = -1;
|
||||||
int columnOffset = 0;
|
int columnOffset = 0;
|
||||||
|
|
||||||
IBiomeWrapper biome = null;
|
|
||||||
IBlockStateWrapper block = null;
|
|
||||||
|
|
||||||
|
|
||||||
// goes from the top down
|
// goes from the top down
|
||||||
for (int i = 0; i < fullColumnData.size(); i++)
|
for (int i = 0; i < fullColumnData.size(); i++)
|
||||||
{
|
{
|
||||||
@@ -200,6 +188,23 @@ public class FullDataToRenderDataTransformer
|
|||||||
int blockLight = FullDataPointUtil.getBlockLight(fullData);
|
int blockLight = FullDataPointUtil.getBlockLight(fullData);
|
||||||
int skyLight = FullDataPointUtil.getSkyLight(fullData);
|
int skyLight = FullDataPointUtil.getSkyLight(fullData);
|
||||||
|
|
||||||
|
// TODO how should corrupted data be handled?
|
||||||
|
// TODO why is the full data corrupted in the first place? FullDataPointUtil hasn't been changed in a long time, could one of the full data point objects be corrupted?
|
||||||
|
// TODO if either of these happen the ID might also be invalid
|
||||||
|
//if (bottomY + blockHeight > 300)
|
||||||
|
//{
|
||||||
|
// // this data point is too tall, it's probably a monolith
|
||||||
|
// int k = 0;
|
||||||
|
// throw new RuntimeException();
|
||||||
|
//}
|
||||||
|
//if (light > 16 || light < 0)
|
||||||
|
//{
|
||||||
|
// // light is out of range
|
||||||
|
// throw new RuntimeException();
|
||||||
|
//}
|
||||||
|
|
||||||
|
IBiomeWrapper biome;
|
||||||
|
IBlockStateWrapper block;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
biome = fullDataMapping.getBiomeWrapper(id);
|
biome = fullDataMapping.getBiomeWrapper(id);
|
||||||
@@ -224,72 +229,28 @@ public class FullDataToRenderDataTransformer
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//====================//
|
if (blockStatesToIgnore.contains(block))
|
||||||
// ignored block and //
|
|
||||||
// cave culling check //
|
|
||||||
//====================//
|
|
||||||
|
|
||||||
boolean ignoreBlock = blockStatesToIgnore.contains(block);
|
|
||||||
boolean caveBlock = caveBlockStatesToIgnore.contains(block);
|
|
||||||
if (caveBlock)
|
|
||||||
{
|
{
|
||||||
if (caveCullingEnabled
|
// Don't render: air, barriers, light blocks, etc.
|
||||||
// assume this data point is underground if it has no sky-light
|
|
||||||
&& skyLight == LodUtil.MIN_MC_LIGHT
|
|
||||||
// cave culling shouldn't happen when at the top of the world
|
|
||||||
&& columnOffset != 0
|
|
||||||
// cave culling can't happen when at the bottom of the world
|
|
||||||
&& columnOffset != fullColumnData.size())
|
|
||||||
{
|
|
||||||
// we need to get the next sky/block lights because
|
|
||||||
// the air block here will always have a light of 0/0 due to only the top of the LOD's light being saved.
|
|
||||||
long nextFullData = fullColumnData.getLong(i+1);
|
|
||||||
int nextSkyLight = FullDataPointUtil.getSkyLight(nextFullData);
|
|
||||||
|
|
||||||
if (nextSkyLight == LodUtil.MIN_MC_LIGHT
|
|
||||||
&& ColorUtil.getAlpha(lastColor) == 255)
|
|
||||||
{
|
|
||||||
// replace the previous block with new bottom
|
|
||||||
long columnData = renderColumnData.get(columnOffset - 1);
|
|
||||||
columnData = RenderDataPointUtil.setYMin(columnData, bottomY);
|
|
||||||
renderColumnData.set(columnOffset - 1, columnData);
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (ignoreBlock)
|
|
||||||
{
|
|
||||||
// this is a merged block and a cave block, so it should never be rendered
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (ignoreBlock)
|
|
||||||
{
|
|
||||||
// this is an ignored block, but shouldn't be merged like a cave block
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//===================//
|
// solid block check
|
||||||
// solid block check //
|
if (avoidSolidBlocks && !block.isSolid() && !block.isLiquid() && block.getOpacity() != LodUtil.BLOCK_FULLY_OPAQUE)
|
||||||
//===================//
|
|
||||||
|
|
||||||
if (ignoreNonCollidingBlocks && !block.isSolid() && !block.isLiquid() && block.getOpacity() != LodUtil.BLOCK_FULLY_OPAQUE)
|
|
||||||
{
|
{
|
||||||
if (colorBelowWithAvoidedBlocks)
|
if (colorBelowWithAvoidedBlocks)
|
||||||
{
|
{
|
||||||
int tempColor = level.computeBaseColor(new DhBlockPos(blockX, bottomY + level.getMinY(), blockZ), biome, block);
|
int tempColor = level.computeBaseColor(new DhBlockPos(blockX, bottomY + level.getMinY(), blockZ), biome, block);
|
||||||
// don't transfer the color when alpha is 0
|
if (ColorUtil.getAlpha(tempColor) == 0)
|
||||||
if (ColorUtil.getAlpha(tempColor) != 0)
|
|
||||||
{
|
{
|
||||||
// don't transfer alpha if for some reason grass is semi transparent
|
//make sure to not transfer the color when alpha is 0
|
||||||
colorToApplyToNextBlock = ColorUtil.setAlpha(tempColor,255);
|
continue;
|
||||||
|
|
||||||
skylightToApplyToNextBlock = skyLight;
|
|
||||||
blocklightToApplyToNextBlock = blockLight;
|
|
||||||
}
|
}
|
||||||
|
//mare sure to not trnasfer alpha if for some reason grass is semi transparent
|
||||||
|
colorToApplyToNextBlock = ColorUtil.setAlpha(tempColor,255);
|
||||||
|
skylightToApplyToNextBlock = skyLight;
|
||||||
|
blocklightToApplyToNextBlock = blockLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't add this block
|
// don't add this block
|
||||||
@@ -311,11 +272,11 @@ public class FullDataToRenderDataTransformer
|
|||||||
skyLight = skylightToApplyToNextBlock;
|
skyLight = skylightToApplyToNextBlock;
|
||||||
blockLight = blocklightToApplyToNextBlock;
|
blockLight = blocklightToApplyToNextBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if they share a top-bottom face and if they have same color
|
//check if they share a top-bottom face and if they have same collor
|
||||||
if (color == lastColor && bottomY + blockHeight == lastBottom && columnOffset > 0)
|
if (color == lastColor && bottomY + blockHeight == lastBottom && columnOffset > 0)
|
||||||
{
|
{
|
||||||
//replace the previous block with new bottom
|
//replace the previus block with new bottom
|
||||||
long columnData = renderColumnData.get(columnOffset - 1);
|
long columnData = renderColumnData.get(columnOffset - 1);
|
||||||
columnData = RenderDataPointUtil.setYMin(columnData, bottomY);
|
columnData = RenderDataPointUtil.setYMin(columnData, bottomY);
|
||||||
renderColumnData.set(columnOffset - 1, columnData);
|
renderColumnData.set(columnOffset - 1, columnData);
|
||||||
@@ -330,7 +291,7 @@ public class FullDataToRenderDataTransformer
|
|||||||
}
|
}
|
||||||
lastBottom = bottomY;
|
lastBottom = bottomY;
|
||||||
lastColor = color;
|
lastColor = color;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -340,22 +301,24 @@ public class FullDataToRenderDataTransformer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO what does this mean?
|
||||||
|
public static void convertColumnData(IDhClientLevel level, FullDataPointIdMap fullDataMapping, int blockX, int blockZ, ColumnArrayView columnArrayView, LongArrayList fullDataColumn)
|
||||||
//================//
|
|
||||||
// helper methods //
|
|
||||||
//================//
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called in loops that may run for an extended period of time. <br>
|
|
||||||
* This is necessary to allow canceling these transformers since running
|
|
||||||
* them after the client has left a given world will throw exceptions.
|
|
||||||
*/
|
|
||||||
private static void throwIfThreadInterrupted() throws InterruptedException
|
|
||||||
{
|
{
|
||||||
if (Thread.interrupted())
|
if (fullDataColumn == null || fullDataColumn.size() == 0)
|
||||||
{
|
{
|
||||||
throw new InterruptedException(FullDataToRenderDataTransformer.class.getSimpleName() + " task interrupted.");
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int dataTotalLength = fullDataColumn.size();
|
||||||
|
if (dataTotalLength > columnArrayView.verticalSize())
|
||||||
|
{
|
||||||
|
ColumnArrayView totalColumnData = new ColumnArrayView(new LongArrayList(new long[dataTotalLength]), dataTotalLength, 0, dataTotalLength);
|
||||||
|
iterateAndConvert(level, fullDataMapping, blockX, blockZ, totalColumnData, fullDataColumn);
|
||||||
|
columnArrayView.changeVerticalSizeFrom(totalColumnData);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iterateAndConvert(level, fullDataMapping, blockX, blockZ, columnArrayView, fullDataColumn); //Directly use the arrayView since it fits.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+25
-39
@@ -31,6 +31,7 @@ import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
|||||||
import com.seibel.distanthorizons.core.enums.EDhDirection;
|
import com.seibel.distanthorizons.core.enums.EDhDirection;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.pos.DhBlockPos;
|
import com.seibel.distanthorizons.core.pos.DhBlockPos;
|
||||||
|
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||||
import com.seibel.distanthorizons.core.pos.DhSectionPos;
|
import com.seibel.distanthorizons.core.pos.DhSectionPos;
|
||||||
import com.seibel.distanthorizons.core.util.FullDataPointUtil;
|
import com.seibel.distanthorizons.core.util.FullDataPointUtil;
|
||||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||||
@@ -46,6 +47,8 @@ public class LodDataBuilder
|
|||||||
{
|
{
|
||||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||||
private static final IBlockStateWrapper AIR = SingletonInjector.INSTANCE.get(IWrapperFactory.class).getAirBlockStateWrapper();
|
private static final IBlockStateWrapper AIR = SingletonInjector.INSTANCE.get(IWrapperFactory.class).getAirBlockStateWrapper();
|
||||||
|
/** how many chunks wide the {@link FullDataSourceV2} is. */
|
||||||
|
private static final int NUMB_OF_CHUNKS_WIDE = FullDataSourceV2.WIDTH / LodUtil.CHUNK_WIDTH;
|
||||||
|
|
||||||
private static boolean getTopErrorLogged = false;
|
private static boolean getTopErrorLogged = false;
|
||||||
|
|
||||||
@@ -64,8 +67,12 @@ public class LodDataBuilder
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int sectionPosX = getXOrZSectionPosFromChunkPos(chunkWrapper.getChunkPos().x);
|
// get the section position
|
||||||
int sectionPosZ = getXOrZSectionPosFromChunkPos(chunkWrapper.getChunkPos().z);
|
int sectionPosX = chunkWrapper.getChunkPos().x;
|
||||||
|
// negative positions start at -1 so the logic there is slightly different
|
||||||
|
sectionPosX = (sectionPosX < 0) ? ((sectionPosX + 1) / NUMB_OF_CHUNKS_WIDE) - 1 : (sectionPosX / NUMB_OF_CHUNKS_WIDE);
|
||||||
|
int sectionPosZ = chunkWrapper.getChunkPos().z;
|
||||||
|
sectionPosZ = (sectionPosZ < 0) ? ((sectionPosZ + 1) / NUMB_OF_CHUNKS_WIDE) - 1 : (sectionPosZ / NUMB_OF_CHUNKS_WIDE);
|
||||||
long pos = DhSectionPos.encode(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, sectionPosX, sectionPosZ);
|
long pos = DhSectionPos.encode(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, sectionPosX, sectionPosZ);
|
||||||
|
|
||||||
FullDataSourceV2 dataSource = FullDataSourceV2.createEmpty(pos);
|
FullDataSourceV2 dataSource = FullDataSourceV2.createEmpty(pos);
|
||||||
@@ -91,30 +98,30 @@ public class LodDataBuilder
|
|||||||
// -3 -> 1
|
// -3 -> 1
|
||||||
// -4 -> 0 ---
|
// -4 -> 0 ---
|
||||||
// -5 -> 3
|
// -5 -> 3
|
||||||
chunkOffsetX = ((chunkOffsetX) % FullDataSourceV2.NUMB_OF_CHUNKS_WIDE);
|
chunkOffsetX = ((chunkOffsetX) % NUMB_OF_CHUNKS_WIDE);
|
||||||
if (chunkOffsetX != 0)
|
if (chunkOffsetX != 0)
|
||||||
{
|
{
|
||||||
chunkOffsetX += FullDataSourceV2.NUMB_OF_CHUNKS_WIDE;
|
chunkOffsetX += NUMB_OF_CHUNKS_WIDE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
chunkOffsetX %= FullDataSourceV2.NUMB_OF_CHUNKS_WIDE;
|
chunkOffsetX %= NUMB_OF_CHUNKS_WIDE;
|
||||||
}
|
}
|
||||||
chunkOffsetX *= LodUtil.CHUNK_WIDTH;
|
chunkOffsetX *= LodUtil.CHUNK_WIDTH;
|
||||||
|
|
||||||
int chunkOffsetZ = chunkWrapper.getChunkPos().z;
|
int chunkOffsetZ = chunkWrapper.getChunkPos().z;
|
||||||
if (chunkWrapper.getChunkPos().z < 0)
|
if (chunkWrapper.getChunkPos().z < 0)
|
||||||
{
|
{
|
||||||
chunkOffsetZ = ((chunkOffsetZ) % FullDataSourceV2.NUMB_OF_CHUNKS_WIDE);
|
chunkOffsetZ = ((chunkOffsetZ) % NUMB_OF_CHUNKS_WIDE);
|
||||||
if (chunkOffsetZ != 0)
|
if (chunkOffsetZ != 0)
|
||||||
{
|
{
|
||||||
chunkOffsetZ += FullDataSourceV2.NUMB_OF_CHUNKS_WIDE;
|
chunkOffsetZ += NUMB_OF_CHUNKS_WIDE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
chunkOffsetZ %= FullDataSourceV2.NUMB_OF_CHUNKS_WIDE;
|
chunkOffsetZ %= NUMB_OF_CHUNKS_WIDE;
|
||||||
}
|
}
|
||||||
chunkOffsetZ *= LodUtil.CHUNK_WIDTH;
|
chunkOffsetZ *= LodUtil.CHUNK_WIDTH;
|
||||||
|
|
||||||
@@ -295,23 +302,14 @@ public class LodDataBuilder
|
|||||||
|
|
||||||
|
|
||||||
/** @throws ClassCastException if an API user returns the wrong object type(s) */
|
/** @throws ClassCastException if an API user returns the wrong object type(s) */
|
||||||
public static FullDataSourceV2 createFromApiChunkData(DhApiChunk apiChunk) throws ClassCastException, DataCorruptedException
|
public static FullDataSourceV2 createFromApiChunkData(DhApiChunk dataPoints) throws ClassCastException, DataCorruptedException
|
||||||
{
|
{
|
||||||
// get the section position
|
FullDataSourceV2 accessor = FullDataSourceV2.createEmpty(DhSectionPos.encode(new DhChunkPos(dataPoints.chunkPosX, dataPoints.chunkPosZ)));
|
||||||
int sectionPosX = getXOrZSectionPosFromChunkPos(apiChunk.chunkPosX);
|
for (int relZ = 0; relZ < LodUtil.CHUNK_WIDTH; relZ++)
|
||||||
int sectionPosZ = getXOrZSectionPosFromChunkPos(apiChunk.chunkPosZ);
|
|
||||||
long pos = DhSectionPos.encode(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, sectionPosX, sectionPosZ);
|
|
||||||
|
|
||||||
// chunk relative block position in the data source
|
|
||||||
int relSourceBlockX = Math.floorMod(apiChunk.chunkPosX, 4) * LodUtil.CHUNK_WIDTH;
|
|
||||||
int relSourceBlockZ = Math.floorMod(apiChunk.chunkPosZ, 4) * LodUtil.CHUNK_WIDTH;
|
|
||||||
|
|
||||||
FullDataSourceV2 dataSource = FullDataSourceV2.createEmpty(pos);
|
|
||||||
for (int relBlockZ = 0; relBlockZ < LodUtil.CHUNK_WIDTH; relBlockZ++)
|
|
||||||
{
|
{
|
||||||
for (int relBlockX = 0; relBlockX < LodUtil.CHUNK_WIDTH; relBlockX++)
|
for (int relX = 0; relX < LodUtil.CHUNK_WIDTH; relX++)
|
||||||
{
|
{
|
||||||
List<DhApiTerrainDataPoint> columnDataPoints = apiChunk.getDataPoints(relBlockX, relBlockZ);
|
List<DhApiTerrainDataPoint> columnDataPoints = dataPoints.getDataPoints(relX, relZ);
|
||||||
|
|
||||||
|
|
||||||
// this null check does 2 nice things at the same time:
|
// this null check does 2 nice things at the same time:
|
||||||
@@ -325,7 +323,7 @@ public class LodDataBuilder
|
|||||||
{
|
{
|
||||||
DhApiTerrainDataPoint dataPoint = columnDataPoints.get(index);
|
DhApiTerrainDataPoint dataPoint = columnDataPoints.get(index);
|
||||||
|
|
||||||
int id = dataSource.mapping.addIfNotPresentAndGetId(
|
int id = accessor.mapping.addIfNotPresentAndGetId(
|
||||||
(IBiomeWrapper) (dataPoint.biomeWrapper),
|
(IBiomeWrapper) (dataPoint.biomeWrapper),
|
||||||
(IBlockStateWrapper) (dataPoint.blockStateWrapper)
|
(IBlockStateWrapper) (dataPoint.blockStateWrapper)
|
||||||
);
|
);
|
||||||
@@ -333,7 +331,7 @@ public class LodDataBuilder
|
|||||||
packedDataPoints.set(index, FullDataPointUtil.encode(
|
packedDataPoints.set(index, FullDataPointUtil.encode(
|
||||||
id,
|
id,
|
||||||
dataPoint.topYBlockPos - dataPoint.bottomYBlockPos,
|
dataPoint.topYBlockPos - dataPoint.bottomYBlockPos,
|
||||||
dataPoint.bottomYBlockPos - apiChunk.bottomYBlockPos,
|
dataPoint.bottomYBlockPos - dataPoints.topYBlockPos,
|
||||||
(byte) (dataPoint.blockLightLevel),
|
(byte) (dataPoint.blockLightLevel),
|
||||||
(byte) (dataPoint.skyLightLevel)
|
(byte) (dataPoint.skyLightLevel)
|
||||||
));
|
));
|
||||||
@@ -341,14 +339,11 @@ public class LodDataBuilder
|
|||||||
|
|
||||||
// TODO add the ability for API users to define a different compression mode
|
// TODO add the ability for API users to define a different compression mode
|
||||||
// or add a "unkown" compression mode
|
// or add a "unkown" compression mode
|
||||||
dataSource.setSingleColumn(
|
accessor.setSingleColumn(packedDataPoints, relX, relZ, EDhApiWorldGenerationStep.LIGHT, EDhApiWorldCompressionMode.MERGE_SAME_BLOCKS);
|
||||||
packedDataPoints,
|
|
||||||
relBlockX + relSourceBlockX, relBlockZ + relSourceBlockZ,
|
|
||||||
EDhApiWorldGenerationStep.LIGHT, EDhApiWorldCompressionMode.MERGE_SAME_BLOCKS);
|
|
||||||
dataSource.isEmpty = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dataSource;
|
|
||||||
|
return accessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -359,13 +354,4 @@ public class LodDataBuilder
|
|||||||
|
|
||||||
public static boolean canGenerateLodFromChunk(IChunkWrapper chunk) { return chunk != null && chunk.isLightCorrect(); }
|
public static boolean canGenerateLodFromChunk(IChunkWrapper chunk) { return chunk != null && chunk.isLightCorrect(); }
|
||||||
|
|
||||||
public static int getXOrZSectionPosFromChunkPos(int chunkXOrZPos)
|
|
||||||
{
|
|
||||||
// get the section position
|
|
||||||
int sectionPos = chunkXOrZPos;
|
|
||||||
// negative positions start at -1 so the logic there is slightly different
|
|
||||||
sectionPos = (sectionPos < 0) ? ((sectionPos + 1) / FullDataSourceV2.NUMB_OF_CHUNKS_WIDE) - 1 : (sectionPos / FullDataSourceV2.NUMB_OF_CHUNKS_WIDE);
|
|
||||||
return sectionPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,7 +98,9 @@ public enum EDhDirection
|
|||||||
private static final EDhDirection[] VALUES = values();
|
private static final EDhDirection[] VALUES = values();
|
||||||
|
|
||||||
private static final Map<String, EDhDirection> BY_NAME = Arrays.stream(VALUES).collect(Collectors.toMap(EDhDirection::getName, (p_199787_0_) ->
|
private static final Map<String, EDhDirection> BY_NAME = Arrays.stream(VALUES).collect(Collectors.toMap(EDhDirection::getName, (p_199787_0_) ->
|
||||||
p_199787_0_));
|
{
|
||||||
|
return p_199787_0_;
|
||||||
|
}));
|
||||||
|
|
||||||
// private static final LodDirection[] BY_3D_DATA = Arrays.stream(VALUES).sorted(Comparator.comparingInt((p_199790_0_) ->
|
// private static final LodDirection[] BY_3D_DATA = Arrays.stream(VALUES).sorted(Comparator.comparingInt((p_199790_0_) ->
|
||||||
// {
|
// {
|
||||||
@@ -245,26 +247,36 @@ public enum EDhDirection
|
|||||||
|
|
||||||
public EDhDirection getClockWise()
|
public EDhDirection getClockWise()
|
||||||
{
|
{
|
||||||
return switch (this)
|
switch (this)
|
||||||
{
|
{
|
||||||
case NORTH -> EAST;
|
case NORTH:
|
||||||
case SOUTH -> WEST;
|
return EAST;
|
||||||
case WEST -> NORTH;
|
case SOUTH:
|
||||||
case EAST -> SOUTH;
|
return WEST;
|
||||||
default -> throw new IllegalStateException("Unable to get Y-rotated facing of " + this);
|
case WEST:
|
||||||
};
|
return NORTH;
|
||||||
|
case EAST:
|
||||||
|
return SOUTH;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException("Unable to get Y-rotated facing of " + this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public EDhDirection getCounterClockWise()
|
public EDhDirection getCounterClockWise()
|
||||||
{
|
{
|
||||||
return switch (this)
|
switch (this)
|
||||||
{
|
{
|
||||||
case NORTH -> WEST;
|
case NORTH:
|
||||||
case SOUTH -> EAST;
|
return WEST;
|
||||||
case WEST -> SOUTH;
|
case SOUTH:
|
||||||
case EAST -> NORTH;
|
return EAST;
|
||||||
default -> throw new IllegalStateException("Unable to get CCW facing of " + this);
|
case WEST:
|
||||||
};
|
return SOUTH;
|
||||||
|
case EAST:
|
||||||
|
return NORTH;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException("Unable to get CCW facing of " + this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
@@ -305,11 +317,16 @@ public enum EDhDirection
|
|||||||
|
|
||||||
public static EDhDirection fromAxisAndDirection(EDhDirection.Axis p_211699_0_, EDhDirection.AxisDirection p_211699_1_)
|
public static EDhDirection fromAxisAndDirection(EDhDirection.Axis p_211699_0_, EDhDirection.AxisDirection p_211699_1_)
|
||||||
{
|
{
|
||||||
return switch (p_211699_0_) {
|
switch (p_211699_0_)
|
||||||
case X -> p_211699_1_ == AxisDirection.POSITIVE ? EAST : WEST;
|
{
|
||||||
case Y -> p_211699_1_ == AxisDirection.POSITIVE ? UP : DOWN;
|
case X:
|
||||||
default -> p_211699_1_ == AxisDirection.POSITIVE ? SOUTH : NORTH;
|
return p_211699_1_ == EDhDirection.AxisDirection.POSITIVE ? EAST : WEST;
|
||||||
};
|
case Y:
|
||||||
|
return p_211699_1_ == EDhDirection.AxisDirection.POSITIVE ? UP : DOWN;
|
||||||
|
case Z:
|
||||||
|
default:
|
||||||
|
return p_211699_1_ == EDhDirection.AxisDirection.POSITIVE ? SOUTH : NORTH;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public float toYRot()
|
// public float toYRot()
|
||||||
@@ -419,7 +436,9 @@ public enum EDhDirection
|
|||||||
private static final EDhDirection.Axis[] VALUES = values();
|
private static final EDhDirection.Axis[] VALUES = values();
|
||||||
|
|
||||||
private static final Map<String, EDhDirection.Axis> BY_NAME = Arrays.stream(VALUES).collect(Collectors.toMap(EDhDirection.Axis::getName, (p_199785_0_) ->
|
private static final Map<String, EDhDirection.Axis> BY_NAME = Arrays.stream(VALUES).collect(Collectors.toMap(EDhDirection.Axis::getName, (p_199785_0_) ->
|
||||||
p_199785_0_));
|
{
|
||||||
|
return p_199785_0_;
|
||||||
|
}));
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
Axis(String name)
|
Axis(String name)
|
||||||
|
|||||||
+5
-5
@@ -125,10 +125,10 @@ public class FullDataSourceProviderV2
|
|||||||
|
|
||||||
// start migrating any legacy data sources present in the background
|
// start migrating any legacy data sources present in the background
|
||||||
this.migrationThreadPool = ThreadUtil.makeRateLimitedThreadPool(1, MIGRATION_THREAD_NAME_PREFIX +"["+dimensionName+"]", Config.Client.Advanced.MultiThreading.runTimeRatioForUpdatePropagatorThreads.get(), Thread.MIN_PRIORITY, (Semaphore)null);
|
this.migrationThreadPool = ThreadUtil.makeRateLimitedThreadPool(1, MIGRATION_THREAD_NAME_PREFIX +"["+dimensionName+"]", Config.Client.Advanced.MultiThreading.runTimeRatioForUpdatePropagatorThreads.get(), Thread.MIN_PRIORITY, (Semaphore)null);
|
||||||
this.migrationThreadPool.execute(this::convertLegacyDataSources);
|
this.migrationThreadPool.execute(() -> this.convertLegacyDataSources());
|
||||||
|
|
||||||
this.updateQueueProcessor = ThreadUtil.makeSingleThreadPool("Parent Update Queue ["+dimensionName+"]");
|
this.updateQueueProcessor = ThreadUtil.makeSingleThreadPool("Parent Update Queue ["+dimensionName+"]");
|
||||||
this.updateQueueProcessor.execute(this::runUpdateQueue);
|
this.updateQueueProcessor.execute(() -> this.runUpdateQueue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -604,12 +604,12 @@ public class FullDataSourceProviderV2
|
|||||||
public void debugRender(DebugRenderer renderer)
|
public void debugRender(DebugRenderer renderer)
|
||||||
{
|
{
|
||||||
this.lockedPosSet
|
this.lockedPosSet
|
||||||
.forEach((pos) -> renderer.renderBox(new DebugRenderer.Box(pos, -32f, 74f, 0.15f, Color.PINK)));
|
.forEach((pos) -> { renderer.renderBox(new DebugRenderer.Box(pos, -32f, 74f, 0.15f, Color.PINK)); });
|
||||||
|
|
||||||
this.queuedUpdateCountsByPos
|
this.queuedUpdateCountsByPos
|
||||||
.forEach((pos, updateCountRef) -> renderer.renderBox(new DebugRenderer.Box(pos, -32f, 80f + (updateCountRef.get() * 16f), 0.20f, Color.WHITE)));
|
.forEach((pos, updateCountRef) -> { renderer.renderBox(new DebugRenderer.Box(pos, -32f, 80f + (updateCountRef.get() * 16f), 0.20f, Color.WHITE)); });
|
||||||
this.parentUpdatingPosSet
|
this.parentUpdatingPosSet
|
||||||
.forEach((pos) -> renderer.renderBox(new DebugRenderer.Box(pos, -32f, 80f, 0.20f, Color.MAGENTA)));
|
.forEach((pos) -> { renderer.renderBox(new DebugRenderer.Box(pos, -32f, 80f, 0.20f, Color.MAGENTA)); });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+7
-4
@@ -111,7 +111,7 @@ public class GeneratedFullDataSourceProvider extends FullDataSourceProviderV2 im
|
|||||||
// if the generation task was split up into smaller positions, add the on-complete event to them
|
// if the generation task was split up into smaller positions, add the on-complete event to them
|
||||||
for (CompletableFuture<WorldGenResult> siblingFuture : genTaskResult.childFutures)
|
for (CompletableFuture<WorldGenResult> siblingFuture : genTaskResult.childFutures)
|
||||||
{
|
{
|
||||||
siblingFuture.whenComplete(this::onWorldGenTaskComplete);
|
siblingFuture.whenComplete((siblingGenTaskResult, siblingEx) -> this.onWorldGenTaskComplete(siblingGenTaskResult, siblingEx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +215,7 @@ public class GeneratedFullDataSourceProvider extends FullDataSourceProviderV2 im
|
|||||||
|
|
||||||
GenTask genTask = new GenTask(genPos);
|
GenTask genTask = new GenTask(genPos);
|
||||||
CompletableFuture<WorldGenResult> worldGenFuture = worldGenQueue.submitGenTask(genPos, (byte) (DhSectionPos.getDetailLevel(genPos) - DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL), genTask);
|
CompletableFuture<WorldGenResult> worldGenFuture = worldGenQueue.submitGenTask(genPos, (byte) (DhSectionPos.getDetailLevel(genPos) - DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL), genTask);
|
||||||
worldGenFuture.whenComplete(this::onWorldGenTaskComplete);
|
worldGenFuture.whenComplete((genTaskResult, ex) -> this.onWorldGenTaskComplete(genTaskResult, ex));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -362,7 +362,7 @@ public class GeneratedFullDataSourceProvider extends FullDataSourceProviderV2 im
|
|||||||
super.debugRender(renderer);
|
super.debugRender(renderer);
|
||||||
|
|
||||||
this.delayedFullDataSourceSaveCache.dataSourceByPosition
|
this.delayedFullDataSourceSaveCache.dataSourceByPosition
|
||||||
.forEach((pos, dataSource) -> renderer.renderBox(new DebugRenderer.Box(pos, -32f, 80f, 0.20f, Color.green.darker())));
|
.forEach((pos, dataSource) -> { renderer.renderBox(new DebugRenderer.Box(pos, -32f, 80f, 0.20f, Color.green.darker())); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -387,7 +387,10 @@ public class GeneratedFullDataSourceProvider extends FullDataSourceProviderV2 im
|
|||||||
@Override
|
@Override
|
||||||
public Consumer<FullDataSourceV2> getChunkDataConsumer()
|
public Consumer<FullDataSourceV2> getChunkDataConsumer()
|
||||||
{
|
{
|
||||||
return GeneratedFullDataSourceProvider.this.delayedFullDataSourceSaveCache::queueDataSourceForUpdateAndSave;
|
return (chunkSizedFullDataSource) ->
|
||||||
|
{
|
||||||
|
GeneratedFullDataSourceProvider.this.delayedFullDataSourceSaveCache.queueDataSourceForUpdateAndSave(chunkSizedFullDataSource);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void onDataSourceSave(FullDataSourceV2 fullDataSource)
|
private void onDataSourceSave(FullDataSourceV2 fullDataSource)
|
||||||
|
|||||||
+32
-29
@@ -41,17 +41,13 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
public class ClientOnlySaveStructure extends AbstractSaveStructure
|
public class ClientOnlySaveStructure extends AbstractSaveStructure
|
||||||
{
|
{
|
||||||
public static final String SERVER_DATA_FOLDER_NAME = "Distant_Horizons_server_data";
|
final File folder;
|
||||||
public static final String REPLAY_SERVER_FOLDER_NAME = "REPLAY";
|
|
||||||
public static final String INVALID_FILE_CHARACTERS_REGEX = "[\\\\/:*?\"<>|]";
|
|
||||||
|
|
||||||
private static final IMinecraftClientWrapper MC_CLIENT = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
|
private static final IMinecraftClientWrapper MC_CLIENT = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
|
||||||
private static final IMinecraftSharedWrapper MC_SHARED = SingletonInjector.INSTANCE.get(IMinecraftSharedWrapper.class);
|
private static final IMinecraftSharedWrapper MC_SHARED = SingletonInjector.INSTANCE.get(IMinecraftSharedWrapper.class);
|
||||||
|
public static final String INVALID_FILE_CHARACTERS_REGEX = "[\\\\/:*?\"<>|]";
|
||||||
|
|
||||||
|
SubDimensionLevelMatcher subDimMatcher = null;
|
||||||
private SubDimensionLevelMatcher subDimMatcher = null;
|
final HashMap<ILevelWrapper, File> levelWrapperToFileMap = new HashMap<>();
|
||||||
private final File folder;
|
|
||||||
private final HashMap<ILevelWrapper, File> levelWrapperToFileMap = new HashMap<>();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -85,8 +81,9 @@ public class ClientOnlySaveStructure extends AbstractSaveStructure
|
|||||||
return this.levelWrapperToFileMap.computeIfAbsent(levelWrapper, (newLevelWrapper) ->
|
return this.levelWrapperToFileMap.computeIfAbsent(levelWrapper, (newLevelWrapper) ->
|
||||||
{
|
{
|
||||||
// Use the server provided key if one was provided
|
// Use the server provided key if one was provided
|
||||||
if (newLevelWrapper instanceof IServerKeyedClientLevel keyedClientLevel)
|
if (newLevelWrapper instanceof IServerKeyedClientLevel)
|
||||||
{
|
{
|
||||||
|
IServerKeyedClientLevel keyedClientLevel = (IServerKeyedClientLevel) newLevelWrapper;
|
||||||
LOGGER.info("Loading level " + newLevelWrapper.getDimensionType().getDimensionName() + " with key: " + keyedClientLevel.getServerLevelKey());
|
LOGGER.info("Loading level " + newLevelWrapper.getDimensionType().getDimensionName() + " with key: " + keyedClientLevel.getServerLevelKey());
|
||||||
// This world was identified by the server directly, so we can know for sure which folder to use.
|
// This world was identified by the server directly, so we can know for sure which folder to use.
|
||||||
return new File(getSaveStructureFolderPath() + File.separatorChar + keyedClientLevel.getServerLevelKey());
|
return new File(getSaveStructureFolderPath() + File.separatorChar + keyedClientLevel.getServerLevelKey());
|
||||||
@@ -94,8 +91,9 @@ public class ClientOnlySaveStructure extends AbstractSaveStructure
|
|||||||
|
|
||||||
|
|
||||||
// use multiverse matching if enabled and in multiplayer (the server should already know where the player is)
|
// use multiverse matching if enabled and in multiplayer (the server should already know where the player is)
|
||||||
if (newLevelWrapper instanceof IClientLevelWrapper newClientLevelWrapper && Config.Client.Advanced.Multiplayer.multiverseSimilarityRequiredPercent.get() != 0)
|
if (newLevelWrapper instanceof IClientLevelWrapper && Config.Client.Advanced.Multiplayer.multiverseSimilarityRequiredPercent.get() != 0)
|
||||||
{
|
{
|
||||||
|
IClientLevelWrapper newClientLevelWrapper = (IClientLevelWrapper) newLevelWrapper;
|
||||||
|
|
||||||
// create the matcher if one doesn't exist
|
// create the matcher if one doesn't exist
|
||||||
if (this.subDimMatcher == null || !this.subDimMatcher.isFindingLevel(newClientLevelWrapper))
|
if (this.subDimMatcher == null || !this.subDimMatcher.isFindingLevel(newClientLevelWrapper))
|
||||||
@@ -132,12 +130,12 @@ public class ClientOnlySaveStructure extends AbstractSaveStructure
|
|||||||
private File getLevelFolderWithoutSimilarityMatching(ILevelWrapper level)
|
private File getLevelFolderWithoutSimilarityMatching(ILevelWrapper level)
|
||||||
{
|
{
|
||||||
List<File> folders = this.getDhDataFoldersForDimension(level.getDimensionType());
|
List<File> folders = this.getDhDataFoldersForDimension(level.getDimensionType());
|
||||||
if (!folders.isEmpty() && folders.getFirst() != null)
|
if (!folders.isEmpty() && folders.get(0) != null)
|
||||||
{
|
{
|
||||||
// use the first existing sub-dimension
|
// use the first existing sub-dimension
|
||||||
String folderName = folders.getFirst().getName();
|
String folderName = folders.get(0).getName();
|
||||||
LOGGER.info("Default Sub Dimension set to: [" + LodUtil.shortenString(folderName, 8) + "...]");
|
LOGGER.info("Default Sub Dimension set to: [" + LodUtil.shortenString(folderName, 8) + "...]");
|
||||||
return folders.getFirst();
|
return folders.get(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -239,7 +237,7 @@ public class ClientOnlySaveStructure extends AbstractSaveStructure
|
|||||||
private static String getSaveStructureFolderPath()
|
private static String getSaveStructureFolderPath()
|
||||||
{
|
{
|
||||||
String path = MC_SHARED.getInstallationDirectory().getPath() + File.separatorChar
|
String path = MC_SHARED.getInstallationDirectory().getPath() + File.separatorChar
|
||||||
+ SERVER_DATA_FOLDER_NAME + File.separatorChar
|
+ "Distant_Horizons_server_data" + File.separatorChar
|
||||||
+ getServerFolderName();
|
+ getServerFolderName();
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
@@ -247,14 +245,6 @@ public class ClientOnlySaveStructure extends AbstractSaveStructure
|
|||||||
/** Generated from the server the client is currently connected to. */
|
/** Generated from the server the client is currently connected to. */
|
||||||
private static String getServerFolderName()
|
private static String getServerFolderName()
|
||||||
{
|
{
|
||||||
// if connected to a replay we won't have any server info
|
|
||||||
// use the dedicated replay server folder
|
|
||||||
if (MC_CLIENT.connectedToReplay())
|
|
||||||
{
|
|
||||||
return REPLAY_SERVER_FOLDER_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// parse the current server's IP
|
// parse the current server's IP
|
||||||
ParsedIp parsedIp = new ParsedIp(MC_CLIENT.getCurrentServerIp());
|
ParsedIp parsedIp = new ParsedIp(MC_CLIENT.getCurrentServerIp());
|
||||||
String serverIpCleaned = parsedIp.ip.replaceAll(INVALID_FILE_CHARACTERS_REGEX, "");
|
String serverIpCleaned = parsedIp.ip.replaceAll(INVALID_FILE_CHARACTERS_REGEX, "");
|
||||||
@@ -268,14 +258,27 @@ public class ClientOnlySaveStructure extends AbstractSaveStructure
|
|||||||
|
|
||||||
|
|
||||||
// generate the folder name
|
// generate the folder name
|
||||||
String folderName = switch (folderNameMode)
|
String folderName;
|
||||||
|
switch (folderNameMode)
|
||||||
{
|
{
|
||||||
default -> serverName;
|
default:
|
||||||
case IP_ONLY -> serverIpCleaned;
|
case NAME_ONLY:
|
||||||
case NAME_IP -> serverName + ", IP " + serverIpCleaned;
|
folderName = serverName;
|
||||||
case NAME_IP_PORT -> serverName + ", IP " + serverIpCleaned + (serverPortCleaned.length() != 0 ? ("-" + serverPortCleaned) : "");
|
break;
|
||||||
case NAME_IP_PORT_MC_VERSION -> serverName + ", IP " + serverIpCleaned + (serverPortCleaned.length() != 0 ? ("-" + serverPortCleaned) : "") + ", GameVersion " + serverMcVersion;
|
case IP_ONLY:
|
||||||
};
|
folderName = serverIpCleaned;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NAME_IP:
|
||||||
|
folderName = serverName + ", IP " + serverIpCleaned;
|
||||||
|
break;
|
||||||
|
case NAME_IP_PORT:
|
||||||
|
folderName = serverName + ", IP " + serverIpCleaned + (serverPortCleaned.length() != 0 ? ("-" + serverPortCleaned) : "");
|
||||||
|
break;
|
||||||
|
case NAME_IP_PORT_MC_VERSION:
|
||||||
|
folderName = serverName + ", IP " + serverIpCleaned + (serverPortCleaned.length() != 0 ? ("-" + serverPortCleaned) : "") + ", GameVersion " + serverMcVersion;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// PercentEscaper makes the characters all part of the standard alphameric character set
|
// PercentEscaper makes the characters all part of the standard alphameric character set
|
||||||
// This fixes some issues when the server is named something in other languages
|
// This fixes some issues when the server is named something in other languages
|
||||||
|
|||||||
+2
-2
@@ -190,7 +190,7 @@ public class SubDimensionLevelMatcher implements AutoCloseable
|
|||||||
}
|
}
|
||||||
FullDataSourceV2 newChunkSizedFullDataView = FullDataSourceV2.createFromChunk(newlyLoadedChunk);
|
FullDataSourceV2 newChunkSizedFullDataView = FullDataSourceV2.createFromChunk(newlyLoadedChunk);
|
||||||
// convert to a data source for easier comparing
|
// convert to a data source for easier comparing
|
||||||
FullDataSourceV2 newDataSource = FullDataSourceV2.createEmpty(DhSectionPos.encodeContaining(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, this.playerData.playerBlockPos));
|
FullDataSourceV2 newDataSource = FullDataSourceV2.createEmpty(DhSectionPos.encode(this.playerData.playerBlockPos));
|
||||||
newDataSource.update(newChunkSizedFullDataView);
|
newDataSource.update(newChunkSizedFullDataView);
|
||||||
|
|
||||||
|
|
||||||
@@ -215,7 +215,7 @@ public class SubDimensionLevelMatcher implements AutoCloseable
|
|||||||
// get the data source to compare against
|
// get the data source to compare against
|
||||||
try (IDhLevel tempLevel = new DhClientLevel(new ClientOnlySaveStructure(), this.currentClientLevel, testLevelFolder, false))
|
try (IDhLevel tempLevel = new DhClientLevel(new ClientOnlySaveStructure(), this.currentClientLevel, testLevelFolder, false))
|
||||||
{
|
{
|
||||||
testFullDataSource = tempLevel.getFullDataProvider().getAsync(DhSectionPos.encodeContaining(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, this.playerData.playerBlockPos)).join();
|
testFullDataSource = tempLevel.getFullDataProvider().getAsync(DhSectionPos.encode(this.playerData.playerBlockPos)).join();
|
||||||
if (testFullDataSource == null)
|
if (testFullDataSource == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -109,17 +109,23 @@ public class BatchGenerator implements IDhApiWorldGenerator
|
|||||||
int chunkPosMinX, int chunkPosMinZ, byte granularity, byte targetDataDetail, EDhApiDistantGeneratorMode generatorMode,
|
int chunkPosMinX, int chunkPosMinZ, byte granularity, byte targetDataDetail, EDhApiDistantGeneratorMode generatorMode,
|
||||||
ExecutorService worldGeneratorThreadPool, Consumer<Object[]> resultConsumer)
|
ExecutorService worldGeneratorThreadPool, Consumer<Object[]> resultConsumer)
|
||||||
{
|
{
|
||||||
EDhApiWorldGenerationStep targetStep = switch (generatorMode)
|
EDhApiWorldGenerationStep targetStep = null;
|
||||||
|
switch (generatorMode)
|
||||||
{
|
{
|
||||||
case PRE_EXISTING_ONLY -> // Only load in existing chunks. Note: this requires the biome generation step in order for biomes to be properly initialized.
|
case PRE_EXISTING_ONLY: // Only load in existing chunks. Note: this requires the biome generation step in order for biomes to be properly initialized.
|
||||||
//case BIOME_ONLY: // No blocks. Require fake height in LodBuilder
|
//case BIOME_ONLY: // No blocks. Require fake height in LodBuilder
|
||||||
EDhApiWorldGenerationStep.BIOMES;
|
targetStep = EDhApiWorldGenerationStep.BIOMES;
|
||||||
|
break;
|
||||||
//case BIOME_ONLY_SIMULATE_HEIGHT:
|
//case BIOME_ONLY_SIMULATE_HEIGHT:
|
||||||
// targetStep = EDhApiWorldGenerationStep.NOISE; // Stone only. Requires a fake surface
|
// targetStep = EDhApiWorldGenerationStep.NOISE; // Stone only. Requires a fake surface
|
||||||
// break;
|
// break;
|
||||||
case SURFACE -> EDhApiWorldGenerationStep.SURFACE;
|
case SURFACE:
|
||||||
case FEATURES -> EDhApiWorldGenerationStep.FEATURES;
|
targetStep = EDhApiWorldGenerationStep.SURFACE;
|
||||||
};
|
break;
|
||||||
|
case FEATURES:
|
||||||
|
targetStep = EDhApiWorldGenerationStep.FEATURES;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
int genChunkSize = BitShiftUtil.powerOfTwo(granularity - 4); // minus 4 is equal to dividing by 16 to convert to chunk scale
|
int genChunkSize = BitShiftUtil.powerOfTwo(granularity - 4); // minus 4 is equal to dividing by 16 to convert to chunk scale
|
||||||
|
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ public class DhLightingEngine
|
|||||||
* Since these objects are always mutated anyway, using a {@link ThreadLocal} will allow us to
|
* Since these objects are always mutated anyway, using a {@link ThreadLocal} will allow us to
|
||||||
* only create as many of these {@link DhBlockPos} as necessary.
|
* only create as many of these {@link DhBlockPos} as necessary.
|
||||||
*/
|
*/
|
||||||
private static final ThreadLocal<DhBlockPos> PRIMARY_BLOCK_POS_REF = ThreadLocal.withInitial(DhBlockPos::new);
|
private static final ThreadLocal<DhBlockPos> PRIMARY_BLOCK_POS_REF = ThreadLocal.withInitial(() -> new DhBlockPos());
|
||||||
private static final ThreadLocal<DhBlockPos> SECONDARY_BLOCK_POS_REF = ThreadLocal.withInitial(DhBlockPos::new);
|
private static final ThreadLocal<DhBlockPos> SECONDARY_BLOCK_POS_REF = ThreadLocal.withInitial(() -> new DhBlockPos());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+20
-17
@@ -78,7 +78,7 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb
|
|||||||
// TODO this logic isn't great and can cause a limit to how many threads could be used for world generation,
|
// TODO this logic isn't great and can cause a limit to how many threads could be used for world generation,
|
||||||
// however it won't cause duplicate requests or concurrency issues, so it will be good enough for now.
|
// however it won't cause duplicate requests or concurrency issues, so it will be good enough for now.
|
||||||
// A good long term fix may be to either:
|
// A good long term fix may be to either:
|
||||||
// 1. allow the generator to deal with larger sections (let the generator threads split up larger tasks into smaller ones
|
// 1. allow the generator to deal with larger sections (let the generator threads split up larger tasks into smaller one
|
||||||
// 2. batch requests better. instead of sending 4 individual tasks of detail level N, send 1 task of detail level n+1
|
// 2. batch requests better. instead of sending 4 individual tasks of detail level N, send 1 task of detail level n+1
|
||||||
private final ExecutorService queueingThread = ThreadUtil.makeSingleThreadPool("World Gen Queue");
|
private final ExecutorService queueingThread = ThreadUtil.makeSingleThreadPool("World Gen Queue");
|
||||||
private boolean generationQueueRunning = false;
|
private boolean generationQueueRunning = false;
|
||||||
@@ -226,9 +226,6 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
LOGGER.error("queueing exception: " + e.getMessage(), e);
|
LOGGER.error("queueing exception: " + e.getMessage(), e);
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
this.generationQueueRunning = false;
|
this.generationQueueRunning = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -376,7 +373,7 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb
|
|||||||
// don't log the shutdown exceptions
|
// don't log the shutdown exceptions
|
||||||
if (!LodUtil.isInterruptOrReject(exception))
|
if (!LodUtil.isInterruptOrReject(exception))
|
||||||
{
|
{
|
||||||
LOGGER.error("Error generating data for pos: " + DhSectionPos.toString(taskPos), exception);
|
LOGGER.error("Error generating data for section " + taskPos, exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
newTaskGroup.group.worldGenTasks.forEach(worldGenTask -> worldGenTask.future.complete(WorldGenResult.CreateFail()));
|
newTaskGroup.group.worldGenTasks.forEach(worldGenTask -> worldGenTask.future.complete(WorldGenResult.CreateFail()));
|
||||||
@@ -386,11 +383,11 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb
|
|||||||
newTaskGroup.group.worldGenTasks.forEach(worldGenTask -> worldGenTask.future.complete(WorldGenResult.CreateSuccess(DhSectionPos.encode(granularity, DhSectionPos.getX(taskPos), DhSectionPos.getZ(taskPos)))));
|
newTaskGroup.group.worldGenTasks.forEach(worldGenTask -> worldGenTask.future.complete(WorldGenResult.CreateSuccess(DhSectionPos.encode(granularity, DhSectionPos.getX(taskPos), DhSectionPos.getZ(taskPos)))));
|
||||||
}
|
}
|
||||||
boolean worked = this.inProgressGenTasksByLodPos.remove(taskPos, newTaskGroup);
|
boolean worked = this.inProgressGenTasksByLodPos.remove(taskPos, newTaskGroup);
|
||||||
LodUtil.assertTrue(worked, "Unable to find in progress generator task with position ["+DhSectionPos.toString(taskPos)+"]");
|
LodUtil.assertTrue(worked);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
LOGGER.error("Unexpected error completing world gen task at pos: ["+DhSectionPos.toString(taskPos)+"].", e);
|
LOGGER.error("Unexpected error completing world gen task: "+taskPos, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -428,16 +425,18 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb
|
|||||||
{
|
{
|
||||||
EDhApiDistantGeneratorMode generatorMode = Config.Client.Advanced.WorldGenerator.distantGeneratorMode.get();
|
EDhApiDistantGeneratorMode generatorMode = Config.Client.Advanced.WorldGenerator.distantGeneratorMode.get();
|
||||||
EDhApiWorldGeneratorReturnType returnType = this.generator.getReturnType();
|
EDhApiWorldGeneratorReturnType returnType = this.generator.getReturnType();
|
||||||
return switch (returnType)
|
switch (returnType)
|
||||||
{
|
{
|
||||||
case VANILLA_CHUNKS -> this.generator.generateChunks(
|
case VANILLA_CHUNKS:
|
||||||
|
{
|
||||||
|
return this.generator.generateChunks(
|
||||||
chunkPosMin.x,
|
chunkPosMin.x,
|
||||||
chunkPosMin.z,
|
chunkPosMin.z,
|
||||||
granularity,
|
granularity,
|
||||||
targetDataDetail,
|
targetDataDetail,
|
||||||
generatorMode,
|
generatorMode,
|
||||||
ThreadPoolUtil.getWorldGenExecutor(),
|
ThreadPoolUtil.getWorldGenExecutor(),
|
||||||
(Object[] generatedObjectArray) ->
|
(Object[] generatedObjectArray) ->
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -452,8 +451,11 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb
|
|||||||
Config.Client.Advanced.WorldGenerator.enableDistantGeneration.set(false);
|
Config.Client.Advanced.WorldGenerator.enableDistantGeneration.set(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
case API_CHUNKS -> this.generator.generateApiChunks(
|
}
|
||||||
|
case API_CHUNKS:
|
||||||
|
{
|
||||||
|
return this.generator.generateApiChunks(
|
||||||
chunkPosMin.x,
|
chunkPosMin.x,
|
||||||
chunkPosMin.z,
|
chunkPosMin.z,
|
||||||
granularity,
|
granularity,
|
||||||
@@ -478,13 +480,14 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb
|
|||||||
Config.Client.Advanced.WorldGenerator.enableDistantGeneration.set(false);
|
Config.Client.Advanced.WorldGenerator.enableDistantGeneration.set(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
default ->
|
}
|
||||||
|
default:
|
||||||
{
|
{
|
||||||
Config.Client.Advanced.WorldGenerator.enableDistantGeneration.set(false);
|
Config.Client.Advanced.WorldGenerator.enableDistantGeneration.set(false);
|
||||||
throw new AssertFailureException("Unknown return type: " + returnType);
|
throw new AssertFailureException("Unknown return type: " + returnType);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -610,8 +613,8 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb
|
|||||||
@Override
|
@Override
|
||||||
public void debugRender(DebugRenderer renderer)
|
public void debugRender(DebugRenderer renderer)
|
||||||
{
|
{
|
||||||
this.waitingTasks.keySet().forEach((pos) -> renderer.renderBox(new DebugRenderer.Box(pos, -32f, 64f, 0.05f, Color.blue)));
|
this.waitingTasks.keySet().forEach((pos) -> { renderer.renderBox(new DebugRenderer.Box(pos, -32f, 64f, 0.05f, Color.blue)); });
|
||||||
this.inProgressGenTasksByLodPos.forEach((pos, t) -> renderer.renderBox(new DebugRenderer.Box(pos, -32f, 64f, 0.05f, Color.red)));
|
this.inProgressGenTasksByLodPos.forEach((pos, t) -> { renderer.renderBox(new DebugRenderer.Box(pos, -32f, 64f, 0.05f, Color.red)); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -40,14 +40,20 @@ public class DarkModeDetector
|
|||||||
|
|
||||||
public static boolean isDarkMode()
|
public static boolean isDarkMode()
|
||||||
{
|
{
|
||||||
return switch (EPlatform.get())
|
switch (EPlatform.get())
|
||||||
{
|
{
|
||||||
case WINDOWS -> isWindowsDarkMode();
|
case WINDOWS:
|
||||||
case MACOS -> isMacOsDarkMode();
|
return isWindowsDarkMode();
|
||||||
// Most Unix(-like) distros also use a lot of the same things as Linux (like desktop environments and window managers)
|
case MACOS:
|
||||||
case LINUX, BSD, UNIX -> checkLinuxDark();
|
return isMacOsDarkMode();
|
||||||
default -> false;
|
case LINUX:
|
||||||
};
|
// Most Unix(-like) distros also use a lot of the same things as Linux (like desktop environments and window managers)
|
||||||
|
case BSD:
|
||||||
|
case UNIX:
|
||||||
|
return checkLinuxDark();
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needs checking as I dont use Mac
|
// Needs checking as I dont use Mac
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ public class JarMain
|
|||||||
|
|
||||||
|
|
||||||
// Selected download
|
// Selected download
|
||||||
AtomicReference<String> downloadID = new AtomicReference<>("");
|
AtomicReference<String> downloadID = new AtomicReference<String>("");
|
||||||
|
|
||||||
|
|
||||||
// This is for the panel to show the update description
|
// This is for the panel to show the update description
|
||||||
|
|||||||
@@ -175,12 +175,17 @@ public class JarUtils
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public static OperatingSystem getOperatingSystem()
|
public static OperatingSystem getOperatingSystem()
|
||||||
{ // Get the os and turn it into that enum
|
{ // Get the os and turn it into that enum
|
||||||
return switch (EPlatform.get()) {
|
switch (EPlatform.get())
|
||||||
case WINDOWS -> OperatingSystem.WINDOWS;
|
{
|
||||||
case LINUX -> OperatingSystem.LINUX;
|
case WINDOWS:
|
||||||
case MACOS -> OperatingSystem.MACOS;
|
return OperatingSystem.WINDOWS;
|
||||||
default -> OperatingSystem.NONE;
|
case LINUX:
|
||||||
};
|
return OperatingSystem.LINUX;
|
||||||
|
case MACOS:
|
||||||
|
return OperatingSystem.MACOS;
|
||||||
|
default:
|
||||||
|
return OperatingSystem.NONE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class BaseJFrame extends JFrame
|
|||||||
final BufferedReader br = new BufferedReader(isr)
|
final BufferedReader br = new BufferedReader(isr)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
List<Object> col = List.of(br.lines().toArray());
|
List<Object> col = Collections.unmodifiableList(new ArrayList<>(Arrays.asList(br.lines().toArray())));
|
||||||
for (Object obj : col)
|
for (Object obj : col)
|
||||||
{
|
{
|
||||||
langsToChoose.add(((String) obj).replaceAll("\\.json", ""));
|
langsToChoose.add(((String) obj).replaceAll("\\.json", ""));
|
||||||
@@ -101,7 +101,7 @@ public class BaseJFrame extends JFrame
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Creates the box
|
// Creates the box
|
||||||
JComboBox<String> languageBox = new JComboBox<>(new DefaultComboBoxModel(langsToChoose.toArray()));
|
JComboBox<String> languageBox = new JComboBox(new DefaultComboBoxModel(langsToChoose.toArray()));
|
||||||
languageBox.setSelectedIndex(langsToChoose.indexOf(Locale.getDefault().toString().toLowerCase()));
|
languageBox.setSelectedIndex(langsToChoose.indexOf(Locale.getDefault().toString().toLowerCase()));
|
||||||
languageBox.addActionListener(e -> {
|
languageBox.addActionListener(e -> {
|
||||||
Locale.setDefault(Locale.forLanguageTag(languageBox.getSelectedItem().toString())); // Change lang on update
|
Locale.setDefault(Locale.forLanguageTag(languageBox.getSelectedItem().toString())); // Change lang on update
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ public class GitlabGetter
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
GitlabGetter gitlabGetter = new GitlabGetter();
|
GitlabGetter gitlabGetter = new GitlabGetter();
|
||||||
|
|
||||||
System.out.println(gitlabGetter.getDownloads(gitlabGetter.projectPipelines.getFirst().get("id")));
|
System.out.println(gitlabGetter.getDownloads(gitlabGetter.projectPipelines.get(0).get("id")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+7
-7
@@ -72,8 +72,8 @@ public class ModrinthGetter
|
|||||||
downloadUrl.put(workingID,
|
downloadUrl.put(workingID,
|
||||||
new URL(
|
new URL(
|
||||||
((Config)
|
((Config)
|
||||||
((ArrayList<?>) currentRelease.get("files"))
|
((ArrayList) currentRelease.get("files"))
|
||||||
.getFirst())
|
.get(0))
|
||||||
.get("url")
|
.get("url")
|
||||||
.toString()
|
.toString()
|
||||||
));
|
));
|
||||||
@@ -112,7 +112,7 @@ public class ModrinthGetter
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return mcVerToReleaseID.get(mcVer).getFirst();
|
return mcVerToReleaseID.get(mcVer).get(0);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -121,17 +121,17 @@ public class ModrinthGetter
|
|||||||
}
|
}
|
||||||
public static String getLatestNameForVersion(String mcVer)
|
public static String getLatestNameForVersion(String mcVer)
|
||||||
{
|
{
|
||||||
return releaseNames.get(mcVerToReleaseID.get(mcVer).getFirst());
|
return releaseNames.get(mcVerToReleaseID.get(mcVer).get(0));
|
||||||
}
|
}
|
||||||
public static URL getLatestDownloadForVersion(String mcVer)
|
public static URL getLatestDownloadForVersion(String mcVer)
|
||||||
{
|
{
|
||||||
return downloadUrl.get(mcVerToReleaseID.get(mcVer).getFirst());
|
return downloadUrl.get(mcVerToReleaseID.get(mcVer).get(0));
|
||||||
}
|
}
|
||||||
public static String getLatestShaForVersion(String mcVer)
|
public static String getLatestShaForVersion(String mcVer)
|
||||||
{
|
{
|
||||||
return (((ArrayList<Config>) idToJson.get(
|
return (((ArrayList<Config>) idToJson.get(
|
||||||
mcVerToReleaseID.get(mcVer).getFirst()
|
mcVerToReleaseID.get(mcVer).get(0)
|
||||||
).get("files")).getFirst().get("hashes.sha1")
|
).get("files")).get(0).get("hashes.sha1")
|
||||||
.toString());
|
.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ public class SelfUpdater
|
|||||||
{
|
{
|
||||||
if (GitlabGetter.INSTANCE.projectPipelines.size() == 0)
|
if (GitlabGetter.INSTANCE.projectPipelines.size() == 0)
|
||||||
return false;
|
return false;
|
||||||
com.electronwill.nightconfig.core.Config pipeline = GitlabGetter.INSTANCE.projectPipelines.getFirst();
|
com.electronwill.nightconfig.core.Config pipeline = GitlabGetter.INSTANCE.projectPipelines.get(0);
|
||||||
|
|
||||||
if (!pipeline.get("ref").equals(ModJarInfo.Git_Branch))
|
if (!pipeline.get("ref").equals(ModJarInfo.Git_Branch))
|
||||||
{
|
{
|
||||||
@@ -186,13 +186,16 @@ public class SelfUpdater
|
|||||||
}
|
}
|
||||||
public static boolean updateMod(String minecraftVersion, File file)
|
public static boolean updateMod(String minecraftVersion, File file)
|
||||||
{
|
{
|
||||||
boolean returnValue = switch (Config.Client.Advanced.AutoUpdater.updateBranch.get())
|
boolean returnValue = false;
|
||||||
|
switch (Config.Client.Advanced.AutoUpdater.updateBranch.get())
|
||||||
{
|
{
|
||||||
case STABLE -> updateStableMod(minecraftVersion, file);
|
case STABLE:
|
||||||
case NIGHTLY -> updateNightlyMod(minecraftVersion, file);
|
returnValue = updateStableMod(minecraftVersion, file);
|
||||||
default -> false;
|
break;
|
||||||
|
case NIGHTLY:
|
||||||
|
returnValue = updateNightlyMod(minecraftVersion, file);
|
||||||
|
break;
|
||||||
};
|
};
|
||||||
;
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +253,7 @@ public class SelfUpdater
|
|||||||
|
|
||||||
File mergedZip = file.getParentFile().toPath().resolve("merged.zip").toFile();
|
File mergedZip = file.getParentFile().toPath().resolve("merged.zip").toFile();
|
||||||
|
|
||||||
WebDownloader.downloadAsFile(GitlabGetter.INSTANCE.getDownloads(GitlabGetter.INSTANCE.projectPipelines.getFirst().get("id")).get(minecraftVersion), mergedZip);
|
WebDownloader.downloadAsFile(GitlabGetter.INSTANCE.getDownloads(GitlabGetter.INSTANCE.projectPipelines.get(0).get("id")).get(minecraftVersion), mergedZip);
|
||||||
|
|
||||||
ZipInputStream zis = new ZipInputStream(new FileInputStream(mergedZip));
|
ZipInputStream zis = new ZipInputStream(new FileInputStream(mergedZip));
|
||||||
ZipEntry zipEntry = zis.getNextEntry();
|
ZipEntry zipEntry = zis.getNextEntry();
|
||||||
@@ -298,7 +301,7 @@ public class SelfUpdater
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
LOGGER.warn("Failed to update " + ModInfo.READABLE_NAME + " to version " + GitlabGetter.INSTANCE.projectPipelines.getFirst().get("sha"));
|
LOGGER.warn("Failed to update " + ModInfo.READABLE_NAME + " to version " + GitlabGetter.INSTANCE.projectPipelines.get(0).get("sha"));
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class ConfigBasedLogger
|
|||||||
|
|
||||||
|
|
||||||
public static final List<WeakReference<ConfigBasedLogger>> loggers
|
public static final List<WeakReference<ConfigBasedLogger>> loggers
|
||||||
= Collections.synchronizedList(new LinkedList<>());
|
= Collections.synchronizedList(new LinkedList<WeakReference<ConfigBasedLogger>>());
|
||||||
|
|
||||||
public static synchronized void updateAll()
|
public static synchronized void updateAll()
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -38,7 +38,7 @@ public class ConfigBasedSpamLogger
|
|||||||
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
|
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
|
||||||
|
|
||||||
public static final List<WeakReference<ConfigBasedSpamLogger>> loggers
|
public static final List<WeakReference<ConfigBasedSpamLogger>> loggers
|
||||||
= Collections.synchronizedList(new LinkedList<>());
|
= Collections.synchronizedList(new LinkedList<WeakReference<ConfigBasedSpamLogger>>());
|
||||||
|
|
||||||
public static synchronized void updateAll(boolean flush)
|
public static synchronized void updateAll(boolean flush)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class SpamReducedLogger
|
|||||||
private static final Logger LOGGER = LogManager.getLogger(MethodHandles.lookup().lookupClass().getSimpleName());
|
private static final Logger LOGGER = LogManager.getLogger(MethodHandles.lookup().lookupClass().getSimpleName());
|
||||||
|
|
||||||
public static final List<WeakReference<SpamReducedLogger>> loggers
|
public static final List<WeakReference<SpamReducedLogger>> loggers
|
||||||
= Collections.synchronizedList(new LinkedList<>());
|
= Collections.synchronizedList(new LinkedList<WeakReference<SpamReducedLogger>>());
|
||||||
|
|
||||||
public static synchronized void flushAll()
|
public static synchronized void flushAll()
|
||||||
{
|
{
|
||||||
@@ -53,7 +53,7 @@ public class SpamReducedLogger
|
|||||||
public SpamReducedLogger(int maxLogPerSec)
|
public SpamReducedLogger(int maxLogPerSec)
|
||||||
{
|
{
|
||||||
maxLogCount = maxLogPerSec;
|
maxLogCount = maxLogPerSec;
|
||||||
loggers.add(new WeakReference<>(this));
|
loggers.add(new WeakReference<SpamReducedLogger>(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset()
|
public void reset()
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
package com.seibel.distanthorizons.core.logging.f3;
|
package com.seibel.distanthorizons.core.logging.f3;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
||||||
|
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.SharedVbo;
|
||||||
import com.seibel.distanthorizons.core.level.IDhLevel;
|
import com.seibel.distanthorizons.core.level.IDhLevel;
|
||||||
import com.seibel.distanthorizons.core.render.RenderBufferHandler;
|
import com.seibel.distanthorizons.core.render.RenderBufferHandler;
|
||||||
import com.seibel.distanthorizons.core.render.renderer.generic.GenericObjectRenderer;
|
import com.seibel.distanthorizons.core.render.renderer.generic.GenericObjectRenderer;
|
||||||
@@ -111,6 +112,11 @@ public class F3Screen
|
|||||||
messageList.add(genericRenderer.getVboRenderDebugMenuString());
|
messageList.add(genericRenderer.getVboRenderDebugMenuString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
messageList.add("");
|
||||||
|
// GPU memory
|
||||||
|
messageList.add("GPU Opaque " + SharedVbo.OPAQUE.getDebugMenuString());
|
||||||
|
messageList.add("GPU Transp " + SharedVbo.TRANSPARENT.getDebugMenuString());
|
||||||
|
messageList.add("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -85,8 +85,9 @@ public class DhBlockPos2D
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
if (obj instanceof DhBlockPos2D other)
|
if (obj instanceof DhBlockPos2D)
|
||||||
{
|
{
|
||||||
|
DhBlockPos2D other = (DhBlockPos2D) obj;
|
||||||
return this.x == other.x && this.z == other.z;
|
return this.x == other.x && this.z == other.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.core.pos;
|
package com.seibel.distanthorizons.core.pos;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
|
|
||||||
import com.seibel.distanthorizons.core.enums.EDhDirection;
|
import com.seibel.distanthorizons.core.enums.EDhDirection;
|
||||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||||
import com.seibel.distanthorizons.coreapi.util.BitShiftUtil;
|
import com.seibel.distanthorizons.coreapi.util.BitShiftUtil;
|
||||||
@@ -102,32 +101,21 @@ public class DhSectionPos
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the section pos at the requested detail level containing the given BlockPos */
|
public static long encode(DhBlockPos pos) { return encodeBlockPos(pos.x, pos.z); }
|
||||||
public static long encodeContaining(byte outputSectionDetailLevel, DhBlockPos pos)
|
public static long encode(DhBlockPos2D pos) { return encodeBlockPos(pos.x, pos.z); }
|
||||||
|
public static long encodeBlockPos(int blockX, int blockZ)
|
||||||
{
|
{
|
||||||
int sectionPosX = getXOrZSectionPosFromChunkOrBlockPos(pos.x, false);
|
long pos = encode(LodUtil.BLOCK_DETAIL_LEVEL, blockX, blockZ);
|
||||||
int sectionPosZ = getXOrZSectionPosFromChunkOrBlockPos(pos.z, false);
|
pos = convertToDetailLevel(pos, DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL);
|
||||||
long blockPos = DhSectionPos.encode(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, sectionPosX, sectionPosZ);
|
return pos;
|
||||||
return convertToDetailLevel(blockPos, outputSectionDetailLevel);
|
|
||||||
}
|
}
|
||||||
/** Returns the section pos at the requested detail level containing the given ChunkPos */
|
|
||||||
public static long encodeContaining(byte outputSectionDetailLevel, DhChunkPos pos)
|
public static long encode(DhChunkPos pos) { return encodeChunkPos(pos.x, pos.z); }
|
||||||
|
public static long encodeChunkPos(int chunkX, int chunkZ)
|
||||||
{
|
{
|
||||||
int sectionPosX = getXOrZSectionPosFromChunkOrBlockPos(pos.x, true);
|
long pos = encode(LodUtil.CHUNK_DETAIL_LEVEL, chunkX, chunkZ);
|
||||||
int sectionPosZ = getXOrZSectionPosFromChunkOrBlockPos(pos.z, true);
|
pos = convertToDetailLevel(pos, DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL);
|
||||||
long blockPos = DhSectionPos.encode(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, sectionPosX, sectionPosZ);
|
return pos;
|
||||||
return convertToDetailLevel(blockPos, outputSectionDetailLevel);
|
|
||||||
}
|
|
||||||
private static int getXOrZSectionPosFromChunkOrBlockPos(int chunkXOrZPos, boolean isChunkPos)
|
|
||||||
{
|
|
||||||
int sectionPos = chunkXOrZPos;
|
|
||||||
int fullDataSourceWidth = isChunkPos ? FullDataSourceV2.NUMB_OF_CHUNKS_WIDE : (FullDataSourceV2.NUMB_OF_CHUNKS_WIDE * LodUtil.CHUNK_WIDTH);
|
|
||||||
|
|
||||||
// negative positions start at -1 so the logic there is slightly different
|
|
||||||
sectionPos = (sectionPos < 0)
|
|
||||||
? ((sectionPos + 1) / fullDataSourceWidth) - 1
|
|
||||||
: (sectionPos / fullDataSourceWidth);
|
|
||||||
return sectionPos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -80,8 +80,9 @@ public class Pos2D
|
|||||||
{
|
{
|
||||||
if (otherObj == this)
|
if (otherObj == this)
|
||||||
return true;
|
return true;
|
||||||
if (otherObj instanceof Pos2D otherPos)
|
if (otherObj instanceof Pos2D)
|
||||||
{
|
{
|
||||||
|
Pos2D otherPos = (Pos2D) otherObj;
|
||||||
return this.x == otherPos.x && this.y == otherPos.y;
|
return this.x == otherPos.x && this.y == otherPos.y;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import com.seibel.distanthorizons.core.pos.DhBlockPos2D;
|
|||||||
import com.seibel.distanthorizons.core.pos.DhSectionPos;
|
import com.seibel.distanthorizons.core.pos.DhSectionPos;
|
||||||
import com.seibel.distanthorizons.core.render.renderer.DebugRenderer;
|
import com.seibel.distanthorizons.core.render.renderer.DebugRenderer;
|
||||||
import com.seibel.distanthorizons.core.render.renderer.IDebugRenderable;
|
import com.seibel.distanthorizons.core.render.renderer.IDebugRenderable;
|
||||||
import com.seibel.distanthorizons.core.sql.repo.BeaconBeamRepo;
|
|
||||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||||
import com.seibel.distanthorizons.core.util.ThreadUtil;
|
import com.seibel.distanthorizons.core.util.ThreadUtil;
|
||||||
import com.seibel.distanthorizons.core.util.objects.quadTree.QuadNode;
|
import com.seibel.distanthorizons.core.util.objects.quadTree.QuadNode;
|
||||||
@@ -647,7 +646,7 @@ public class LodQuadTree extends QuadTree<LodRenderSection> implements IDebugRen
|
|||||||
}
|
}
|
||||||
else if (renderSection.renderBuffer.hasNonNullVbos())
|
else if (renderSection.renderBuffer.hasNonNullVbos())
|
||||||
{
|
{
|
||||||
if (renderSection.renderBuffer.vboBufferCount() != 0)
|
if (renderSection.renderBuffer.bufferSliceCount() != 0)
|
||||||
{
|
{
|
||||||
color = Color.GREEN;
|
color = Color.GREEN;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
LOGGER.warn("Unable to get render source " + DhSectionPos.toString(this.pos) + ", error: " + e.getMessage(), e);
|
LOGGER.warn("Unable to get render source " + this.pos + ", error: " + e.getMessage(), e);
|
||||||
this.renderSourceLoadingRefFuture = null;
|
this.renderSourceLoadingRefFuture = null;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-10
@@ -25,11 +25,13 @@ import com.seibel.distanthorizons.api.interfaces.override.rendering.IDhApiShadow
|
|||||||
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.ColumnRenderBuffer;
|
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.ColumnRenderBuffer;
|
||||||
|
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.SharedVbo;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.enums.EDhDirection;
|
import com.seibel.distanthorizons.core.enums.EDhDirection;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.logging.f3.F3Screen;
|
import com.seibel.distanthorizons.core.logging.f3.F3Screen;
|
||||||
|
import com.seibel.distanthorizons.core.pos.DhBlockPos;
|
||||||
import com.seibel.distanthorizons.core.pos.DhLodPos;
|
import com.seibel.distanthorizons.core.pos.DhLodPos;
|
||||||
import com.seibel.distanthorizons.core.pos.DhSectionPos;
|
import com.seibel.distanthorizons.core.pos.DhSectionPos;
|
||||||
import com.seibel.distanthorizons.core.pos.Pos2D;
|
import com.seibel.distanthorizons.core.pos.Pos2D;
|
||||||
@@ -48,9 +50,7 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.joml.Matrix4fc;
|
import org.joml.Matrix4fc;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.*;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.ListIterator;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -348,7 +348,11 @@ public class RenderBufferHandler implements AutoCloseable
|
|||||||
// TODO why can these sometimes be null when teleporting between multiverses
|
// TODO why can these sometimes be null when teleporting between multiverses
|
||||||
if (this.loadedNearToFarBuffers != null)
|
if (this.loadedNearToFarBuffers != null)
|
||||||
{
|
{
|
||||||
this.loadedNearToFarBuffers.forEach(loadedBuffer -> loadedBuffer.buffer.renderOpaque(renderContext, renderEventParam));
|
renderContext.setModelViewMatrixOffset(DhBlockPos.ZERO, renderEventParam);
|
||||||
|
|
||||||
|
ArrayList<SharedVbo.BufferSlice> sliceList = new ArrayList<>();
|
||||||
|
this.loadedNearToFarBuffers.forEach(loadedBuffer -> sliceList.addAll(Arrays.asList(loadedBuffer.buffer.opaqueBufferSlices)));
|
||||||
|
renderContext.drawSharedVbo(SharedVbo.OPAQUE, sliceList.toArray(new SharedVbo.BufferSlice[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void renderTransparent(LodRenderer renderContext, DhApiRenderParam renderEventParam)
|
public void renderTransparent(LodRenderer renderContext, DhApiRenderParam renderEventParam)
|
||||||
@@ -356,12 +360,11 @@ public class RenderBufferHandler implements AutoCloseable
|
|||||||
// TODO why can these sometimes be null when teleporting between multiverses
|
// TODO why can these sometimes be null when teleporting between multiverses
|
||||||
if (this.loadedNearToFarBuffers != null)
|
if (this.loadedNearToFarBuffers != null)
|
||||||
{
|
{
|
||||||
ListIterator<LoadedRenderBuffer> iter = this.loadedNearToFarBuffers.listIterator(this.loadedNearToFarBuffers.size());
|
renderContext.setModelViewMatrixOffset(DhBlockPos.ZERO, renderEventParam);
|
||||||
while (iter.hasPrevious())
|
|
||||||
{
|
ArrayList<SharedVbo.BufferSlice> sliceList = new ArrayList<>();
|
||||||
LoadedRenderBuffer loadedBuffer = iter.previous();
|
this.loadedNearToFarBuffers.forEach(loadedBuffer -> sliceList.addAll(Arrays.asList(loadedBuffer.buffer.transparentBufferSlices)));
|
||||||
loadedBuffer.buffer.renderTransparent(renderContext, renderEventParam);
|
renderContext.drawSharedVbo(SharedVbo.TRANSPARENT, sliceList.toArray(new SharedVbo.BufferSlice[0]));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -179,19 +179,15 @@ public class LodFogConfig
|
|||||||
|
|
||||||
if (farFogSetting == null)
|
if (farFogSetting == null)
|
||||||
{
|
{
|
||||||
str.append("""
|
str.append("\n" +
|
||||||
|
"float getFarFogThickness(float dist) { return 0.0; } \n" +
|
||||||
float getFarFogThickness(float dist) { return 0.0; }
|
"float getHeightFogThickness(float dist) { return 0.0; } \n" +
|
||||||
float getHeightFogThickness(float dist) { return 0.0; }
|
"float calculateFarFogDepth(float horizontal, float dist, float uNearFogStart) { return 0.0; } \n" +
|
||||||
float calculateFarFogDepth(float horizontal, float dist, float uNearFogStart) { return 0.0; }
|
"float calculateHeightFogDepth(float vertical, float realY) { return 0.0; } \n" +
|
||||||
float calculateHeightFogDepth(float vertical, float realY) { return 0.0; }
|
"float mixFogThickness(float near, float far, float height) \n" +
|
||||||
float mixFogThickness(float near, float far, float height)
|
"{ \n" +
|
||||||
{
|
" return 0.0; \n" +
|
||||||
return 0.0;
|
"} \n\n");
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
""");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -273,13 +269,18 @@ public class LodFogConfig
|
|||||||
|
|
||||||
private static String getFarFogMethod(EDhApiFogFalloff fogType)
|
private static String getFarFogMethod(EDhApiFogFalloff fogType)
|
||||||
{
|
{
|
||||||
return switch (fogType)
|
switch (fogType)
|
||||||
{
|
{
|
||||||
case LINEAR -> "return linearFog(dist, farFogStart, farFogLength, farFogMin, farFogRange);\n";
|
case LINEAR:
|
||||||
case EXPONENTIAL -> "return exponentialFog(dist, farFogStart, farFogLength, farFogMin, farFogRange, farFogDensity);\n";
|
return "return linearFog(dist, farFogStart, farFogLength, farFogMin, farFogRange);\n";
|
||||||
case EXPONENTIAL_SQUARED -> "return exponentialSquaredFog(dist, farFogStart, farFogLength, farFogMin, farFogRange, farFogDensity);\n";
|
case EXPONENTIAL:
|
||||||
default -> throw new IllegalArgumentException("FogType [" + fogType + "] not implemented for [getFarFogMethod].");
|
return "return exponentialFog(dist, farFogStart, farFogLength, farFogMin, farFogRange, farFogDensity);\n";
|
||||||
};
|
case EXPONENTIAL_SQUARED:
|
||||||
|
return "return exponentialSquaredFog(dist, farFogStart, farFogLength, farFogMin, farFogRange, farFogDensity);\n";
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("FogType [" + fogType + "] not implemented for [getFarFogMethod].");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getHeightDepthMethod(EDhApiHeightFogMode heightMode, float heightFogHeight)
|
private static String getHeightDepthMethod(EDhApiHeightFogMode heightMode, float heightFogHeight)
|
||||||
@@ -316,13 +317,18 @@ public class LodFogConfig
|
|||||||
*/
|
*/
|
||||||
private static String getHeightFogMethod(EDhApiFogFalloff fogType)
|
private static String getHeightFogMethod(EDhApiFogFalloff fogType)
|
||||||
{
|
{
|
||||||
return switch (fogType)
|
switch (fogType)
|
||||||
{
|
{
|
||||||
case LINEAR -> " return linearFog(dist, heightFogStart, heightFogLength, heightFogMin, heightFogRange);\n";
|
case LINEAR:
|
||||||
case EXPONENTIAL -> " return exponentialFog(dist, heightFogStart, heightFogLength, heightFogMin, heightFogRange, heightFogDensity);\n";
|
return " return linearFog(dist, heightFogStart, heightFogLength, heightFogMin, heightFogRange);\n";
|
||||||
case EXPONENTIAL_SQUARED -> " return exponentialSquaredFog(dist, heightFogStart, heightFogLength, heightFogMin, heightFogRange, heightFogDensity);\n";
|
case EXPONENTIAL:
|
||||||
default -> throw new IllegalArgumentException("FogType [" + fogType + "] not implemented for [getHeightFogMethod].");
|
return " return exponentialFog(dist, heightFogStart, heightFogLength, heightFogMin, heightFogRange, heightFogDensity);\n";
|
||||||
};
|
case EXPONENTIAL_SQUARED:
|
||||||
|
return " return exponentialSquaredFog(dist, heightFogStart, heightFogLength, heightFogMin, heightFogRange, heightFogDensity);\n";
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("FogType [" + fogType + "] not implemented for [getHeightFogMethod].");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,109 +27,213 @@ public class GLEnums
|
|||||||
|
|
||||||
public static String getString(int glEnum)
|
public static String getString(int glEnum)
|
||||||
{
|
{
|
||||||
return switch (glEnum)
|
// blend stuff
|
||||||
|
switch (glEnum)
|
||||||
{
|
{
|
||||||
// Zero
|
case GL_ZERO:
|
||||||
case GL_ZERO -> "GL_ZERO";
|
return "GL_ZERO";
|
||||||
|
case GL_ONE:
|
||||||
// blend stuff
|
return "GL_ONE";
|
||||||
case GL_ONE -> "GL_ONE";
|
case GL_SRC_COLOR:
|
||||||
case GL_SRC_COLOR -> "GL_SRC_COLOR";
|
return "GL_SRC_COLOR";
|
||||||
case GL_ONE_MINUS_SRC_COLOR -> "GL_ONE_MINUS_SRC_COLOR";
|
case GL_ONE_MINUS_SRC_COLOR:
|
||||||
case GL_DST_COLOR -> "GL_DST_COLOR";
|
return "GL_ONE_MINUS_SRC_COLOR";
|
||||||
case GL_ONE_MINUS_DST_COLOR -> "GL_ONE_MINUS_DST_COLOR";
|
case GL_DST_COLOR:
|
||||||
case GL_SRC_ALPHA -> "GL_SRC_ALPHA";
|
return "GL_DST_COLOR";
|
||||||
case GL_ONE_MINUS_SRC_ALPHA -> "GL_ONE_MINUS_SRC_ALPHA";
|
case GL_ONE_MINUS_DST_COLOR:
|
||||||
case GL_DST_ALPHA -> "GL_DST_ALPHA";
|
return "GL_ONE_MINUS_DST_COLOR";
|
||||||
case GL_ONE_MINUS_DST_ALPHA -> "GL_ONE_MINUS_DST_ALPHA";
|
case GL_SRC_ALPHA:
|
||||||
case GL_CONSTANT_COLOR -> "GL_CONSTANT_COLOR";
|
return "GL_SRC_ALPHA";
|
||||||
case GL_ONE_MINUS_CONSTANT_COLOR -> "GL_ONE_MINUS_CONSTANT_COLOR";
|
case GL_ONE_MINUS_SRC_ALPHA:
|
||||||
case GL_CONSTANT_ALPHA -> "GL_CONSTANT_ALPHA";
|
return "GL_ONE_MINUS_SRC_ALPHA";
|
||||||
case GL_ONE_MINUS_CONSTANT_ALPHA -> "GL_ONE_MINUS_CONSTANT_ALPHA";
|
case GL_DST_ALPHA:
|
||||||
|
return "GL_DST_ALPHA";
|
||||||
// shader stuff
|
case GL_ONE_MINUS_DST_ALPHA:
|
||||||
case GL_VERTEX_SHADER -> "GL_VERTEX_SHADER";
|
return "GL_ONE_MINUS_DST_ALPHA";
|
||||||
case GL_GEOMETRY_SHADER -> "GL_GEOMETRY_SHADER";
|
case GL_CONSTANT_COLOR:
|
||||||
case GL_FRAGMENT_SHADER -> "GL_FRAGMENT_SHADER";
|
return "GL_CONSTANT_COLOR";
|
||||||
|
case GL_ONE_MINUS_CONSTANT_COLOR:
|
||||||
// stencil stuff
|
return "GL_ONE_MINUS_CONSTANT_COLOR";
|
||||||
case GL_KEEP -> "GL_KEEP";
|
case GL_CONSTANT_ALPHA:
|
||||||
case GL_REPLACE -> "GL_REPLACE";
|
return "GL_CONSTANT_ALPHA";
|
||||||
case GL_INCR -> "GL_INCR";
|
case GL_ONE_MINUS_CONSTANT_ALPHA:
|
||||||
case GL_DECR -> "GL_DECR";
|
return "GL_ONE_MINUS_CONSTANT_ALPHA";
|
||||||
case GL_INVERT -> "GL_INVERT";
|
default:
|
||||||
case GL_INCR_WRAP -> "GL_INCR_WRAP";
|
}
|
||||||
case GL_DECR_WRAP -> "GL_DECR_WRAP";
|
|
||||||
|
// shader stuff
|
||||||
// depth stuff
|
switch (glEnum)
|
||||||
case GL_NEVER -> "GL_NEVER";
|
{
|
||||||
case GL_LESS -> "GL_LESS";
|
case GL_VERTEX_SHADER:
|
||||||
case GL_EQUAL -> "GL_EQUAL";
|
return "GL_VERTEX_SHADER";
|
||||||
case GL_LEQUAL -> "GL_LEQUAL";
|
case GL_GEOMETRY_SHADER:
|
||||||
case GL_GREATER -> "GL_GREATER";
|
return "GL_GEOMETRY_SHADER";
|
||||||
case GL_NOTEQUAL -> "GL_NOTEQUAL";
|
case GL_FRAGMENT_SHADER:
|
||||||
case GL_GEQUAL -> "GL_GEQUAL";
|
return "GL_FRAGMENT_SHADER";
|
||||||
case GL_ALWAYS -> "GL_ALWAYS";
|
default:
|
||||||
|
}
|
||||||
// Texture binding points
|
|
||||||
case GL_TEXTURE0 -> "GL_TEXTURE0";
|
// stencil stuff
|
||||||
case GL_TEXTURE1 -> "GL_TEXTURE1";
|
switch (glEnum)
|
||||||
case GL_TEXTURE2 -> "GL_TEXTURE2";
|
{
|
||||||
case GL_TEXTURE3 -> "GL_TEXTURE3";
|
case GL_KEEP:
|
||||||
case GL_TEXTURE4 -> "GL_TEXTURE4";
|
return "GL_KEEP";
|
||||||
case GL_TEXTURE5 -> "GL_TEXTURE5";
|
case GL_ZERO:
|
||||||
case GL_TEXTURE6 -> "GL_TEXTURE6";
|
return "GL_ZERO";
|
||||||
case GL_TEXTURE7 -> "GL_TEXTURE7";
|
case GL_REPLACE:
|
||||||
case GL_TEXTURE8 -> "GL_TEXTURE8";
|
return "GL_REPLACE";
|
||||||
case GL_TEXTURE9 -> "GL_TEXTURE9";
|
case GL_INCR:
|
||||||
case GL_TEXTURE10 -> "GL_TEXTURE10";
|
return "GL_INCR";
|
||||||
case GL_TEXTURE11 -> "GL_TEXTURE11";
|
case GL_DECR:
|
||||||
case GL_TEXTURE12 -> "GL_TEXTURE12";
|
return "GL_DECR";
|
||||||
case GL_TEXTURE13 -> "GL_TEXTURE13";
|
case GL_INVERT:
|
||||||
case GL_TEXTURE14 -> "GL_TEXTURE14";
|
return "GL_INVERT";
|
||||||
case GL_TEXTURE15 -> "GL_TEXTURE15";
|
case GL_INCR_WRAP:
|
||||||
case GL_TEXTURE16 -> "GL_TEXTURE16";
|
return "GL_INCR_WRAP";
|
||||||
case GL_TEXTURE17 -> "GL_TEXTURE17";
|
case GL_DECR_WRAP:
|
||||||
case GL_TEXTURE18 -> "GL_TEXTURE18";
|
return "GL_DECR_WRAP";
|
||||||
case GL_TEXTURE19 -> "GL_TEXTURE19";
|
default:
|
||||||
case GL_TEXTURE20 -> "GL_TEXTURE20";
|
}
|
||||||
case GL_TEXTURE21 -> "GL_TEXTURE21";
|
|
||||||
case GL_TEXTURE22 -> "GL_TEXTURE22";
|
// depth stuff
|
||||||
case GL_TEXTURE23 -> "GL_TEXTURE23";
|
switch (glEnum)
|
||||||
case GL_TEXTURE24 -> "GL_TEXTURE24";
|
{
|
||||||
case GL_TEXTURE25 -> "GL_TEXTURE25";
|
case GL_NEVER:
|
||||||
case GL_TEXTURE26 -> "GL_TEXTURE26";
|
return "GL_NEVER";
|
||||||
case GL_TEXTURE27 -> "GL_TEXTURE27";
|
case GL_LESS:
|
||||||
case GL_TEXTURE28 -> "GL_TEXTURE28";
|
return "GL_LESS";
|
||||||
case GL_TEXTURE29 -> "GL_TEXTURE29";
|
case GL_EQUAL:
|
||||||
case GL_TEXTURE30 -> "GL_TEXTURE30";
|
return "GL_EQUAL";
|
||||||
case GL_TEXTURE31 -> "GL_TEXTURE31";
|
case GL_LEQUAL:
|
||||||
|
return "GL_LEQUAL";
|
||||||
|
case GL_GREATER:
|
||||||
// Polygon modes
|
return "GL_GREATER";
|
||||||
case GL_POINT -> "GL_POINT";
|
case GL_NOTEQUAL:
|
||||||
case GL_LINE -> "GL_LINE";
|
return "GL_NOTEQUAL";
|
||||||
case GL_FILL -> "GL_FILL";
|
case GL_GEQUAL:
|
||||||
|
return "GL_GEQUAL";
|
||||||
// Culling modes
|
case GL_ALWAYS:
|
||||||
case GL_FRONT -> "GL_FRONT";
|
return "GL_ALWAYS";
|
||||||
case GL_BACK -> "GL_BACK";
|
default:
|
||||||
case GL_FRONT_AND_BACK -> "GL_FRONT_AND_BACK";
|
}
|
||||||
default -> "GL_UNKNOWN(" + glEnum + ")";
|
|
||||||
};
|
// Texture binding points
|
||||||
|
switch (glEnum)
|
||||||
|
{
|
||||||
|
case GL_TEXTURE0:
|
||||||
|
return "GL_TEXTURE0";
|
||||||
|
case GL_TEXTURE1:
|
||||||
|
return "GL_TEXTURE1";
|
||||||
|
case GL_TEXTURE2:
|
||||||
|
return "GL_TEXTURE2";
|
||||||
|
case GL_TEXTURE3:
|
||||||
|
return "GL_TEXTURE3";
|
||||||
|
case GL_TEXTURE4:
|
||||||
|
return "GL_TEXTURE4";
|
||||||
|
case GL_TEXTURE5:
|
||||||
|
return "GL_TEXTURE5";
|
||||||
|
case GL_TEXTURE6:
|
||||||
|
return "GL_TEXTURE6";
|
||||||
|
case GL_TEXTURE7:
|
||||||
|
return "GL_TEXTURE7";
|
||||||
|
case GL_TEXTURE8:
|
||||||
|
return "GL_TEXTURE8";
|
||||||
|
case GL_TEXTURE9:
|
||||||
|
return "GL_TEXTURE9";
|
||||||
|
case GL_TEXTURE10:
|
||||||
|
return "GL_TEXTURE10";
|
||||||
|
case GL_TEXTURE11:
|
||||||
|
return "GL_TEXTURE11";
|
||||||
|
case GL_TEXTURE12:
|
||||||
|
return "GL_TEXTURE12";
|
||||||
|
case GL_TEXTURE13:
|
||||||
|
return "GL_TEXTURE13";
|
||||||
|
case GL_TEXTURE14:
|
||||||
|
return "GL_TEXTURE14";
|
||||||
|
case GL_TEXTURE15:
|
||||||
|
return "GL_TEXTURE15";
|
||||||
|
case GL_TEXTURE16:
|
||||||
|
return "GL_TEXTURE16";
|
||||||
|
case GL_TEXTURE17:
|
||||||
|
return "GL_TEXTURE17";
|
||||||
|
case GL_TEXTURE18:
|
||||||
|
return "GL_TEXTURE18";
|
||||||
|
case GL_TEXTURE19:
|
||||||
|
return "GL_TEXTURE19";
|
||||||
|
case GL_TEXTURE20:
|
||||||
|
return "GL_TEXTURE20";
|
||||||
|
case GL_TEXTURE21:
|
||||||
|
return "GL_TEXTURE21";
|
||||||
|
case GL_TEXTURE22:
|
||||||
|
return "GL_TEXTURE22";
|
||||||
|
case GL_TEXTURE23:
|
||||||
|
return "GL_TEXTURE23";
|
||||||
|
case GL_TEXTURE24:
|
||||||
|
return "GL_TEXTURE24";
|
||||||
|
case GL_TEXTURE25:
|
||||||
|
return "GL_TEXTURE25";
|
||||||
|
case GL_TEXTURE26:
|
||||||
|
return "GL_TEXTURE26";
|
||||||
|
case GL_TEXTURE27:
|
||||||
|
return "GL_TEXTURE27";
|
||||||
|
case GL_TEXTURE28:
|
||||||
|
return "GL_TEXTURE28";
|
||||||
|
case GL_TEXTURE29:
|
||||||
|
return "GL_TEXTURE29";
|
||||||
|
case GL_TEXTURE30:
|
||||||
|
return "GL_TEXTURE30";
|
||||||
|
case GL_TEXTURE31:
|
||||||
|
return "GL_TEXTURE31";
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
// Polygon modes
|
||||||
|
switch (glEnum)
|
||||||
|
{
|
||||||
|
case GL_POINT:
|
||||||
|
return "GL_POINT";
|
||||||
|
case GL_LINE:
|
||||||
|
return "GL_LINE";
|
||||||
|
case GL_FILL:
|
||||||
|
return "GL_FILL";
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
// Culling modes
|
||||||
|
switch (glEnum)
|
||||||
|
{
|
||||||
|
case GL_FRONT:
|
||||||
|
return "GL_FRONT";
|
||||||
|
case GL_BACK:
|
||||||
|
return "GL_BACK";
|
||||||
|
case GL_FRONT_AND_BACK:
|
||||||
|
return "GL_FRONT_AND_BACK";
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
return "GL_UNKNOWN(" + glEnum + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getTypeSize(int glTypeEnum)
|
public static int getTypeSize(int glTypeEnum)
|
||||||
{
|
{
|
||||||
return switch (glTypeEnum)
|
switch (glTypeEnum)
|
||||||
{
|
{
|
||||||
case GL_BYTE, GL_UNSIGNED_BYTE -> 1;
|
case GL_BYTE:
|
||||||
case GL_SHORT, GL_UNSIGNED_SHORT -> 2;
|
case GL_UNSIGNED_BYTE:
|
||||||
case GL_INT, GL_UNSIGNED_INT -> 4;
|
return 1;
|
||||||
case GL_FLOAT -> 4;
|
case GL_SHORT:
|
||||||
case GL_DOUBLE -> 8;
|
case GL_UNSIGNED_SHORT:
|
||||||
default -> throw new IllegalArgumentException("Unknown type enum: " + getString(glTypeEnum));
|
return 2;
|
||||||
};
|
case GL_INT:
|
||||||
|
case GL_UNSIGNED_INT:
|
||||||
|
return 4;
|
||||||
|
case GL_FLOAT:
|
||||||
|
return 4;
|
||||||
|
case GL_DOUBLE:
|
||||||
|
return 8;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Unknown type enum: " + getString(glTypeEnum));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+1
-1
@@ -70,7 +70,7 @@ public class GLBuffer implements AutoCloseable
|
|||||||
// constructors //
|
// constructors //
|
||||||
//==============//
|
//==============//
|
||||||
|
|
||||||
static { CLEANUP_THREAD.execute(GLBuffer::runPhantomReferenceCleanupLoop); }
|
static { CLEANUP_THREAD.execute(() -> runPhantomReferenceCleanupLoop()); }
|
||||||
|
|
||||||
public GLBuffer(boolean isBufferStorage) { this.create(isBufferStorage); }
|
public GLBuffer(boolean isBufferStorage) { this.create(isBufferStorage); }
|
||||||
|
|
||||||
|
|||||||
+64
-34
@@ -4,8 +4,6 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.lwjgl.opengl.GL30C;
|
import org.lwjgl.opengl.GL30C;
|
||||||
import org.lwjgl.opengl.GL43C;
|
import org.lwjgl.opengl.GL43C;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public enum EDhDepthBufferFormat
|
public enum EDhDepthBufferFormat
|
||||||
{
|
{
|
||||||
DEPTH(false),
|
DEPTH(false),
|
||||||
@@ -28,56 +26,88 @@ public enum EDhDepthBufferFormat
|
|||||||
@Nullable
|
@Nullable
|
||||||
public static EDhDepthBufferFormat fromGlEnum(int glenum)
|
public static EDhDepthBufferFormat fromGlEnum(int glenum)
|
||||||
{
|
{
|
||||||
return switch (glenum)
|
switch (glenum)
|
||||||
{
|
{
|
||||||
case GL30C.GL_DEPTH_COMPONENT -> EDhDepthBufferFormat.DEPTH;
|
case GL30C.GL_DEPTH_COMPONENT:
|
||||||
case GL30C.GL_DEPTH_COMPONENT16 -> EDhDepthBufferFormat.DEPTH16;
|
return EDhDepthBufferFormat.DEPTH;
|
||||||
case GL30C.GL_DEPTH_COMPONENT24 -> EDhDepthBufferFormat.DEPTH24;
|
case GL30C.GL_DEPTH_COMPONENT16:
|
||||||
case GL30C.GL_DEPTH_COMPONENT32 -> EDhDepthBufferFormat.DEPTH32;
|
return EDhDepthBufferFormat.DEPTH16;
|
||||||
case GL30C.GL_DEPTH_COMPONENT32F -> EDhDepthBufferFormat.DEPTH32F;
|
case GL30C.GL_DEPTH_COMPONENT24:
|
||||||
case GL30C.GL_DEPTH_STENCIL -> EDhDepthBufferFormat.DEPTH_STENCIL;
|
return EDhDepthBufferFormat.DEPTH24;
|
||||||
case GL30C.GL_DEPTH24_STENCIL8 -> EDhDepthBufferFormat.DEPTH24_STENCIL8;
|
case GL30C.GL_DEPTH_COMPONENT32:
|
||||||
case GL30C.GL_DEPTH32F_STENCIL8 -> EDhDepthBufferFormat.DEPTH32F_STENCIL8;
|
return EDhDepthBufferFormat.DEPTH32;
|
||||||
default -> null;
|
case GL30C.GL_DEPTH_COMPONENT32F:
|
||||||
};
|
return EDhDepthBufferFormat.DEPTH32F;
|
||||||
|
case GL30C.GL_DEPTH_STENCIL:
|
||||||
|
return EDhDepthBufferFormat.DEPTH_STENCIL;
|
||||||
|
case GL30C.GL_DEPTH24_STENCIL8:
|
||||||
|
return EDhDepthBufferFormat.DEPTH24_STENCIL8;
|
||||||
|
case GL30C.GL_DEPTH32F_STENCIL8:
|
||||||
|
return EDhDepthBufferFormat.DEPTH32F_STENCIL8;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EDhDepthBufferFormat fromGlEnumOrDefault(int glenum)
|
public static EDhDepthBufferFormat fromGlEnumOrDefault(int glenum)
|
||||||
{
|
{
|
||||||
EDhDepthBufferFormat format = fromGlEnum(glenum);
|
EDhDepthBufferFormat format = fromGlEnum(glenum);
|
||||||
// yolo, just assume it's GL_DEPTH_COMPONENT
|
if (format == null)
|
||||||
return Objects.requireNonNullElse(format, EDhDepthBufferFormat.DEPTH);
|
{
|
||||||
|
// yolo, just assume it's GL_DEPTH_COMPONENT
|
||||||
|
return EDhDepthBufferFormat.DEPTH;
|
||||||
|
}
|
||||||
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getGlInternalFormat()
|
public int getGlInternalFormat()
|
||||||
{
|
{
|
||||||
return switch (this)
|
switch (this)
|
||||||
{
|
{
|
||||||
case DEPTH -> GL30C.GL_DEPTH_COMPONENT;
|
case DEPTH:
|
||||||
case DEPTH16 -> GL30C.GL_DEPTH_COMPONENT16;
|
return GL30C.GL_DEPTH_COMPONENT;
|
||||||
case DEPTH24 -> GL30C.GL_DEPTH_COMPONENT24;
|
case DEPTH16:
|
||||||
case DEPTH32 -> GL30C.GL_DEPTH_COMPONENT32;
|
return GL30C.GL_DEPTH_COMPONENT16;
|
||||||
case DEPTH32F -> GL30C.GL_DEPTH_COMPONENT32F;
|
case DEPTH24:
|
||||||
case DEPTH_STENCIL -> GL30C.GL_DEPTH_STENCIL;
|
return GL30C.GL_DEPTH_COMPONENT24;
|
||||||
case DEPTH24_STENCIL8 -> GL30C.GL_DEPTH24_STENCIL8;
|
case DEPTH32:
|
||||||
case DEPTH32F_STENCIL8 -> GL30C.GL_DEPTH32F_STENCIL8;
|
return GL30C.GL_DEPTH_COMPONENT32;
|
||||||
};
|
case DEPTH32F:
|
||||||
|
return GL30C.GL_DEPTH_COMPONENT32F;
|
||||||
|
case DEPTH_STENCIL:
|
||||||
|
return GL30C.GL_DEPTH_STENCIL;
|
||||||
|
case DEPTH24_STENCIL8:
|
||||||
|
return GL30C.GL_DEPTH24_STENCIL8;
|
||||||
|
case DEPTH32F_STENCIL8:
|
||||||
|
return GL30C.GL_DEPTH32F_STENCIL8;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new AssertionError("unreachable");
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getGlType() { return isCombinedStencil() ? GL30C.GL_DEPTH_STENCIL : GL30C.GL_DEPTH_COMPONENT; }
|
public int getGlType() { return isCombinedStencil() ? GL30C.GL_DEPTH_STENCIL : GL30C.GL_DEPTH_COMPONENT; }
|
||||||
|
|
||||||
public int getGlFormat()
|
public int getGlFormat()
|
||||||
{
|
{
|
||||||
return switch (this) {
|
switch (this)
|
||||||
case DEPTH, DEPTH16 -> GL43C.GL_UNSIGNED_SHORT;
|
{
|
||||||
case DEPTH24, DEPTH32 -> GL43C.GL_UNSIGNED_INT;
|
case DEPTH:
|
||||||
case DEPTH32F -> GL30C.GL_FLOAT;
|
case DEPTH16:
|
||||||
case DEPTH_STENCIL, DEPTH24_STENCIL8 -> GL30C.GL_UNSIGNED_INT_24_8;
|
return GL43C.GL_UNSIGNED_SHORT;
|
||||||
case DEPTH32F_STENCIL8 -> GL30C.GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
|
case DEPTH24:
|
||||||
};
|
case DEPTH32:
|
||||||
|
return GL43C.GL_UNSIGNED_INT;
|
||||||
}
|
case DEPTH32F:
|
||||||
|
return GL30C.GL_FLOAT;
|
||||||
|
case DEPTH_STENCIL:
|
||||||
|
case DEPTH24_STENCIL8:
|
||||||
|
return GL30C.GL_UNSIGNED_INT_24_8;
|
||||||
|
case DEPTH32F_STENCIL8:
|
||||||
|
return GL30C.GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new AssertionError("unreachable");
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isCombinedStencil() { return combinedStencil; }
|
public boolean isCombinedStencil() { return combinedStencil; }
|
||||||
|
|
||||||
|
|||||||
+52
-23
@@ -25,6 +25,7 @@ import com.seibel.distanthorizons.api.interfaces.override.rendering.IDhApiShader
|
|||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.*;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.*;
|
||||||
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
|
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.SharedVbo;
|
||||||
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.ColumnRenderBuffer;
|
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.ColumnRenderBuffer;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
@@ -35,11 +36,11 @@ import com.seibel.distanthorizons.core.render.DhApiRenderProxy;
|
|||||||
import com.seibel.distanthorizons.core.render.RenderBufferHandler;
|
import com.seibel.distanthorizons.core.render.RenderBufferHandler;
|
||||||
import com.seibel.distanthorizons.core.render.glObject.GLProxy;
|
import com.seibel.distanthorizons.core.render.glObject.GLProxy;
|
||||||
import com.seibel.distanthorizons.core.render.glObject.GLState;
|
import com.seibel.distanthorizons.core.render.glObject.GLState;
|
||||||
import com.seibel.distanthorizons.core.render.glObject.buffer.GLVertexBuffer;
|
|
||||||
import com.seibel.distanthorizons.core.render.glObject.buffer.QuadElementBuffer;
|
import com.seibel.distanthorizons.core.render.glObject.buffer.QuadElementBuffer;
|
||||||
import com.seibel.distanthorizons.core.render.glObject.texture.*;
|
import com.seibel.distanthorizons.core.render.glObject.texture.*;
|
||||||
import com.seibel.distanthorizons.core.render.renderer.generic.GenericObjectRenderer;
|
import com.seibel.distanthorizons.core.render.renderer.generic.GenericObjectRenderer;
|
||||||
import com.seibel.distanthorizons.core.render.renderer.shaders.*;
|
import com.seibel.distanthorizons.core.render.renderer.shaders.*;
|
||||||
|
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IProfilerWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IProfilerWrapper;
|
||||||
@@ -54,10 +55,13 @@ import com.seibel.distanthorizons.coreapi.DependencyInjection.OverrideInjector;
|
|||||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||||
import com.seibel.distanthorizons.core.util.math.Vec3d;
|
import com.seibel.distanthorizons.core.util.math.Vec3d;
|
||||||
import com.seibel.distanthorizons.core.util.math.Vec3f;
|
import com.seibel.distanthorizons.core.util.math.Vec3f;
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.lwjgl.PointerBuffer;
|
||||||
import org.lwjgl.opengl.GL32;
|
import org.lwjgl.opengl.GL32;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.nio.IntBuffer;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
@@ -301,8 +305,11 @@ public class LodRenderer
|
|||||||
// terrain
|
// terrain
|
||||||
profiler.popPush("LOD Opaque");
|
profiler.popPush("LOD Opaque");
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam);
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam);
|
||||||
|
|
||||||
this.bufferHandler.renderOpaque(this, renderEventParam);
|
this.bufferHandler.renderOpaque(this, renderEventParam);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// custom objects with SSAO
|
// custom objects with SSAO
|
||||||
if (Config.Client.Advanced.Graphics.GenericRendering.enableRendering.get())
|
if (Config.Client.Advanced.Graphics.GenericRendering.enableRendering.get())
|
||||||
{
|
{
|
||||||
@@ -466,6 +473,7 @@ public class LodRenderer
|
|||||||
GL32.glBlendEquation(GL32.GL_FUNC_ADD);
|
GL32.glBlendEquation(GL32.GL_FUNC_ADD);
|
||||||
GL32.glBlendFuncSeparate(GL32.GL_SRC_ALPHA, GL32.GL_ONE_MINUS_SRC_ALPHA, GL32.GL_ONE, GL32.GL_ONE_MINUS_SRC_ALPHA);
|
GL32.glBlendFuncSeparate(GL32.GL_SRC_ALPHA, GL32.GL_ONE_MINUS_SRC_ALPHA, GL32.GL_ONE, GL32.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam);
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam);
|
||||||
|
|
||||||
this.bufferHandler.renderTransparent(this, renderEventParam);
|
this.bufferHandler.renderTransparent(this, renderEventParam);
|
||||||
GL32.glDepthMask(true); // Apparently the depth mask state is stored in the FBO, so glState fails to restore it...
|
GL32.glDepthMask(true); // Apparently the depth mask state is stored in the FBO, so glState fails to restore it...
|
||||||
|
|
||||||
@@ -485,37 +493,58 @@ public class LodRenderer
|
|||||||
shaderProgram = shaderProgramOverride;
|
shaderProgram = shaderProgramOverride;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!GL32.glIsProgram(shaderProgram.getId()))
|
||||||
|
{
|
||||||
|
throw new IllegalStateException("No GL program exists with the ID: [" + shaderProgram.getId() + "]. This either means a shader program was freed while it was still in use or was never created.");
|
||||||
|
}
|
||||||
|
|
||||||
shaderProgram.bind();
|
shaderProgram.bind();
|
||||||
shaderProgram.setModelOffsetPos(modelPos);
|
shaderProgram.setModelOffsetPos(modelPos);
|
||||||
|
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeBufferRenderEvent.class, new DhApiBeforeBufferRenderEvent.EventParam(renderEventParam, modelPos));
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeBufferRenderEvent.class, new DhApiBeforeBufferRenderEvent.EventParam(renderEventParam, modelPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawVbo(GLVertexBuffer vbo)
|
public void drawSharedVbo(SharedVbo sharedVbo, SharedVbo.BufferSlice[] slices)
|
||||||
{
|
{
|
||||||
//// can be uncommented to add additional debug validation to prevent crashes if invalid buffers are being created
|
IDhApiShaderProgram shaderProgram = this.lodRenderProgram;
|
||||||
//// shouldn't be used in production due to the performance hit
|
IDhApiShaderProgram shaderProgramOverride = OverrideInjector.INSTANCE.get(IDhApiShaderProgram.class);
|
||||||
//if (GL32.glIsBuffer(vbo.getId()))
|
if (shaderProgramOverride != null && shaderProgram.overrideThisFrame())
|
||||||
{
|
{
|
||||||
IDhApiShaderProgram shaderProgram = this.lodRenderProgram;
|
shaderProgram = shaderProgramOverride;
|
||||||
IDhApiShaderProgram shaderProgramOverride = OverrideInjector.INSTANCE.get(IDhApiShaderProgram.class);
|
|
||||||
if (shaderProgramOverride != null && shaderProgram.overrideThisFrame())
|
|
||||||
{
|
|
||||||
shaderProgram = shaderProgramOverride;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
vbo.bind();
|
|
||||||
shaderProgram.bindVertexBuffer(vbo.getId());
|
|
||||||
GL32.glDrawElements(GL32.GL_TRIANGLES, (vbo.getVertexCount() / 4) * 6, // TODO what does the 4 and 6 here represent?
|
|
||||||
this.quadIBO.getType(), 0);
|
|
||||||
vbo.unbind();
|
|
||||||
}
|
}
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// // will spam the log if uncommented, but helpful for validation
|
sharedVbo.bind();
|
||||||
// //LOGGER.warn("Unable to draw VBO: "+vbo.getId());
|
shaderProgram.bindVertexBuffer(sharedVbo.vboId);
|
||||||
//}
|
|
||||||
|
IntArrayList countList = new IntArrayList();
|
||||||
|
IntArrayList baseVertexList = new IntArrayList();
|
||||||
|
for (int i = 0; i < slices.length; i++)
|
||||||
|
{
|
||||||
|
SharedVbo.BufferSlice slice = slices[i];
|
||||||
|
if (slice != null && slice.vertexCount != 0)
|
||||||
|
{
|
||||||
|
countList.add((slice.vertexCount / 4) * 6); // 4 vertices per quad, 6 indices per quad
|
||||||
|
baseVertexList.add((int)slice.startIndex / LodUtil.LOD_VERTEX_FORMAT.getByteSize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] counts = countList.toIntArray();
|
||||||
|
PointerBuffer iboIndicies = PointerBuffer.allocateDirect(counts.length);
|
||||||
|
for (int i = 0; i < counts.length; i++)
|
||||||
|
{
|
||||||
|
iboIndicies.put(0L);
|
||||||
|
}
|
||||||
|
iboIndicies.rewind();
|
||||||
|
int[] baseVertecies = baseVertexList.toIntArray();
|
||||||
|
|
||||||
|
|
||||||
|
if (counts.length != 0)
|
||||||
|
{
|
||||||
|
GL32.glMultiDrawElementsBaseVertex(GL32.GL_TRIANGLES, counts, this.quadIBO.getType(), iboIndicies, baseVertecies);
|
||||||
|
}
|
||||||
|
|
||||||
|
sharedVbo.unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+7
-6
@@ -308,8 +308,8 @@ public class GenericObjectRenderer implements IDhApiCustomRenderRegister
|
|||||||
{
|
{
|
||||||
blockPos.y = 140f;
|
blockPos.y = 140f;
|
||||||
|
|
||||||
Color newColor = (massRelativePosBoxGroup.getFirst().color == Color.RED) ? Color.RED.darker() : Color.RED;
|
Color newColor = (massRelativePosBoxGroup.get(0).color == Color.RED) ? Color.RED.darker() : Color.RED;
|
||||||
massRelativePosBoxGroup.forEach((box) -> box.color = newColor);
|
massRelativePosBoxGroup.forEach((box) -> { box.color = newColor; });
|
||||||
massRelativePosBoxGroup.triggerBoxChange();
|
massRelativePosBoxGroup.triggerBoxChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,13 +327,14 @@ public class GenericObjectRenderer implements IDhApiCustomRenderRegister
|
|||||||
@Override
|
@Override
|
||||||
public void add(IDhApiRenderableBoxGroup iBoxGroup) throws IllegalArgumentException
|
public void add(IDhApiRenderableBoxGroup iBoxGroup) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if (!(iBoxGroup instanceof RenderableBoxGroup boxGroup))
|
if (!(iBoxGroup instanceof RenderableBoxGroup))
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("Box group must be of type ["+ RenderableBoxGroup.class.getSimpleName()+"], type received: ["+(iBoxGroup != null ? iBoxGroup.getClass() : "NULL")+"].");
|
throw new IllegalArgumentException("Box group must be of type ["+ RenderableBoxGroup.class.getSimpleName()+"], type received: ["+(iBoxGroup != null ? iBoxGroup.getClass() : "NULL")+"].");
|
||||||
}
|
}
|
||||||
|
RenderableBoxGroup boxGroup = (RenderableBoxGroup) iBoxGroup;
|
||||||
|
|
||||||
long id = boxGroup.getId();
|
|
||||||
|
long id = boxGroup.getId();
|
||||||
if (this.boxGroupById.containsKey(id))
|
if (this.boxGroupById.containsKey(id))
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("A box group with the ID [" + id + "] is already present.");
|
throw new IllegalArgumentException("A box group with the ID [" + id + "] is already present.");
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ public abstract class AbstractDhRepo<TKey, TDTO extends IBaseDTO<TKey>> implemen
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<Map<String, Object>> objectList = this.query(sql);
|
List<Map<String, Object>> objectList = this.query(sql);
|
||||||
return !objectList.isEmpty() ? objectList.getFirst() : null;
|
return !objectList.isEmpty() ? objectList.get(0) : null;
|
||||||
}
|
}
|
||||||
catch (DbConnectionClosedException e)
|
catch (DbConnectionClosedException e)
|
||||||
{
|
{
|
||||||
@@ -512,7 +512,7 @@ public abstract class AbstractDhRepo<TKey, TDTO extends IBaseDTO<TKey>> implemen
|
|||||||
for (int columnIndex = 1; columnIndex <= resultColumnCount; columnIndex++) // column indices start at 1
|
for (int columnIndex = 1; columnIndex <= resultColumnCount; columnIndex++) // column indices start at 1
|
||||||
{
|
{
|
||||||
String columnName = resultMetaData.getColumnName(columnIndex);
|
String columnName = resultMetaData.getColumnName(columnIndex);
|
||||||
if (columnName == null || columnName.isEmpty())
|
if (columnName == null || columnName.equals(""))
|
||||||
{
|
{
|
||||||
throw new RuntimeException("SQL result set is missing a column name for column ["+resultMetaData.getTableName(columnIndex)+"."+columnIndex+"].");
|
throw new RuntimeException("SQL result set is missing a column name for column ["+resultMetaData.getTableName(columnIndex)+"."+columnIndex+"].");
|
||||||
}
|
}
|
||||||
@@ -521,13 +521,22 @@ public abstract class AbstractDhRepo<TKey, TDTO extends IBaseDTO<TKey>> implemen
|
|||||||
// some values need explicit conversion
|
// some values need explicit conversion
|
||||||
// Example: Long values that are within the bounds of an int would automatically be incorrectly returned as "Integer" objects
|
// Example: Long values that are within the bounds of an int would automatically be incorrectly returned as "Integer" objects
|
||||||
String columnType = resultMetaData.getColumnTypeName(columnIndex).toUpperCase();
|
String columnType = resultMetaData.getColumnTypeName(columnIndex).toUpperCase();
|
||||||
Object columnValue = switch (columnType)
|
Object columnValue;
|
||||||
|
switch (columnType)
|
||||||
{
|
{
|
||||||
case "BIGINT" -> resultSet.getLong(columnIndex);
|
case "BIGINT":
|
||||||
case "SMALLINT" -> resultSet.getShort(columnIndex);
|
columnValue = resultSet.getLong(columnIndex);
|
||||||
case "TINYINT" -> resultSet.getByte(columnIndex);
|
break;
|
||||||
default -> resultSet.getObject(columnIndex);
|
case "SMALLINT":
|
||||||
};
|
columnValue = resultSet.getShort(columnIndex);
|
||||||
|
break;
|
||||||
|
case "TINYINT":
|
||||||
|
columnValue = resultSet.getByte(columnIndex);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
columnValue = resultSet.getObject(columnIndex);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
object.put(columnName, columnValue);
|
object.put(columnName, columnValue);
|
||||||
|
|||||||
@@ -179,15 +179,21 @@ public class ColorUtil
|
|||||||
float q = v * (1f - s * f);
|
float q = v * (1f - s * f);
|
||||||
float t = v * (1f - s * (1f - f));
|
float t = v * (1f - s * (1f - f));
|
||||||
|
|
||||||
return switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case 0 -> ColorUtil.rgbToInt(a, v, t, p);
|
case 0:
|
||||||
case 1 -> ColorUtil.rgbToInt(a, q, v, p);
|
return ColorUtil.rgbToInt(a, v, t, p);
|
||||||
case 2 -> ColorUtil.rgbToInt(a, p, v, t);
|
case 1:
|
||||||
case 3 -> ColorUtil.rgbToInt(a, p, q, v);
|
return ColorUtil.rgbToInt(a, q, v, p);
|
||||||
case 4 -> ColorUtil.rgbToInt(a, t, p, v);
|
case 2:
|
||||||
default -> ColorUtil.rgbToInt(a, v, p, q); // case 5
|
return ColorUtil.rgbToInt(a, p, v, t);
|
||||||
};
|
case 3:
|
||||||
|
return ColorUtil.rgbToInt(a, p, q, v);
|
||||||
|
case 4:
|
||||||
|
return ColorUtil.rgbToInt(a, t, p, v);
|
||||||
|
default:
|
||||||
|
return ColorUtil.rgbToInt(a, v, p, q); // case 5
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the hex value for the Alpha, Red, Green, and Blue channels. */
|
/** Returns the hex value for the Alpha, Red, Green, and Blue channels. */
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ public class LodUtil
|
|||||||
|
|
||||||
Iterator<DhChunkPos> posIter = MC_RENDER.getVanillaRenderedChunks().iterator();
|
Iterator<DhChunkPos> posIter = MC_RENDER.getVanillaRenderedChunks().iterator();
|
||||||
|
|
||||||
return new EdgeDistanceBooleanGrid(new Iterator<>()
|
return new EdgeDistanceBooleanGrid(new Iterator<Pos2D>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext()
|
public boolean hasNext()
|
||||||
|
|||||||
+22
-14
@@ -452,14 +452,18 @@ public class RenderDataPointReducingList
|
|||||||
0,
|
0,
|
||||||
size,
|
size,
|
||||||
// comparator
|
// comparator
|
||||||
(int index1, int index2) ->
|
(int index1, int index2) ->
|
||||||
Integer.compare(
|
{
|
||||||
this.getSize(this.getSortingIndex(index1)),
|
return Integer.compare(
|
||||||
this.getSize(this.getSortingIndex(index2))
|
this.getSize(this.getSortingIndex(index1)),
|
||||||
),
|
this.getSize(this.getSortingIndex(index2))
|
||||||
|
);
|
||||||
|
},
|
||||||
// swapper
|
// swapper
|
||||||
(int index1, int index2) ->
|
(int index1, int index2) ->
|
||||||
ShortArrays.swap(array, index1, index2)
|
{
|
||||||
|
ShortArrays.swap(array, index1, index2);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,14 +479,18 @@ public class RenderDataPointReducingList
|
|||||||
0,
|
0,
|
||||||
size,
|
size,
|
||||||
// comparator
|
// comparator
|
||||||
(int index1, int index2) ->
|
(int index1, int index2) ->
|
||||||
Integer.compare(
|
{
|
||||||
this.getMinY(this.getSortingIndex(index1)),
|
return Integer.compare(
|
||||||
this.getMinY(this.getSortingIndex(index2))
|
this.getMinY(this.getSortingIndex(index1)),
|
||||||
),
|
this.getMinY(this.getSortingIndex(index2))
|
||||||
|
);
|
||||||
|
},
|
||||||
// swapper
|
// swapper
|
||||||
(int index1, int index2) ->
|
(int index1, int index2) ->
|
||||||
ShortArrays.swap(array, index1, index2)
|
{
|
||||||
|
ShortArrays.swap(array, index1, index2);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -245,8 +245,8 @@ public class RenderDataPointUtil
|
|||||||
" Y-:" + getYMin(dataPoint) +
|
" Y-:" + getYMin(dataPoint) +
|
||||||
" argb:" + getAlpha(dataPoint) + " " +
|
" argb:" + getAlpha(dataPoint) + " " +
|
||||||
getRed(dataPoint) + " " +
|
getRed(dataPoint) + " " +
|
||||||
getGreen(dataPoint) + " " +
|
getBlue(dataPoint) + " " +
|
||||||
getBlue(dataPoint) +
|
getGreen(dataPoint) +
|
||||||
" BL:" + getLightBlock(dataPoint) +
|
" BL:" + getLightBlock(dataPoint) +
|
||||||
" SL:" + getLightSky(dataPoint) +
|
" SL:" + getLightSky(dataPoint) +
|
||||||
" BID:" + getBlockMaterialId(dataPoint);
|
" BID:" + getBlockMaterialId(dataPoint);
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class ThreadUtil
|
|||||||
|
|
||||||
RateLimitedThreadPoolExecutor executor = makeRateLimitedThreadPool(poolSize, runTimeRatioConfigEntry.get(), threadFactory, activeThreadCountSemaphore);
|
RateLimitedThreadPoolExecutor executor = makeRateLimitedThreadPool(poolSize, runTimeRatioConfigEntry.get(), threadFactory, activeThreadCountSemaphore);
|
||||||
|
|
||||||
ConfigChangeListener<Double> changeListener = new ConfigChangeListener<>(runTimeRatioConfigEntry, (newRunTimeRatio) -> executor.runTimeRatio = newRunTimeRatio);
|
ConfigChangeListener<Double> changeListener = new ConfigChangeListener<>(runTimeRatioConfigEntry, (newRunTimeRatio) -> { executor.runTimeRatio = newRunTimeRatio; });
|
||||||
THREAD_CHANGE_LISTENERS_BY_THREAD_NAME.put(threadFactory.threadName, changeListener);
|
THREAD_CHANGE_LISTENERS_BY_THREAD_NAME.put(threadFactory.threadName, changeListener);
|
||||||
|
|
||||||
return executor;
|
return executor;
|
||||||
@@ -102,7 +102,7 @@ public class ThreadUtil
|
|||||||
// ThreadPoolExecutor vs the more generic ExecutorService
|
// ThreadPoolExecutor vs the more generic ExecutorService
|
||||||
return new ThreadPoolExecutor(/*corePoolSize*/ poolSize, /*maxPoolSize*/ poolSize,
|
return new ThreadPoolExecutor(/*corePoolSize*/ poolSize, /*maxPoolSize*/ poolSize,
|
||||||
0L, TimeUnit.MILLISECONDS,
|
0L, TimeUnit.MILLISECONDS,
|
||||||
new LinkedBlockingQueue<>(),
|
new LinkedBlockingQueue<Runnable>(),
|
||||||
new DhThreadFactory(name, priority));
|
new DhThreadFactory(name, priority));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -70,7 +70,7 @@ public class EdgeDistanceBooleanGrid extends PosArrayGridList<BoolType>
|
|||||||
{
|
{
|
||||||
if (edgeCache != null) return;
|
if (edgeCache != null) return;
|
||||||
|
|
||||||
edgeCache = new ArrayGridList<>(gridSize, (ox, oy) -> {
|
edgeCache = new ArrayGridList<Integer>(gridSize, (ox, oy) -> {
|
||||||
BoolType b = get(ox + getOffsetX(), oy + getOffsetY());
|
BoolType b = get(ox + getOffsetX(), oy + getOffsetY());
|
||||||
return b == null ? -1 : 0;
|
return b == null ? -1 : 0;
|
||||||
});
|
});
|
||||||
@@ -79,7 +79,9 @@ public class EdgeDistanceBooleanGrid extends PosArrayGridList<BoolType>
|
|||||||
while (!isDone[0])
|
while (!isDone[0])
|
||||||
{
|
{
|
||||||
isDone[0] = true;
|
isDone[0] = true;
|
||||||
edgeCache.forEachPos((ox, oy) -> isDone[0] &= updatePos(edgeCache, ox, oy));
|
edgeCache.forEachPos((ox, oy) -> {
|
||||||
|
isDone[0] &= updatePos(edgeCache, ox, oy);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -50,7 +50,7 @@ public class DummyRunExecutorService implements ExecutorService
|
|||||||
public List<Runnable> shutdownNow()
|
public List<Runnable> shutdownNow()
|
||||||
{
|
{
|
||||||
shutdownCalled = true;
|
shutdownCalled = true;
|
||||||
return new ArrayList<>();
|
return new ArrayList<Runnable>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -116,7 +116,7 @@ public class DummyRunExecutorService implements ExecutorService
|
|||||||
@Override
|
@Override
|
||||||
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
|
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
|
||||||
{
|
{
|
||||||
List<Future<T>> futures = new ArrayList<>(tasks.size());
|
List<Future<T>> futures = new ArrayList<Future<T>>(tasks.size());
|
||||||
for (Callable<T> t : tasks)
|
for (Callable<T> t : tasks)
|
||||||
{
|
{
|
||||||
futures.add(submit(t));
|
futures.add(submit(t));
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ public class EventTimer
|
|||||||
public void nextEvent(String name)
|
public void nextEvent(String name)
|
||||||
{
|
{
|
||||||
long timeNs = System.nanoTime();
|
long timeNs = System.nanoTime();
|
||||||
if (lastEventNs != -1 && !events.isEmpty() && events.getLast().timeNs == -1)
|
if (lastEventNs != -1 && !events.isEmpty() && events.get(events.size() - 1).timeNs == -1)
|
||||||
{
|
{
|
||||||
events.getLast().timeNs = timeNs - lastEventNs;
|
events.get(events.size() - 1).timeNs = timeNs - lastEventNs;
|
||||||
}
|
}
|
||||||
lastEventNs = timeNs;
|
lastEventNs = timeNs;
|
||||||
events.add(new Event(name));
|
events.add(new Event(name));
|
||||||
@@ -59,9 +59,9 @@ public class EventTimer
|
|||||||
public void complete()
|
public void complete()
|
||||||
{
|
{
|
||||||
long timeNs = System.nanoTime();
|
long timeNs = System.nanoTime();
|
||||||
if (lastEventNs != -1 && !events.isEmpty() && events.getLast().timeNs == -1)
|
if (lastEventNs != -1 && !events.isEmpty() && events.get(events.size() - 1).timeNs == -1)
|
||||||
{
|
{
|
||||||
events.getLast().timeNs = timeNs - lastEventNs;
|
events.get(events.size() - 1).timeNs = timeNs - lastEventNs;
|
||||||
}
|
}
|
||||||
lastEventNs = -1;
|
lastEventNs = -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,13 +61,13 @@ public class SortedArraySet<E> implements SortedSet<E>
|
|||||||
@Override
|
@Override
|
||||||
public E first()
|
public E first()
|
||||||
{
|
{
|
||||||
return list.getFirst();
|
return list.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public E last()
|
public E last()
|
||||||
{
|
{
|
||||||
return list.getLast();
|
return list.get(list.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ import java.util.TreeMap;
|
|||||||
|
|
||||||
public class StatsMap
|
public class StatsMap
|
||||||
{
|
{
|
||||||
final TreeMap<String, Long> longMap = new TreeMap<>();
|
final TreeMap<String, Long> longMap = new TreeMap<String, Long>();
|
||||||
final TreeMap<String, UnitBytes> bytesMap = new TreeMap<>();
|
final TreeMap<String, UnitBytes> bytesMap = new TreeMap<String, UnitBytes>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
+11
-7
@@ -53,15 +53,19 @@ public class DhDataInputStream extends DataInputStream
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return switch (compressionMode)
|
switch (compressionMode)
|
||||||
{
|
{
|
||||||
case UNCOMPRESSED -> stream;
|
case UNCOMPRESSED:
|
||||||
case LZ4 -> new LZ4FrameInputStream(stream);
|
return stream;
|
||||||
case LZMA2 ->
|
case LZ4:
|
||||||
|
return new LZ4FrameInputStream(stream);
|
||||||
|
case LZMA2:
|
||||||
// Note: all LZMA/XZ compressors can be decompressed using this same InputStream
|
// Note: all LZMA/XZ compressors can be decompressed using this same InputStream
|
||||||
new XZInputStream(stream);
|
return new XZInputStream(stream);
|
||||||
default -> throw new IllegalArgumentException("No compressor defined for [" + compressionMode + "]");
|
|
||||||
};
|
default:
|
||||||
|
throw new IllegalArgumentException("No compressor defined for [" + compressionMode + "]");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Error e)
|
catch (Error e)
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-2
@@ -58,7 +58,7 @@ public class LzmaArrayCache extends ArrayCache
|
|||||||
return new byte[size];
|
return new byte[size];
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] array = cacheList.removeLast();
|
byte[] array = cacheList.remove(cacheList.size()-1);
|
||||||
if (array == null)
|
if (array == null)
|
||||||
{
|
{
|
||||||
return new byte[size];
|
return new byte[size];
|
||||||
@@ -102,7 +102,7 @@ public class LzmaArrayCache extends ArrayCache
|
|||||||
return new int[size];
|
return new int[size];
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] array = cacheList.removeLast();
|
int[] array = cacheList.remove(cacheList.size()-1);
|
||||||
if (array == null)
|
if (array == null)
|
||||||
{
|
{
|
||||||
return new int[size];
|
return new int[size];
|
||||||
|
|||||||
+13
-7
@@ -124,14 +124,20 @@ public class QuadNode<T>
|
|||||||
*/
|
*/
|
||||||
public QuadNode<T> getChildByIndex(int child0to3) throws IllegalArgumentException
|
public QuadNode<T> getChildByIndex(int child0to3) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
return switch (child0to3)
|
switch (child0to3)
|
||||||
{
|
{
|
||||||
case 0 -> nwChild;
|
case 0:
|
||||||
case 1 -> swChild;
|
return nwChild;
|
||||||
case 2 -> neChild;
|
case 1:
|
||||||
case 3 -> seChild;
|
return swChild;
|
||||||
default -> throw new IllegalArgumentException("child0to3 must be between 0 and 3");
|
case 2:
|
||||||
};
|
return neChild;
|
||||||
|
case 3:
|
||||||
|
return seChild;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("child0to3 must be between 0 and 3");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -141,7 +141,7 @@ public class QuadTree<T>
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
topQuadNode = new QuadNode<>(rootPos, this.treeMaxDetailLevel);
|
topQuadNode = new QuadNode<T>(rootPos, this.treeMaxDetailLevel);
|
||||||
boolean successfullyAdded = this.topRingList.set(ringListPosX, ringListPosZ, topQuadNode);
|
boolean successfullyAdded = this.topRingList.set(ringListPosX, ringListPosZ, topQuadNode);
|
||||||
if (!successfullyAdded)
|
if (!successfullyAdded)
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-2
@@ -56,8 +56,8 @@ public class ConfigThreadPool
|
|||||||
this.activeThreadCountSemaphore = activeThreadCountSemaphore;
|
this.activeThreadCountSemaphore = activeThreadCountSemaphore;
|
||||||
|
|
||||||
this.threadCountConfig = threadCountConfig;
|
this.threadCountConfig = threadCountConfig;
|
||||||
this.threadCountConfigListener = new ConfigChangeListener<>(threadCountConfig,
|
this.threadCountConfigListener = new ConfigChangeListener<>(threadCountConfig,
|
||||||
this::setThreadPoolSize);
|
(threadCount) -> { this.setThreadPoolSize(threadCount); });
|
||||||
this.runTimeRatioConfig = runTimeRatioConfig;
|
this.runTimeRatioConfig = runTimeRatioConfig;
|
||||||
|
|
||||||
this.setThreadPoolSize(threadCountConfig.get());
|
this.setThreadPoolSize(threadCountConfig.get());
|
||||||
|
|||||||
@@ -19,18 +19,26 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.core.world;
|
package com.seibel.distanthorizons.core.world;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.file.structure.ClientOnlySaveStructure;
|
import com.seibel.distanthorizons.core.file.structure.ClientOnlySaveStructure;
|
||||||
import com.seibel.distanthorizons.core.level.IDhLevel;
|
import com.seibel.distanthorizons.core.level.IDhLevel;
|
||||||
import com.seibel.distanthorizons.core.level.DhClientLevel;
|
import com.seibel.distanthorizons.core.level.DhClientLevel;
|
||||||
|
import com.seibel.distanthorizons.core.network.NetworkClient;
|
||||||
|
import com.seibel.distanthorizons.core.network.messages.*;
|
||||||
|
import com.seibel.distanthorizons.core.network.messages.PlayerUUIDMessage;
|
||||||
|
import com.seibel.distanthorizons.core.network.messages.RemotePlayerConfigMessage;
|
||||||
|
import com.seibel.distanthorizons.core.network.objects.RemotePlayer;
|
||||||
import com.seibel.distanthorizons.core.util.ThreadUtil;
|
import com.seibel.distanthorizons.core.util.ThreadUtil;
|
||||||
import com.seibel.distanthorizons.core.util.objects.EventLoop;
|
import com.seibel.distanthorizons.core.util.objects.EventLoop;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user