Skip to content

Commit

Permalink
Fix scanning in chunks using a SingleValuePalette
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSharp committed Nov 16, 2023
1 parent 44bcd42 commit 19accb0
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/main/java/baritone/cache/FasterWorldScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
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;
Expand Down Expand Up @@ -191,7 +192,29 @@ private void visitSection(BlockOptionalMetaLookup lookup, LevelChunkSection sect
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;
}
Expand All @@ -202,9 +225,6 @@ private void visitSection(BlockOptionalMetaLookup lookup, LevelChunkSection sect
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) {
Expand Down

0 comments on commit 19accb0

Please sign in to comment.