Skip to content

Commit 698d2f3

Browse files
committed
fix weird black spots in the world
1 parent fe0a69d commit 698d2f3

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

src/main/java/com/falsepattern/lumi/internal/ArrayHelper.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,17 @@
2626

2727
import org.jetbrains.annotations.Contract;
2828
import org.jetbrains.annotations.NotNull;
29+
import org.jetbrains.annotations.Nullable;
30+
31+
import net.minecraft.world.chunk.NibbleArray;
2932

3033
public class ArrayHelper {
34+
public static boolean isEmpty(@Nullable NibbleArray arr) {
35+
if (arr == null) {
36+
return true;
37+
}
38+
return isZero(arr.data);
39+
}
3140
@Contract(pure = true)
3241
public static boolean isZero(byte @NotNull [] arr) {
3342
for (int i = 0; i < arr.length; i++) {

src/main/java/com/falsepattern/lumi/internal/mixin/mixins/common/ExtendedBlockStorageMixin.java

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
package com.falsepattern.lumi.internal.mixin.mixins.common;
2626

27+
import com.falsepattern.lumi.internal.ArrayHelper;
2728
import lombok.val;
2829
import net.minecraft.world.EnumSkyBlock;
2930
import net.minecraft.world.chunk.NibbleArray;
@@ -189,26 +190,12 @@ public boolean isEmpty() {
189190
return false;
190191

191192
if (lumi$isDirty) {
192-
val blockLightEqual = lumi$checkLightArrayEqual(blocklightArray, EnumSkyBlock.Block);
193-
val skyLightEqual = lumi$checkLightArrayEqual(skylightArray, EnumSkyBlock.Sky);
194-
lumi$isTrivial = blockLightEqual && skyLightEqual;
193+
val blockLightEmpty = ArrayHelper.isEmpty(blocklightArray);
194+
val skyLightEmpty = ArrayHelper.isEmpty(skylightArray);
195+
lumi$isTrivial = blockLightEmpty && skyLightEmpty;
195196
lumi$isDirty = false;
196197
}
197198

198199
return lumi$isTrivial;
199200
}
200-
201-
@Unique
202-
private boolean lumi$checkLightArrayEqual(NibbleArray storage, EnumSkyBlock baseLightType) {
203-
if (storage == null)
204-
return true;
205-
206-
val expectedValue = (byte) baseLightType.defaultLightValue;
207-
val data = storage.data;
208-
for (val value : data)
209-
if (value != expectedValue)
210-
return false;
211-
212-
return true;
213-
}
214201
}

0 commit comments

Comments
 (0)