chunk check optimization
This commit is contained in:
parent
8d1570a11b
commit
fb04ec6ff4
@ -113,15 +113,18 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
BetterBlockPos dest = (BetterBlockPos) movementToGetToNeighbor.getDest();
|
BetterBlockPos dest = (BetterBlockPos) movementToGetToNeighbor.getDest();
|
||||||
boolean isPositionCached = false;
|
if (dest.x >> 4 != currentNodePos.x >> 4 || dest.z >> 4 != currentNodePos.z >> 4) {
|
||||||
if (world != null) {
|
// only need to check if the destination is a loaded chunk if it's in a different chunk than the start of the movement
|
||||||
if (world.isCached(dest)) {
|
boolean isPositionCached = false;
|
||||||
isPositionCached = true;
|
if (world != null) {
|
||||||
|
if (world.isCached(dest)) {
|
||||||
|
isPositionCached = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isPositionCached && Minecraft.getMinecraft().world.getChunk(dest) instanceof EmptyChunk) {
|
||||||
|
numEmptyChunk++;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!isPositionCached && Minecraft.getMinecraft().world.getChunk(dest) instanceof EmptyChunk) {
|
|
||||||
numEmptyChunk++;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
//long costStart = System.nanoTime();
|
//long costStart = System.nanoTime();
|
||||||
// TODO cache cost
|
// TODO cache cost
|
||||||
|
@ -27,9 +27,9 @@ import net.minecraft.util.math.Vec3i;
|
|||||||
* @author leijurv
|
* @author leijurv
|
||||||
*/
|
*/
|
||||||
public class BetterBlockPos extends BlockPos {
|
public class BetterBlockPos extends BlockPos {
|
||||||
private final int x;
|
public final int x;
|
||||||
private final int y;
|
public final int y;
|
||||||
private final int z;
|
public final int z;
|
||||||
private final int hashCode;
|
private final int hashCode;
|
||||||
|
|
||||||
public BetterBlockPos(int x, int y, int z) {
|
public BetterBlockPos(int x, int y, int z) {
|
||||||
|
Loading…
Reference in New Issue
Block a user