Improve Tracking
Dieser Commit ist enthalten in:
Ursprung
6d9a8683db
Commit
7b055a37be
@ -37,7 +37,7 @@ public class ArrowStopper extends BasicListener {
|
||||
|
||||
private BukkitTask task;
|
||||
private static final Vector NULL_VECTOR = new Vector(0, 0, 0);
|
||||
|
||||
private static final BlockFace[] BLOCK_FACES = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
|
||||
public ArrowStopper() {
|
||||
super(Config.TechhiderActive ? EnumSet.of(FightState.RUNNING) : EnumSet.noneOf(FightState.class));
|
||||
}
|
||||
@ -74,28 +74,20 @@ public class ArrowStopper extends BasicListener {
|
||||
private boolean checkBlocks(Block start, Block end) {
|
||||
Block cursor = start;
|
||||
|
||||
while (cursor.getY() != end.getY()) {
|
||||
boolean negativ = cursor.getY() - end.getY() < 0;
|
||||
BlockFace face = negativ?BlockFace.UP:BlockFace.DOWN;
|
||||
if(checkBlock(cursor))
|
||||
return true;
|
||||
cursor = cursor.getRelative(face);
|
||||
while (!cursor.getLocation().equals(end.getLocation())) {
|
||||
BlockFace nearest = BlockFace.SELF;
|
||||
double nearestDistance = cursor.getLocation().distance(end.getLocation());
|
||||
for (BlockFace face : BLOCK_FACES) {
|
||||
Block relative = cursor.getRelative(face);
|
||||
double distance = relative.getLocation().distance(end.getLocation());
|
||||
if(distance < nearestDistance) {
|
||||
nearestDistance = distance;
|
||||
nearest = face;
|
||||
}
|
||||
|
||||
while (cursor.getX() != end.getX()) {
|
||||
boolean negativ = cursor.getX() - end.getX() < 0;
|
||||
BlockFace face = negativ?BlockFace.EAST:BlockFace.WEST;
|
||||
if(checkBlock(cursor))
|
||||
return true;
|
||||
cursor = cursor.getRelative(face);
|
||||
}
|
||||
|
||||
while (cursor.getZ() != end.getZ()) {
|
||||
boolean negativ = cursor.getZ() - end.getZ() < 0;
|
||||
BlockFace face = negativ?BlockFace.SOUTH:BlockFace.NORTH;
|
||||
cursor = cursor.getRelative(nearest);
|
||||
if(checkBlock(cursor))
|
||||
return true;
|
||||
cursor = cursor.getRelative(face);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren