Optimize ArrowStopper #282
|
@ -61,18 +61,23 @@ public class ArrowStopper {
|
||||||
|
|
||||||
private boolean checkBlocks(Block start, Block end) {
|
private boolean checkBlocks(Block start, Block end) {
|
||||||
Block cursor = start;
|
Block cursor = start;
|
||||||
|
BlockFace from = BlockFace.SELF;
|
||||||
|
|
||||||
while (!cursor.getLocation().equals(end.getLocation())) {
|
while (!cursor.getLocation().equals(end.getLocation())) {
|
||||||
BlockFace nearest = BlockFace.SELF;
|
BlockFace nearest = BlockFace.SELF;
|
||||||
double nearestDistance = cursor.getLocation().distance(end.getLocation());
|
double nearestDistance = cursor.getLocation().distanceSquared(end.getLocation());
|
||||||
for (BlockFace face : BLOCK_FACES) {
|
for (BlockFace face : BLOCK_FACES) {
|
||||||
|
if(face == from) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Block relative = cursor.getRelative(face);
|
Block relative = cursor.getRelative(face);
|
||||||
double distance = relative.getLocation().distance(end.getLocation());
|
double distance = relative.getLocation().distanceSquared(end.getLocation());
|
||||||
if(distance < nearestDistance) {
|
if(distance < nearestDistance) {
|
||||||
nearestDistance = distance;
|
nearestDistance = distance;
|
||||||
nearest = face;
|
nearest = face;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
from = nearest.getOppositeFace();
|
||||||
cursor = cursor.getRelative(nearest);
|
cursor = cursor.getRelative(nearest);
|
||||||
if(checkBlock(cursor))
|
if(checkBlock(cursor))
|
||||||
return true;
|
return true;
|
||||||
|
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren