Merge pull request #4195 from ZacSharp/pr/1.19.4/worldscanner/fixSingleValuePalette

Fix scanning chunks using a SingleValuePalette
This commit is contained in:
leijurv 2023-11-17 17:50:53 -08:00 committed by GitHub
commit f147519a5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) {