Backport changes from 1.18 branch
This commit is contained in:
@@ -33,5 +33,6 @@ public class DependencySetup {
|
||||
SingletonHandler.bind(IVersionConstants.class, VersionConstants.INSTANCE);
|
||||
}
|
||||
SingletonHandler.bind(IWrapperFactory.class, WrapperFactory.INSTANCE);
|
||||
DependencySetupDoneCheck.isDone = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.seibel.lod.common.wrappers;
|
||||
|
||||
public class DependencySetupDoneCheck
|
||||
{
|
||||
public static boolean isDone = false;
|
||||
|
||||
}
|
||||
+15
-4
@@ -197,7 +197,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
public final LinkedList<GenerationEvent> events = new LinkedList<GenerationEvent>();
|
||||
public final GlobalParameters params;
|
||||
public final StepStructureStart stepStructureStart = new StepStructureStart(this);
|
||||
public final StepStructureReference stepStructureReference = new StepStructureReference();
|
||||
public final StepStructureReference stepStructureReference = new StepStructureReference(this);
|
||||
public final StepBiomes stepBiomes = new StepBiomes(this);
|
||||
public final StepNoise stepNoise = new StepNoise(this);
|
||||
public final StepSurface stepSurface = new StepSurface(this);
|
||||
@@ -212,6 +212,13 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
public long lastExceptionTriggerTime = 0;
|
||||
|
||||
public static final LodThreadFactory threadFactory = new LodThreadFactory("Gen-Worker-Thread", Thread.MIN_PRIORITY);
|
||||
|
||||
public static ThreadLocal<Boolean> isDistantGeneratorThread = new ThreadLocal<Boolean>();
|
||||
|
||||
public static boolean isCurrentThreadDistantGeneratorThread() {
|
||||
return (isDistantGeneratorThread.get() != null);
|
||||
}
|
||||
|
||||
|
||||
public ExecutorService executors = Executors.newFixedThreadPool(
|
||||
CONFIG.client().advanced().threading().getNumberOfWorldGenerationThreads(), threadFactory);
|
||||
@@ -412,17 +419,21 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
int targetIndex = referencedChunks.offsetOf(centreIndex, ox, oy);
|
||||
ChunkAccess target = referencedChunks.get(targetIndex);
|
||||
target.setLightCorrect(true);
|
||||
ChunkWrapper wrappedChunk = new ChunkWrapper(target, region);
|
||||
if (!wrappedChunk.isLightCorrect()) {
|
||||
throw new RuntimeException("The generated chunk somehow has isLightCorrect() returning false");
|
||||
}
|
||||
boolean isFull = target.getStatus() == ChunkStatus.FULL || target instanceof LevelChunk;
|
||||
if (isFull) {
|
||||
if (ENABLE_LOAD_EVENT_LOGGING)
|
||||
ClientApi.LOGGER.info("Detected full existing chunk at {}", target.getPos());
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, new ChunkWrapper(target, region),
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, wrappedChunk,
|
||||
new LodBuilderConfig(DistanceGenerationMode.FULL), true, e.genAllDetails);
|
||||
} else if (target.getStatus() == ChunkStatus.EMPTY && generationMode == DistanceGenerationMode.NONE) {
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, new ChunkWrapper(target, region),
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, wrappedChunk,
|
||||
LodBuilderConfig.getFillVoidConfig(), true, e.genAllDetails);
|
||||
} else {
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, new ChunkWrapper(target, region),
|
||||
params.lodBuilder.generateLodNodeFromChunk(params.lodDim, wrappedChunk,
|
||||
new LodBuilderConfig(generationMode), true, e.genAllDetails);
|
||||
}
|
||||
lightEngine.retainData(target.getPos(), false);
|
||||
|
||||
+6
-1
@@ -42,7 +42,12 @@ public final class GenerationEvent {
|
||||
this.genAllDetails = genAllDetails;
|
||||
|
||||
future = generationGroup.executors.submit(() -> {
|
||||
generationGroup.generateLodFromList(this);
|
||||
BatchGenerationEnvironment.isDistantGeneratorThread.set(true);
|
||||
try {
|
||||
generationGroup.generateLodFromList(this);
|
||||
} finally {
|
||||
BatchGenerationEnvironment.isDistantGeneratorThread.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+12
-37
@@ -20,44 +20,19 @@ import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
|
||||
public final class StepStructureReference {
|
||||
public final ChunkStatus STATUS = ChunkStatus.STRUCTURE_REFERENCES;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final BatchGenerationEnvironment envionment;
|
||||
|
||||
private void createReferences(WorldGenRegion worldGenLevel, StructureFeatureManager structureFeatureManager,
|
||||
ChunkAccess chunkAccess) {
|
||||
ChunkPos chunkPos = chunkAccess.getPos();
|
||||
int j = chunkPos.x;
|
||||
int k = chunkPos.z;
|
||||
int l = chunkPos.getMinBlockX();
|
||||
int m = chunkPos.getMinBlockZ();
|
||||
|
||||
SectionPos sectionPos = SectionPos.of(chunkAccess.getPos(), 0);
|
||||
|
||||
for (int n = j - 8; n <= j + 8; n++) {
|
||||
for (int o = k - 8; o <= k + 8; o++) {
|
||||
if (!worldGenLevel.hasChunk(n, o))
|
||||
continue;
|
||||
long p = ChunkPos.asLong(n, o);
|
||||
for (StructureStart<?> structureStart : worldGenLevel.getChunk(n, o).getAllStarts().values()) {
|
||||
try {
|
||||
if (structureStart.isValid()
|
||||
&& structureStart.getBoundingBox().intersects(l, m, l + 15, m + 15)) {
|
||||
structureFeatureManager.addReferenceForFeature(sectionPos, structureStart.getFeature(), p,
|
||||
chunkAccess);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
CrashReport crashReport = CrashReport.forThrowable(exception, "Generating structure reference");
|
||||
CrashReportCategory crashReportCategory = crashReport.addCategory("Structure");
|
||||
crashReportCategory.setDetail("Id",
|
||||
() -> Registry.STRUCTURE_FEATURE.getKey(structureStart.getFeature()).toString());
|
||||
crashReportCategory.setDetail("Name", () -> structureStart.getFeature().getFeatureName());
|
||||
crashReportCategory.setDetail("Class",
|
||||
() -> structureStart.getFeature().getClass().getCanonicalName());
|
||||
throw new ReportedException(crashReport);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param worldGenerationEnvironment
|
||||
*/
|
||||
public StepStructureReference(BatchGenerationEnvironment worldGenerationEnvironment) {
|
||||
envionment = worldGenerationEnvironment;
|
||||
}
|
||||
|
||||
public final ChunkStatus STATUS = ChunkStatus.STRUCTURE_REFERENCES;
|
||||
|
||||
public void generateGroup(ThreadedParameters tParams, WorldGenRegion worldGenRegion, List<ChunkAccess> chunks) {
|
||||
|
||||
@@ -72,7 +47,7 @@ public final class StepStructureReference {
|
||||
|
||||
for (ChunkAccess chunk : chunksToDo) {
|
||||
// System.out.println("StepStructureReference: "+chunk.getPos());
|
||||
createReferences(worldGenRegion, tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk);
|
||||
envionment.params.generator.createReferences(worldGenRegion, tParams.structFeat.forWorldGenRegion(worldGenRegion), chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
Submodule core updated: 50819c30da...fbbccf4739
Reference in New Issue
Block a user