Skip to content

Commit

Permalink
Don't create render chunks for air sections
Browse files Browse the repository at this point in the history
  • Loading branch information
StewStrong committed Oct 15, 2023
1 parent abe814e commit babd287
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import net.minecraft.core.BlockPos;
import net.minecraft.core.Vec3i;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.LevelChunkSection;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector3dc;
import org.spongepowered.asm.mixin.Final;
Expand Down Expand Up @@ -122,7 +124,13 @@ private void addShipVisibleChunks(
}

shipObject.getActiveChunksSet().forEach((x, z) -> {
final ChunkAccess chunk = level.getChunk(x, z);
for (int y = level.getMinSection(); y < level.getMaxSection(); y++) {
final LevelChunkSection levelChunkSection = chunk.getSection(y - level.getMinSection());
if (levelChunkSection.hasOnlyAir()) {
// Skip air sections
continue;
}
tempPos.set(x << 4, y << 4, z << 4);
final ChunkRenderDispatcher.RenderChunk renderChunk =
chunkStorageAccessor.callGetRenderChunkAt(tempPos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand All @@ -35,9 +36,11 @@ public class MixinViewAreaVanilla implements IVSViewAreaMethods {
protected int chunkGridSizeY;

// Maps chunk position to an array of BuiltChunk, indexed by the y value.
@Unique
private final Long2ObjectMap<ChunkRenderDispatcher.RenderChunk[]> vs$shipRenderChunks =
new Long2ObjectOpenHashMap<>();
// This creates render chunks
@Unique
private ChunkRenderDispatcher vs$chunkBuilder;

/**
Expand Down

0 comments on commit babd287

Please sign in to comment.