Fix scanning in chunks using a SingleValuePalette

This commit is contained in:
ZacSharp 2023-11-16 23:21:01 +01:00
parent 44bcd4251d
commit 19accb0d90
No known key found for this signature in database
GPG Key ID: 9453647B005083A3
1 changed files with 24 additions and 4 deletions

View File

@ -38,6 +38,7 @@ import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.chunk.Palette;
import net.minecraft.world.level.chunk.PalettedContainer;
import net.minecraft.world.level.chunk.SingleValuePalette;
import java.util.ArrayList;
import java.util.List;
@ -191,7 +192,29 @@ public enum FasterWorldScanner implements IWorldScanner {
return;
}
boolean[] isInFilter = getIncludedFilterIndices(lookup, ((IPalettedContainer<BlockState>) sectionContainer).getPalette());
int yOffset = section.bottomBlockY();
Palette<BlockState> palette = ((IPalettedContainer<BlockState>) sectionContainer).getPalette();
if (palette instanceof SingleValuePalette) {
// single value palette doesn't have any data
if (lookup.has(palette.valueFor(0))) {
// TODO this is 4k hits, maybe don't return all of them?
for (int x = 0; x < 16; ++x) {
for (int y = 0; y < 16; ++y) {
for (int z = 0; z < 16; ++z) {
blocks.add(new BlockPos(
(int) chunkX + x,
yOffset + y,
(int) chunkZ + z
));
}
}
}
}
return;
}
boolean[] isInFilter = getIncludedFilterIndices(lookup, palette);
if (isInFilter.length == 0) {
return;
}
@ -202,9 +225,6 @@ public enum FasterWorldScanner implements IWorldScanner {
int bitsPerEntry = array.getBits();
long maxEntryValue = (1L << bitsPerEntry) - 1L;
int yOffset = section.bottomBlockY();
for (int i = 0, idx = 0; i < longArray.length && idx < arraySize; ++i) {
long l = longArray[i];
for (int offset = 0; offset <= (64 - bitsPerEntry) && idx < arraySize; offset += bitsPerEntry, ++idx) {