Fix: Do not create semi-invalid render contexts for chunks containing only wires (#465)
Also do not create "full" contexts for chunks containing neither wires nor blocks if IE is installed. Closes #441
This commit is contained in:
1 parent
87b548e48b
commit
e843c69f39
3 files changed
+22
-32
No files matched your search
+1
-19
@@ -5,14 +5,11 @@ import blusunrize.immersiveengineering.api.wires.WireCollisionData.ConnectionSeg
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.RenderSection;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.tasks.ChunkRenderBuildTask;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.tasks.ChunkRenderRebuildTask;
|
||||
import me.jellysquid.mods.sodium.client.world.cloned.ChunkRenderContext;
|
||||
import me.jellysquid.mods.sodium.client.world.cloned.ClonedChunkSection;
|
||||
import me.jellysquid.mods.sodium.client.world.WorldSlice;
|
||||
import me.jellysquid.mods.sodium.client.world.cloned.ClonedChunkSectionCache;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.ChunkSectionPos;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ImmersiveEmptyChunkChecker {
|
||||
@@ -21,19 +18,4 @@ public class ImmersiveEmptyChunkChecker {
|
||||
List<ConnectionSegments> wiresInSection = globalNet.getCollisionData().getWiresIn(origin);
|
||||
return wiresInSection != null && !wiresInSection.isEmpty();
|
||||
}
|
||||
|
||||
public static ChunkRenderBuildTask makeEmptyRebuildTask(
|
||||
ClonedChunkSectionCache sectionCache, ChunkSectionPos origin, RenderSection render, int frame
|
||||
) {
|
||||
var sections = new ClonedChunkSection[64];
|
||||
// TODO rethink this mess, and possibly call release?
|
||||
var centerSection = sectionCache.acquire(origin.getSectionX(), origin.getSectionY(), origin.getSectionZ());
|
||||
Arrays.fill(sections, centerSection);
|
||||
var sectionBB = new BlockBox(
|
||||
origin.getMinX() - 2, origin.getMinY() - 2, origin.getMinZ() - 2,
|
||||
origin.getMaxX() + 2, origin.getMaxY() + 2, origin.getMaxZ() + 2
|
||||
);
|
||||
var context = new ChunkRenderContext(origin, sections, sectionBB);
|
||||
return new ChunkRenderRebuildTask(render, context, frame);
|
||||
}
|
||||
}
|
||||
+14
-12
@@ -255,12 +255,16 @@ public class RenderSectionManager {
|
||||
Chunk chunk = this.world.getChunk(x, z);
|
||||
ChunkSection section = chunk.getSectionArray()[this.world.sectionCoordToIndex(y)];
|
||||
|
||||
if (section.isEmpty()) {
|
||||
if(!SodiumClientMod.immersiveLoaded) {
|
||||
render.setData(ChunkRenderData.EMPTY);
|
||||
}else if(!ImmersiveEmptyChunkChecker.hasWires(ChunkSectionPos.from(x, y, z))) {
|
||||
render.setData(ChunkRenderData.EMPTY);
|
||||
}
|
||||
boolean isEmpty;
|
||||
if (!section.isEmpty()) {
|
||||
isEmpty = false;
|
||||
} else if (!SodiumClientMod.immersiveLoaded) {
|
||||
isEmpty = true;
|
||||
} else {
|
||||
isEmpty = !ImmersiveEmptyChunkChecker.hasWires(ChunkSectionPos.from(x, y, z));
|
||||
}
|
||||
if (isEmpty) {
|
||||
render.setData(ChunkRenderData.EMPTY);
|
||||
} else {
|
||||
render.markForUpdate(ChunkUpdateType.INITIAL_BUILD);
|
||||
}
|
||||
@@ -385,13 +389,11 @@ public class RenderSectionManager {
|
||||
ChunkRenderContext context = WorldSlice.prepare(this.world, render.getChunkPos(), this.sectionCache);
|
||||
int frame = this.currentFrame;
|
||||
|
||||
if (context == null) {
|
||||
return SodiumClientMod.immersiveLoaded ? ImmersiveEmptyChunkChecker.makeEmptyRebuildTask(
|
||||
sectionCache, render.getChunkPos(), render, currentFrame
|
||||
) : new ChunkRenderEmptyBuildTask(render, frame);
|
||||
if (context != null) {
|
||||
return new ChunkRenderRebuildTask(render, context, frame);
|
||||
} else {
|
||||
return new ChunkRenderEmptyBuildTask(render, frame);
|
||||
}
|
||||
|
||||
return new ChunkRenderRebuildTask(render, context, frame);
|
||||
}
|
||||
|
||||
public void markGraphDirty() {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package me.jellysquid.mods.sodium.client.world;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import me.jellysquid.mods.sodium.client.compat.immersive.ImmersiveEmptyChunkChecker;
|
||||
import me.jellysquid.mods.sodium.client.world.biome.BlockColorCache;
|
||||
import me.jellysquid.mods.sodium.client.world.cloned.ChunkRenderContext;
|
||||
import me.jellysquid.mods.sodium.client.world.cloned.ClonedChunkSection;
|
||||
@@ -97,7 +99,11 @@ public class WorldSlice implements BlockRenderView {
|
||||
// If the chunk section is absent or empty, simply terminate now. There will never be anything in this chunk
|
||||
// section to render, so we need to signal that a chunk render task shouldn't created. This saves a considerable
|
||||
// amount of time in queueing instant build tasks and greatly accelerates how quickly the world can be loaded.
|
||||
if (section == null || section.isEmpty()) {
|
||||
boolean isEmpty = section == null || section.isEmpty();
|
||||
if (isEmpty && SodiumClientMod.immersiveLoaded) {
|
||||
isEmpty = !ImmersiveEmptyChunkChecker.hasWires(origin);
|
||||
}
|
||||
if (isEmpty) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user