12
1

Optimize ArrowStopper #282

Geschlossen
Chaoscaot möchte 4 Commits von optimize_arrowstopper nach master mergen
Nur Änderungen aus Commit 0c9a67a28e werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -65,13 +65,13 @@ public class ArrowStopper {
while (!cursor.getLocation().equals(end.getLocation())) { while (!cursor.getLocation().equals(end.getLocation())) {
BlockFace nearest = BlockFace.SELF; BlockFace nearest = BlockFace.SELF;
double nearestDistance = getSquareDistance(cursor.getLocation(), end.getLocation()); double nearestDistance = cursor.getLocation().distanceSquared(end.getLocation());
for (BlockFace face : BLOCK_FACES) { for (BlockFace face : BLOCK_FACES) {
if(face == from) { if(face == from) {
continue; continue;
} }
Block relative = cursor.getRelative(face); Block relative = cursor.getRelative(face);
double distance = getSquareDistance(relative.getLocation(), end.getLocation()); double distance = relative.getLocation().distanceSquared(end.getLocation());
if(distance < nearestDistance) { if(distance < nearestDistance) {
nearestDistance = distance; nearestDistance = distance;
nearest = face; nearest = face;
@ -86,10 +86,6 @@ public class ArrowStopper {
return false; return false;
} }
private double getSquareDistance(Location loc1, Location loc2) {
return loc1.getX() * loc2.getX() + loc1.getY() * loc2.getY() + loc1.getZ() * loc2.getZ();
}
private boolean checkBlock(Block block) { private boolean checkBlock(Block block) {
Chaoscaot markierte diese Unterhaltung als gelöst Veraltet
Veraltet
Review

Location#distanceSquared(Location)

Location#distanceSquared(Location)
return Config.HiddenBlocks.contains(block.getType().name().toLowerCase()); return Config.HiddenBlocks.contains(block.getType().name().toLowerCase());
} }