Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@ public final class GreedyRuntimeState {
private GreedyRuntimeState() {
}

private static final boolean FLAT_LIGHTING_LOADED = FabricLoader.getInstance().isModLoaded("flat-lighting");
private static volatile boolean flatLighting;
private static volatile long flatLightingCheckNanos;

/** True when Flat Lighting is installed and its cardinal lighting is off (reads its config only, re-read at most once a second). */
public static boolean isFlatLighting() {
if (!FLAT_LIGHTING_LOADED) {
return false;
}
long now = System.nanoTime();
if (now - flatLightingCheckNanos > 1_000_000_000L) {
flatLightingCheckNanos = now;
try {
flatLighting = java.nio.file.Files.readString(FabricLoader.getInstance().getConfigDir().resolve("flat-lighting.json"))
.replace(" ", "").contains("\"cardinalLighting\":false");
} catch (Exception e) {
flatLighting = false;
}
}
return flatLighting;
}

public static boolean isRuntimeGreedyActive() {
return GreedyConfig.enabled();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ protected abstract BufferBuilder getOrBeginLayer(
int baseY = work.baseY();
int baseZ = work.baseZ();
work.scratchLighting.applyDirectionalShade =
!GreedyRuntimeState.isInSableSubLevel(baseX >> 4, baseZ >> 4);
!GreedyRuntimeState.isInSableSubLevel(baseX >> 4, baseZ >> 4)
&& !GreedyRuntimeState.isFlatLighting();

long[][] mergeKeys = work.faceMergeKeys();
populateFaceVisibility(renderSectionRegion, work.sectionStates(), work.visibleFaces(), mergeKeys, baseX, baseY, baseZ, work.eligibleIndices(), work.eligibleCount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ public abstract class SodiumChunkBuilderMeshingTaskMixin {
int baseY = work.sectionOrigin().getY();
int baseZ = work.sectionOrigin().getZ();
work.scratchLighting.applyDirectionalShade =
!GreedyRuntimeState.isInSableSubLevel(baseX >> 4, baseZ >> 4);
!GreedyRuntimeState.isInSableSubLevel(baseX >> 4, baseZ >> 4)
&& !GreedyRuntimeState.isFlatLighting();
BitSet[] visibleFaces = GREEDY_MESHING$VISIBLE.get();
long[][] mergeKeys = work.faceMergeKeys();
GreedySectionCache sectionCache = work.sectionCache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ public abstract class VulkanBuildTaskMixin {
int baseY = origin.getY();
int baseZ = origin.getZ();
work.scratchLighting.applyDirectionalShade =
!GreedyRuntimeState.isInSableSubLevel(baseX >> 4, baseZ >> 4);
!GreedyRuntimeState.isInSableSubLevel(baseX >> 4, baseZ >> 4)
&& !GreedyRuntimeState.isFlatLighting();
BitSet[] visibleFaces = GREEDY_MESHING$VISIBLE.get();
long[][] mergeKeys = work.faceMergeKeys();
populateFaceVisibility(world, work.sectionStates(), visibleFaces, mergeKeys, baseX, baseY, baseZ);
Expand Down
Loading