1
0
mirror of https://github.com/cabaletta/baritone synced 2024-12-26 17:02:24 +00:00

rearranged loop order

This commit is contained in:
Leijurv 2018-09-04 15:23:54 -07:00
parent e7d41ba4fc
commit 69d8bd56fa
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 11 additions and 7 deletions

View File

@ -80,10 +80,12 @@ public final class ChunkPacker implements Helper {
}
BlockStateContainer bsc = extendedblockstorage.getData();
int yReal = y0 << 4;
for (int x = 0; x < 16; x++) {
for (int y1 = 0; y1 < 16; y1++) {
for (int z = 0; z < 16; z++) {
int y = y1 | yReal;
// the mapping of BlockStateContainer.getIndex from xyz to index is y << 8 | z << 4 | x;
// for better cache locality, iterate in that order
for (int y1 = 0; y1 < 16; y1++) {
int y = y1 | yReal;
for (int z = 0; z < 16; z++) {
for (int x = 0; x < 16; x++) {
int index = CachedChunk.getPositionIndex(x, y, z);
IBlockState state = bsc.get(x, y1, z);
boolean[] bits = getPathingBlockType(state).getBits();

View File

@ -73,9 +73,11 @@ public enum WorldScanner implements Helper {
}
int yReal = y0 << 4;
BlockStateContainer bsc = extendedblockstorage.getData();
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {
// the mapping of BlockStateContainer.getIndex from xyz to index is y << 8 | z << 4 | x;
// for better cache locality, iterate in that order
for (int y = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {
for (int x = 0; x < 16; x++) {
IBlockState state = bsc.get(x, y, z);
if (asBlocks.contains(state.getBlock())) {
res.add(new BlockPos(chunkX | x, yReal | y, chunkZ | z));