world scanner do 1 chunk only if blocks at same y have been found

This commit is contained in:
Leijurv 2018-09-14 12:24:53 -07:00
parent 1bd15e5d5b
commit 7d94cb259f
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -44,8 +44,10 @@ public enum WorldScanner implements Helper {
int playerChunkX = playerFeet().getX() >> 4;
int playerChunkZ = playerFeet().getZ() >> 4;
int playerY = playerFeet().getY();
int searchRadiusSq = 0;
boolean foundWithinY = false;
while (true) {
boolean allUnloaded = true;
for (int xoff = -searchRadiusSq; xoff <= searchRadiusSq; xoff++) {
@ -78,7 +80,11 @@ public enum WorldScanner implements Helper {
for (int x = 0; x < 16; x++) {
IBlockState state = bsc.get(x, y, z);
if (blocks.contains(state.getBlock())) {
res.add(new BlockPos(chunkX | x, yReal | y, chunkZ | z));
int yy = yReal | y;
res.add(new BlockPos(chunkX | x, yy, chunkZ | z));
if (Math.abs(yy - playerY) < 10) {
foundWithinY = true;
}
}
}
}
@ -89,7 +95,7 @@ public enum WorldScanner implements Helper {
if (allUnloaded) {
return res;
}
if (res.size() >= max && searchRadiusSq > 26) {
if (res.size() >= max && (searchRadiusSq > 26 || (searchRadiusSq > 1 && foundWithinY))) {
return res;
}
searchRadiusSq++;