This commit is contained in:
CodeF53
2022-05-01 10:34:41 -06:00
parent 79224bdca3
commit 5ddf4f6ddf
25 changed files with 77 additions and 76 deletions
@@ -78,7 +78,7 @@ public class ClientApi
private static final EventApi EVENT_API = EventApi.INSTANCE;
public static final boolean ENABLE_LAG_SPIKE_LOGGING = false;
public static final long LAG_SPIKE_THRESOLD_NS = TimeUnit.NANOSECONDS.convert(16, TimeUnit.MILLISECONDS);
public static final long LAG_SPIKE_THRESHOLD_NS = TimeUnit.NANOSECONDS.convert(16, TimeUnit.MILLISECONDS);
public static final long SPAM_LOGGER_FLUSH_NS = TimeUnit.NANOSECONDS.convert(1, TimeUnit.SECONDS);
@@ -91,7 +91,7 @@ public class ClientApi
public void end(String source) {
if (!ENABLE_LAG_SPIKE_LOGGING) return;
timer = System.nanoTime() - timer;
if (timer > LAG_SPIKE_THRESOLD_NS) {
if (timer > LAG_SPIKE_THRESHOLD_NS) {
LOGGER.info("LagSpikeCatcher: "+source+" took "+Duration.ofNanos(timer)+"!");
}
}
@@ -217,7 +217,7 @@ public class ClientApi
LagSpikeCatcher updateToBeLoadedChunk = new LagSpikeCatcher();
for (long pos : toBeLoaded) {
if (generating.size() >= 1) {
//ApiShared.LOGGER.info("Lod Generating Full! Remining: "+toBeLoaded.size());
//ApiShared.LOGGER.info("Lod Generating Full! Remaining: "+toBeLoaded.size());
break;
}
IChunkWrapper chunk = world.tryGetChunk(FACTORY.createChunkPos(pos));
@@ -230,7 +230,7 @@ public class ClientApi
if (!chunk.doesNearbyChunksExist()) continue;
toBeLoaded.remove(pos);
generating.add(pos);
//ApiShared.LOGGER.info("Lod Generation trying "+pos+". Remining: " +toBeLoaded.size());
//ApiShared.LOGGER.info("Lod Generation trying "+pos+". Remaining: " +toBeLoaded.size());
InternalApiShared.lodBuilder.generateLodNodeAsync(chunk, InternalApiShared.lodWorld,
world.getDimensionType(), DistanceGenerationMode.FULL, true, true, () -> {
generating.remove(pos);
@@ -281,7 +281,7 @@ public class ClientApi
try {
MC.sendChatMessage("\u00A74\u00A7l\u00A7uERROR: Distant Horizons"
+ " renderer has encountered an exception!");
MC.sendChatMessage("\u00A74Renderer is now disabled to prevent futher issues.");
MC.sendChatMessage("\u00A74Renderer is now disabled to prevent further issues.");
MC.sendChatMessage("\u00A74Exception detail: "+e.toString());
} catch (RuntimeException ignored) {}
}
@@ -338,7 +338,7 @@ public class ClientApi
}
//=================//
// DUBUG USE //
// DEBUG USE //
//=================//
// Trigger once on key press, with CLIENT PLAYER.
@@ -223,7 +223,7 @@ public class LodBuilder
try {
if (region.getMinDetailLevel()!= 0) {
if (!LodUtil.checkRamUsage(0.05, 16)) {
EVENT_LOGGER.debug("LodBuilder: Not enough RAM avalible for loading files to build lods! Returning...");
EVENT_LOGGER.debug("LodBuilder: Not enough RAM available for loading files to build lods! Returning...");
return false;
}
@@ -458,7 +458,7 @@ public class LodBuilder
if (chunk.blockPosInsideChunk(x, y+1, z)) {
IBlockDetailWrapper blockAbove = chunk.getBlockDetail(x, y+1, z);
if (blockAbove != null && config.client().worldGenerator().getTintWithAvoidedBlocks() && !blockAbove.shouldRender(config.client().worldGenerator().getBlocksToAvoid()))
{ // The above block is skipped. Lets use its skipped color for currrent block
{ // The above block is skipped. Lets use its skipped color for current block
colorInt = blockAbove.getAndResolveFaceColor(null, chunk, FACTORY.createBlockPos(x, y+1, z));
}
}
@@ -125,7 +125,7 @@ public final class BufferQuad
/**
* Attempts to merge the given quad into this one.
* @returns true if the quads were merged, false otherwise.
* @return true if the quads were merged, false otherwise.
*/
public boolean tryMerge(BufferQuad quad, BufferMergeDirectionEnum mergeDirection)
{
@@ -121,9 +121,8 @@ public class BatchGenerator
// ApiShared.LOGGER.info("PosToGenerate: {}", posToGenerate);
// Find the max number of iterations we need to go though.
// We are checking one FarPos, and one NearPos per iterations. This ensure we
// aren't just
// always picking one or the other.
// We are checking one FarPos, and one NearPos per iterations.
// This ensures we aren't just always picking one or the other.
Steps targetStep;
switch (mode) {
case NONE:
@@ -248,17 +247,17 @@ public class BatchGenerator
if (estimatedSampleNeeded > 32768)
estimatedSampleNeeded = 32768;
if (ENABLE_GENERATOR_STATS_LOGGING)
LOGGER.info("WorldGenerator: Increasing estimatedSampleNeeeded to " + estimatedSampleNeeded);
LOGGER.info("WorldGenerator: Increasing estimatedSampleNeeded to " + estimatedSampleNeeded);
} else if (toGenerate <= 0 && positionGoneThough * 1.5 < posToGenerate.getNumberOfPos()) {
// We haven't gone though half of them and it's already enough.
// Let's shink the estimatedSampleNeeded.
// We haven't gone through half of them, and it's already enough.
// Let's shrink the estimatedSampleNeeded.
estimatedSampleNeeded /= 1.2;
// Ensure we don't go to near zero.
// Ensure we don't go near zero.
if (estimatedSampleNeeded < 4)
estimatedSampleNeeded = 4;
if (ENABLE_GENERATOR_STATS_LOGGING)
LOGGER.info("WorldGenerator: Decreasing estimatedSampleNeeeded to " + estimatedSampleNeeded);
LOGGER.info("WorldGenerator: Decreasing estimatedSampleNeeded to " + estimatedSampleNeeded);
}
}
@@ -52,7 +52,7 @@ public class ConfigBase {
public static final int configVersion = 1;
public static void init(Class<?> config) {
addAcceptableInputs(); // Add all of the acceptable stuff to the acceptableInputs list
addAcceptableInputs(); // Add all the acceptable stuff to the acceptableInputs list
initNestedClass(config, ""); // Init root category
// File handling (load from file)
@@ -17,7 +17,7 @@ public class ConfigTypeConverters {
try {
return convertObjects.get(clazz).convertToString(value);
} catch (Exception e) {
System.out.println("Type [" + clazz.toString() + "] isnt a convertable value in the config file handler");
System.out.println("Type [" + clazz.toString() + "] isnt a convertible value in the config file handler");
return null;
}
}
@@ -25,7 +25,7 @@ public class ConfigTypeConverters {
try {
return convertObjects.get(clazz).convertFromString(value);
} catch (Exception e) {
System.out.println("Type [" + clazz.toString() + "] isnt a convertable value in the config file handler");
System.out.println("Type [" + clazz.toString() + "] isnt a convertible value in the config file handler");
return null;
}
}
@@ -78,7 +78,7 @@ public enum DistanceGenerationMode
* This is the most compatible, but causes server/simulation lag.
* This will also show player made structures if you
* are adding the mod on a pre-existing world.
* Singlethreaded - Slow (15-50 ms, with spikes up to 200 ms)
* Single-threaded - Slow (15-50 ms, with spikes up to 200 ms)
*/
FULL((byte) 6);
@@ -34,7 +34,7 @@ public enum ShadingMode
GAME_SHADING,
/**
* LODs will use ambient occlusion to mimic Minecarft's
* LODs will use ambient occlusion to mimic Minecraft's
* Fancy lighting.
*/
AMBIENT_OCCLUSION
@@ -39,13 +39,13 @@ import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
*/
public interface IReflectionHandler extends IBindable
{
/** @returns Whether Optifine is set to render fog or not. */
/** @return Whether Optifine is set to render fog or not. */
FogDrawMode getFogDrawMode();
/** @returns if Vivecraft is present. Attempts to find the "VRRenderer" class. */
/** @return if Vivecraft is present. Attempts to find the "VRRenderer" class. */
boolean vivecraftPresent();
/** @returns if Sodium (or a sodium like) mod is present. Attempts to find the "SodiumWorldRenderer" class. */
/** @return if Sodium (or a sodium like) mod is present. Attempts to find the "SodiumWorldRenderer" class. */
boolean sodiumPresent();
boolean optifinePresent();
@@ -257,6 +257,7 @@ public class LodDimensionFileHandler
+ " version found: " + fileVersion
+ ", version requested: " + LOD_SAVE_FILE_VERSION
+ ". File has been deleted.");
//TODO: fix comment
// This should not break, but be continue to see whether other detail levels can be loaded or updated
region.addLevelContainer(new VerticalLevelContainer(tempDetailLevel));
}
@@ -481,7 +482,7 @@ public class LodDimensionFileHandler
boolean isStarted = isFileWritingThreadRunning.get();
if (!isStarted)
throw new ConcurrentModificationException("WriterMain Triggered but the thead state is not started!?");
throw new ConcurrentModificationException("WriterMain Triggered but the thread state is not started!?");
if (ENABLE_SAVE_THREAD_LOGGING)
LOGGER.info("Lod File Writer started. To-be-written-regions: " + regionToSave.size());
@@ -498,7 +499,7 @@ public class LodDimensionFileHandler
{
if (r.isWriting.getAndIncrement() > 0)
continue;
//Check if the data has been swapped out right under me. Otherwise remove it from the entry
//Check if the data has been swapped out right under me. Otherwise, remove it from the entry
if (!regionToSave.remove(r.getRegionPos(), r))
continue;
r.needSaving = false;
@@ -35,37 +35,37 @@ public class DependencyHandler
/**
* Links the given implementation object to an interface so it can be referenced later.
* Links the given implementation object to an interface, so it can be referenced later.
*
* @param depenencyInterface The interface the implementation object should implement.
* @param dependencyImplementation A object that implements the depenencyInterface interface.
* @param dependencyInterface The interface the implementation object should implement.
* @param dependencyImplementation An object that implements the dependencyInterface interface.
* @throws IllegalStateException if the implementation object doesn't implement
* the interface or the interface has already been bound.
*/
public void bind(Class<?> depenencyInterface, Object dependencyImplementation) throws IllegalStateException
public void bind(Class<?> dependencyInterface, Object dependencyImplementation) throws IllegalStateException
{
// only allow binding before the finishBinding method is called
if (bindingFinished)
{
throw new IllegalStateException("The dependency [" + depenencyInterface.getSimpleName() + "] cannot be bound, Binding is finished for [" + this.getClass().getSimpleName() + "]. Make sure your bindings are happening before the [bindingFinished] method is being called.");
throw new IllegalStateException("The dependency [" + dependencyInterface.getSimpleName() + "] cannot be bound, Binding is finished for [" + this.getClass().getSimpleName() + "]. Make sure your bindings are happening before the [bindingFinished] method is being called.");
}
// make sure we haven't already bound this dependency
if (dependencies.containsKey(depenencyInterface))
if (dependencies.containsKey(dependencyInterface))
{
throw new IllegalStateException("The dependency [" + depenencyInterface.getSimpleName() + "] has already been bound.");
throw new IllegalStateException("The dependency [" + dependencyInterface.getSimpleName() + "] has already been bound.");
}
// make sure the given dependency implements the necessary interfaces
boolean implementsInterface = checkIfClassImplements(dependencyImplementation.getClass(), depenencyInterface);
boolean implementsInterface = checkIfClassImplements(dependencyImplementation.getClass(), dependencyInterface);
boolean implementsBindable = checkIfClassImplements(dependencyImplementation.getClass(), IBindable.class);
// display any errors
if (!implementsInterface)
{
throw new IllegalStateException("The dependency [" + dependencyImplementation.getClass().getSimpleName() + "] doesn't implement the interface [" + depenencyInterface.getSimpleName() + "].");
throw new IllegalStateException("The dependency [" + dependencyImplementation.getClass().getSimpleName() + "] doesn't implement the interface [" + dependencyInterface.getSimpleName() + "].");
}
if (!implementsBindable)
{
@@ -73,7 +73,7 @@ public class DependencyHandler
}
dependencies.put(depenencyInterface, dependencyImplementation);
dependencies.put(dependencyInterface, dependencyImplementation);
}
/**
* Checks if classToTest (or one of its ancestors)
@@ -30,7 +30,7 @@ public interface IBindable
/**
* Finish initializing this object. <br> <br>
*
* Generally this should just used for getting other objects through
* Generally this should just be used for getting other objects through
* dependency injection and is specifically designed to allow
* for circular references. <br><br>
*
@@ -45,7 +45,7 @@ public class ModAccessorHandler
/**
* Links the given mod accessor to an interface so it can be referenced later.
* Links the given mod accessor to an interface, so it can be referenced later.
*
* @param interfaceClass The interface the mod accessor should implement.
* @param modAccessor An object that implements the interfaceClass interface.
@@ -56,7 +56,7 @@ public class ModAccessorHandler
throws IllegalStateException
{
dependencyHandler.bind(interfaceClass, modAccessor);
LOGGER.info("Registored mod comatibility accessor for " + modAccessor.getModName());
LOGGER.info("Registered mod compatibility accessor for " + modAccessor.getModName());
}
/**
@@ -30,12 +30,14 @@ public class SingletonHandler
{
private static final DependencyHandler dependencyHandler = new DependencyHandler();
// TODO: FIX Javadoc
// This is the exact same javadoc as in DependencyHandler.java
// Ths method doesnt even use dependencyInterface or dependencyImplementation
/**
* Links the given implementation object to an interface so it can be referenced later.
* Links the given implementation object to an interface, so it can be referenced later.
*
* @param depenencyInterface The interface the implementation object should implement.
* @param dependencyImplementation A object that implements the depenencyInterface interface.
* @param dependencyInterface The interface the implementation object should implement.
* @param dependencyImplementation An object that implements the dependencyInterface interface.
* @throws IllegalStateException if the implementation object doesn't implement
* the interface or the interface has already been bound.
*/
@@ -29,8 +29,8 @@ import java.util.concurrent.ConcurrentMap;
public class BlockBiomeCouple
{
public static final ConcurrentMap<BlockDetail, BlockBiomeCouple> noBiomeIstanceCache = new ConcurrentHashMap<>();
public static ConcurrentMap<IBiomeWrapper, ConcurrentMap<BlockDetail, BlockBiomeCouple>> withBiomeIstanceCache = new ConcurrentHashMap<>();
public static final ConcurrentMap<BlockDetail, BlockBiomeCouple> noBiomeInstanceCache = new ConcurrentHashMap<>();
public static ConcurrentMap<IBiomeWrapper, ConcurrentMap<BlockDetail, BlockBiomeCouple>> withBiomeInstanceCache = new ConcurrentHashMap<>();
String blockName;
String biomeName;
@@ -43,14 +43,14 @@ public class BlockBiomeCouple
}
public static BlockBiomeCouple getBlockBiomeCouple(IBlockColorWrapper blockColor){
if(noBiomeIstanceCache.containsKey(blockColor))
if(noBiomeInstanceCache.containsKey(blockColor))
{
return noBiomeIstanceCache.get(blockColor);
return noBiomeInstanceCache.get(blockColor);
}
else
{
BlockBiomeCouple couple = new BlockBiomeCouple(blockColor);
noBiomeIstanceCache.put(blockColor,couple);
noBiomeInstanceCache.put(blockColor,couple);
return couple;
}
}
@@ -62,9 +62,9 @@ public class BlockBiomeCouple
}
else
{
if(withBiomeIstanceCache.containsKey(biomeColor))
if(withBiomeInstanceCache.containsKey(biomeColor))
{
withBiomeIstanceCache.put(biomeColor, new ConcurrentHashMap<>());
withBiomeInstanceCache.put(biomeColor, new ConcurrentHashMap<>());
}
ConcurrentMap<IBlockColorWrapper, BlockBiomeCouple> blockToCoupleMap = withBiomeIstanceCache.get(biomeColor);
if(blockToCoupleMap.containsKey(blockColor))
@@ -144,7 +144,7 @@ public class PosToRenderContainer
public int getNthPosZ(int n)
{
return lodPosList[n].posZ;
//eturn posToRender[n * 3 + 2];
//return posToRender[n * 3 + 2];
}
public void sort() {
@@ -19,7 +19,6 @@
package com.seibel.lod.core.objects.lod;
import com.seibel.lod.core.api.internal.InternalApiShared;
import com.seibel.lod.core.api.internal.ClientApi;
import com.seibel.lod.core.enums.config.DistanceGenerationMode;
import com.seibel.lod.core.enums.config.DropoffQuality;
@@ -232,11 +231,11 @@ public class LodDimension
regions[xIndex][zIndex] = newRegion;
}*/
public interface PosComsumer {
public interface PosConsumer {
void run(int x, int z);
}
public void iterateWithSpiral(PosComsumer r) {
public void iterateWithSpiral(PosConsumer r) {
int ox,oy,dx,dy;
ox = oy = dx = 0;
dy = -1;
@@ -258,7 +257,7 @@ public class LodDimension
oy += dy;
}
}
public void iterateByDistance(PosComsumer r) {
public void iterateByDistance(PosConsumer r) {
if (iteratorList==null) return;
for (RegionPos relativePos : iteratorList) {
r.run(relativePos.x+halfWidth, relativePos.z+halfWidth);
@@ -468,7 +467,7 @@ public class LodDimension
posToGenerate = new PosToGenerateContainer(maxDataToGenerate, playerBlockPosX, playerBlockPosZ);
// This ensures that we don't spawn way too much regions without finish flushing them first.
// This ensures that we don't spawn way too many regions without finish flushing them first.
//if (dirtiedRegionsRoughCount > 16) return posToGenerate;
GenerationPriority allowedPriority = dirtiedRegionsRoughCount>12 ? GenerationPriority.NEAR_FIRST : priority;
Pos2D minPos = regions.getMinInRange();
@@ -111,7 +111,7 @@ public class LodRegion {
* @return true if the data was added successfully
*/
public boolean addData(byte detailLevel, int posX, int posZ, int verticalIndex, long data) {
if(isWriting.get()<=0) throw new ConcurrentModificationException("isWriting counter lock should have been aquired!");
if(isWriting.get()<=0) throw new ConcurrentModificationException("isWriting counter lock should have been acquired!");
posX = LevelPosUtil.getRegionModule(detailLevel, posX);
posZ = LevelPosUtil.getRegionModule(detailLevel, posZ);
@@ -132,7 +132,7 @@ public class LodRegion {
* @return true if the data was added successfully
*/
public boolean addVerticalData(byte detailLevel, int posX, int posZ, long[] data, boolean override) {
if(isWriting.get()<=0) throw new ConcurrentModificationException("isWriting counter lock should have been aquired!");
if(isWriting.get()<=0) throw new ConcurrentModificationException("isWriting counter lock should have been acquired!");
posX = LevelPosUtil.getRegionModule(detailLevel, posX);
posZ = LevelPosUtil.getRegionModule(detailLevel, posZ);
@@ -156,7 +156,7 @@ public class LodRegion {
* @return true if the data was added successfully
*/
public boolean addChunkOfData(byte detailLevel, int posX, int posZ, int widthX, int widthZ, long[] data, int verticalSize, boolean override) {
if(isWriting.get()<=0) throw new ConcurrentModificationException("isWriting counter lock should have been aquired!");
if(isWriting.get()<=0) throw new ConcurrentModificationException("isWriting counter lock should have been acquired!");
posX = LevelPosUtil.getRegionModule(detailLevel, posX);
posZ = LevelPosUtil.getRegionModule(detailLevel, posZ);
@@ -183,7 +183,7 @@ public class LodRegion {
);*/
}
if (!doesDataExist(detailLevel, posX, posZ, DistanceGenerationMode.values()[DataPointUtil.getGenerationMode(data[0]) - 1])) { //FIXME: -1 casue NONE has value of 1 but slot of 0
if (!doesDataExist(detailLevel, posX, posZ, DistanceGenerationMode.values()[DataPointUtil.getGenerationMode(data[0]) - 1])) { //FIXME: -1 case NONE has value of 1 but slot of 0
throw new RuntimeException("Data still doesn't exist after addChunkOfData!");
}
@@ -419,8 +419,8 @@ public class LodRegion {
}
/**
* This method will fill the posToRender array with all levelPos that are
* render-able. But the entire region try use the same detail level.
* This method will fill the posToRender array with all levelPos that are render-able,
* but the entire region try to use the same detail level.
*/
private void getPosToRenderFlat(PosToRenderContainer posToRender, byte detailLevel, int offsetPosX, int offsetPosZ,
byte targetLevel, byte farModeSwitchLevel) {
@@ -47,7 +47,7 @@ public class VerticalLevelContainer implements LevelContainer
public final long[] dataContainer;
//Currently these variable are not used. We are going to use them in the new data format
//Currently, these variable are not used. We are going to use them in the new data format
public final int[] verticalDataContainer = null;
public final int[] colorDataContainer = null;
public final byte[] lightDataContainer = null;
@@ -215,8 +215,8 @@ public class Mat4f
this.m33 = 1.0F;
}
/** adjugate and determinate */
public float adjugateAndDet()
/** adjudicate and determinate */
public float adjudicateAndDet()
{
float f = this.m00 * this.m11 - this.m01 * this.m10;
float f1 = this.m00 * this.m12 - this.m02 * this.m10;
@@ -289,7 +289,7 @@ public class Mat4f
public boolean invert()
{
float det = this.adjugateAndDet();
float det = this.adjudicateAndDet();
if (Math.abs(det) > 1.0E-6F)
{
this.multiply(det);
@@ -177,7 +177,7 @@ public class LodBox
short height = DataPointUtil.getHeight(adjPoint);
short depth = DataPointUtil.getDepth(adjPoint);
// If the depth of said block is higher then our max Y, continue
// If the depth of said block is higher than our max Y, continue
// Basically: y < maxY <= _____ height
// _______&&: y < maxY <= depth
if (y + wy <= depth)
@@ -92,8 +92,8 @@ public class LodVertexFormat
}
else if (obj != null && this.getClass() == obj.getClass())
{
LodVertexFormat vertexformat = (LodVertexFormat) obj;
return this.byteSize == vertexformat.byteSize && this.elements.equals(vertexformat.elements);
LodVertexFormat vertexFormat = (LodVertexFormat) obj;
return this.byteSize == vertexFormat.byteSize && this.elements.equals(vertexFormat.elements);
}
else
{
@@ -91,7 +91,7 @@ public abstract class RenderBuffer implements AutoCloseable
/* Called on being reused after the object is swapped to the back
* and a new build event is triggered. Used for cleaning up non
* reusable objects sooner.
* Note: This is ran on BUILDER thread, and does not have access to
* Note: This is run on BUILDER thread, and does not have access to
* GL Context, Use GLProxy.recordOpenGlCall() to access GL Context
* instead! */
public void onReuse() {}
@@ -111,11 +111,11 @@ public abstract class RenderBuffer implements AutoCloseable
/* Called on buffer no longer being used. (Life ended)
* Return false if current object cannot be reused.
* Note: This should not do too much stuff as it is ran on render thread!
* Note: This should not do too much stuff as it is run on render thread!
* The corresponding cleanups should be done using the onReuse() to prevent
* lag spikes! If you want this buffer to not be reused, but cleanup is
* expensive, use onReuse() instead!
* Note 2: This may not be triggered on some siturations like renderer being
* Note 2: This may not be triggered on some situations like renderer being
* terminated, or dimension changed. So implementation should NEVER assume
* that onSwapToFront() will link to a call of onSwapToBack()! */
public boolean onSwapToBack() {return true;}
@@ -32,10 +32,10 @@ import com.seibel.lod.core.handlers.dependencyInjection.IBindable;
*/
public interface IVersionConstants extends IBindable
{
/** @returns the minimum height blocks can be generated */
/** @return the minimum height blocks can be generated */
int getMinimumWorldHeight();
/** @Returns the number of generations call per thread. */
/** @return the number of generations call per thread. */
default int getWorldGenerationCountPerThread() {
return 8;
}
@@ -84,7 +84,7 @@ public interface IMinecraftClientWrapper extends IBindable
/**
* Attempts to get the ServerWorld for the dimension
* the user is currently in.
* @returns null if no ServerWorld is available
* @return null if no ServerWorld is available
*/
IWorldWrapper getWrappedServerWorld();