crucial performance optimization

This commit is contained in:
Leijurv 2021-01-30 17:22:19 -08:00
parent 91854f97ad
commit a732e766f4
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
1 changed files with 3 additions and 3 deletions

View File

@ -31,7 +31,7 @@ public class GoalRunAway implements Goal {
private final BlockPos[] from; private final BlockPos[] from;
private final double distanceSq; private final int distanceSq;
private final Integer maintainY; private final Integer maintainY;
@ -44,7 +44,7 @@ public class GoalRunAway implements Goal {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
this.from = from; this.from = from;
this.distanceSq = distance * distance; this.distanceSq = (int) (distance * distance);
this.maintainY = maintainY; this.maintainY = maintainY;
} }
@ -56,7 +56,7 @@ public class GoalRunAway implements Goal {
for (BlockPos p : from) { for (BlockPos p : from) {
int diffX = x - p.getX(); int diffX = x - p.getX();
int diffZ = z - p.getZ(); int diffZ = z - p.getZ();
double distSq = diffX * diffX + diffZ * diffZ; int distSq = diffX * diffX + diffZ * diffZ;
if (distSq < distanceSq) { if (distSq < distanceSq) {
return false; return false;
} }