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