Update core, Change some small stuff.
This commit is contained in:
@@ -80,16 +80,15 @@ public class BlockColorWrapper implements IBlockColorWrapper
|
||||
public static IBlockColorWrapper getBlockColorWrapper(Block block)
|
||||
{
|
||||
//first we check if the block has already been wrapped
|
||||
if (blockColorWrapperMap.containsKey(block) && blockColorWrapperMap.get(block) != null)
|
||||
return blockColorWrapperMap.get(block);
|
||||
|
||||
BlockColorWrapper colorWrapper = blockColorWrapperMap.get(block);
|
||||
if (colorWrapper != null)
|
||||
return colorWrapper;
|
||||
|
||||
//if it hasn't been created yet, we create it and save it in the map
|
||||
BlockColorWrapper blockWrapper = new BlockColorWrapper(block);
|
||||
blockColorWrapperMap.put(block, blockWrapper);
|
||||
|
||||
colorWrapper = new BlockColorWrapper(block);
|
||||
BlockColorWrapper colorWrapperCAS = blockColorWrapperMap.putIfAbsent(block, colorWrapper);
|
||||
//we return the newly created wrapper
|
||||
return blockWrapper;
|
||||
return colorWrapperCAS==null ? colorWrapper : colorWrapperCAS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,16 +58,15 @@ public class BlockShapeWrapper implements IBlockShapeWrapper
|
||||
static public BlockShapeWrapper getBlockShapeWrapper(Block block, ChunkWrapper chunkWrapper, int x, int y, int z)
|
||||
{
|
||||
//first we check if the block has already been wrapped
|
||||
if (blockShapeWrapperMap.containsKey(block) && blockShapeWrapperMap.get(block) != null)
|
||||
return blockShapeWrapperMap.get(block);
|
||||
|
||||
BlockShapeWrapper blockWrapper = blockShapeWrapperMap.get(block);
|
||||
if (blockWrapper != null)
|
||||
return blockWrapper;
|
||||
|
||||
//if it hasn't been created yet, we create it and save it in the map
|
||||
BlockShapeWrapper blockWrapper = new BlockShapeWrapper(block, chunkWrapper, x, y, z);
|
||||
blockShapeWrapperMap.put(block, blockWrapper);
|
||||
|
||||
blockWrapper = new BlockShapeWrapper(block, chunkWrapper, x, y, z);
|
||||
BlockShapeWrapper blockWrapperCAS = blockShapeWrapperMap.putIfAbsent(block, blockWrapper);
|
||||
//we return the newly created wrapper
|
||||
return blockWrapper;
|
||||
return blockWrapperCAS==null ? blockWrapper : blockWrapperCAS;
|
||||
}
|
||||
|
||||
private void setupShapes(IChunkWrapper chunkWrapper, int x, int y, int z)
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.QuartPos;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.block.AirBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.LiquidBlock;
|
||||
import net.minecraft.world.level.block.LiquidBlockContainer;
|
||||
|
||||
+20
-4
@@ -47,9 +47,10 @@ public class ExperimentalGenerator extends AbstractExperimentalWorldGeneratorWra
|
||||
public LodDimension targetLodDim;
|
||||
public static final int generationGroupSize = 4;
|
||||
public static final int generationGroupSizeFar = 0;
|
||||
public static int numberOfGenerationPoints = CONFIG.client().advanced().threading().getNumberOfWorldGenerationThreads();
|
||||
public static int previousThreadCount = CONFIG.client().advanced().threading().getNumberOfWorldGenerationThreads();
|
||||
|
||||
private int estimatedSampleNeeded = 128;
|
||||
private int estimatedPointsToQueue = 1;
|
||||
|
||||
public ExperimentalGenerator(LodBuilder newLodBuilder, LodDimension newLodDimension, IWorldWrapper worldWrapper) {
|
||||
super(newLodBuilder, newLodDimension, worldWrapper);
|
||||
@@ -73,7 +74,13 @@ public class ExperimentalGenerator extends AbstractExperimentalWorldGeneratorWra
|
||||
}
|
||||
|
||||
DistanceGenerationMode mode = CONFIG.client().worldGenerator().getDistanceGenerationMode();
|
||||
numberOfGenerationPoints = CONFIG.client().advanced().threading().getNumberOfWorldGenerationThreads();
|
||||
int newThreadCount = CONFIG.client().advanced().threading().getNumberOfWorldGenerationThreads();
|
||||
if (newThreadCount != previousThreadCount) {
|
||||
generationGroup.resizeThreadPool(newThreadCount);
|
||||
previousThreadCount = newThreadCount;
|
||||
}
|
||||
if (estimatedPointsToQueue < newThreadCount) estimatedPointsToQueue = newThreadCount;
|
||||
|
||||
GenerationPriority priority = CONFIG.client().worldGenerator().getGenerationPriority();
|
||||
if (priority == GenerationPriority.AUTO)
|
||||
priority = MC.hasSinglePlayerServer() ? GenerationPriority.FAR_FIRST : GenerationPriority.NEAR_FIRST;
|
||||
@@ -83,10 +90,14 @@ public class ExperimentalGenerator extends AbstractExperimentalWorldGeneratorWra
|
||||
return;
|
||||
int eventsCount = generationGroup.events.size();
|
||||
// If we still all jobs running, return.
|
||||
if (eventsCount >= numberOfGenerationPoints)
|
||||
if (eventsCount >= estimatedPointsToQueue) {
|
||||
estimatedPointsToQueue--;
|
||||
if (estimatedPointsToQueue < newThreadCount) estimatedPointsToQueue = newThreadCount;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final int targetToGenerate = numberOfGenerationPoints - eventsCount;
|
||||
final int targetToGenerate = estimatedPointsToQueue - eventsCount;
|
||||
int toGenerate = targetToGenerate;
|
||||
int positionGoneThough = 0;
|
||||
|
||||
@@ -98,6 +109,11 @@ public class ExperimentalGenerator extends AbstractExperimentalWorldGeneratorWra
|
||||
// position generation is completed.
|
||||
PosToGenerateContainer posToGenerate = lodDim.getPosToGenerate(estimatedSampleNeeded, playerPosX, playerPosZ, priority, mode);
|
||||
|
||||
if (eventsCount == 0 && posToGenerate.getNumberOfPos()>=estimatedSampleNeeded) {
|
||||
estimatedPointsToQueue++;
|
||||
if (estimatedPointsToQueue > newThreadCount*10) estimatedPointsToQueue = newThreadCount*10;
|
||||
}
|
||||
|
||||
//ClientApi.LOGGER.info("PosToGenerate: {}", posToGenerate);
|
||||
|
||||
// Find the max number of iterations we need to go though.
|
||||
|
||||
+19
-3
@@ -26,6 +26,8 @@ import com.seibel.lod.core.builders.lodBuilding.LodBuilderConfig;
|
||||
import com.seibel.lod.core.enums.config.DistanceGenerationMode;
|
||||
import com.seibel.lod.core.objects.lod.LodDimension;
|
||||
import com.seibel.lod.core.util.LodThreadFactory;
|
||||
import com.seibel.lod.core.util.SingletonHandler;
|
||||
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IStarlightAccessor;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
@@ -461,10 +463,20 @@ public final class WorldGenerationStep {
|
||||
final StepCarvers stepCarvers = new StepCarvers();
|
||||
final StepFeatures stepFeatures = new StepFeatures();
|
||||
final StepLight stepLight = new StepLight();
|
||||
private static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class);
|
||||
|
||||
public final ExecutorService executors = Executors
|
||||
.newCachedThreadPool(new LodThreadFactory("Gen-Worker-Thread", Thread.MIN_PRIORITY));
|
||||
//public final ExecutorService executors = Executors
|
||||
// .newCachedThreadPool(new LodThreadFactory("Gen-Worker-Thread", Thread.MIN_PRIORITY));
|
||||
public ExecutorService executors = Executors
|
||||
.newFixedThreadPool(CONFIG.client().advanced().threading().getNumberOfWorldGenerationThreads(),
|
||||
new LodThreadFactory("Gen-Worker-Thread", Thread.MIN_PRIORITY));
|
||||
|
||||
public void resizeThreadPool(int newThreadCount)
|
||||
{
|
||||
executors = Executors.newFixedThreadPool(newThreadCount,
|
||||
new LodThreadFactory("Gen-Worker-Thread", Thread.MIN_PRIORITY));
|
||||
}
|
||||
|
||||
public boolean tryAddPoint(int px, int pz, int range, Steps target) {
|
||||
int boxSize = range * 2 + 1;
|
||||
int x = Math.floorDiv(px, boxSize) * boxSize + range;
|
||||
@@ -621,7 +633,7 @@ public final class WorldGenerationStep {
|
||||
int targetIndex = referencedChunks.offsetOf(centreIndex, ox, oy);
|
||||
ChunkAccess target = referencedChunks.get(targetIndex);
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, new ChunkWrapper(target, region), new LodBuilderConfig(generationMode)
|
||||
, false);
|
||||
, true);
|
||||
//params.lodBuilder.generateLodNodeAsync(new ChunkWrapper(target, region), ApiShared.lodWorld, params.lodDim.dimension,
|
||||
// generationMode, false, () -> {}, () -> {});
|
||||
}
|
||||
@@ -1281,5 +1293,9 @@ public final class WorldGenerationStep {
|
||||
throw new UnsupportedOperationException("This should never be used!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+1
-1
Submodule core updated: ab3880a5e5...c3abb9c46b
Reference in New Issue
Block a user