rename methods

This commit is contained in:
xGinko 2024-04-28 19:08:47 +02:00
parent 02b4675fa0
commit c7ee42f150
3 changed files with 9 additions and 9 deletions

View File

@ -114,7 +114,7 @@ public class OptimizeByBlock implements VillagerOptimizerModule, Listener {
final Villager.Profession profession = villager.getProfession();
if (profession.equals(Villager.Profession.NONE) || profession.equals(Villager.Profession.NITWIT)) continue;
final double distance = LocationUtil.relDistanceSquared3D(villager.getLocation(), blockLoc);
final double distance = LocationUtil.relDistance3DSquared(villager.getLocation(), blockLoc);
if (distance >= closestDistance) continue;
final WrappedVillager wVillager = villagerCache.getOrAdd(villager);
@ -181,7 +181,7 @@ public class OptimizeByBlock implements VillagerOptimizerModule, Listener {
double closestDistance = Double.MAX_VALUE;
for (Villager villager : blockLoc.getNearbyEntitiesByType(Villager.class, search_radius)) {
final double distance = LocationUtil.relDistanceSquared3D(villager.getLocation(), blockLoc);
final double distance = LocationUtil.relDistance3DSquared(villager.getLocation(), blockLoc);
if (distance >= closestDistance) continue;
final WrappedVillager wVillager = villagerCache.getOrAdd(villager);

View File

@ -110,7 +110,7 @@ public class OptimizeByWorkstation implements VillagerOptimizerModule, Listener
WrappedVillager wrapped = villagerCache.getOrAdd(villager);
if (wrapped.getJobSite() == null) continue;
if (wrapped.getJobSite().getWorld() != workstationLoc.getWorld()) continue;
if (LocationUtil.relDistanceSquared3D(wrapped.getJobSite(), workstationLoc) > 1) continue;
if (LocationUtil.relDistance3DSquared(wrapped.getJobSite(), workstationLoc) > 1) continue;
if (!wrapped.canOptimize(cooldown_millis) && !player.hasPermission(Permissions.Bypass.WORKSTATION_COOLDOWN.get())) {
wrapped.sayNo();
@ -178,7 +178,7 @@ public class OptimizeByWorkstation implements VillagerOptimizerModule, Listener
for (Villager villager : workstationLoc.getNearbyEntitiesByType(Villager.class, search_radius)) {
if (!villager.getProfession().equals(workstationProfession)) continue;
final double distance = LocationUtil.relDistanceSquared3D(villager.getLocation(), workstationLoc);
final double distance = LocationUtil.relDistance3DSquared(villager.getLocation(), workstationLoc);
if (distance >= closestDistance) continue;
WrappedVillager wrapped = villagerCache.getOrAdd(villager);

View File

@ -11,7 +11,7 @@ public class LocationUtil {
return "[" + location.getWorld().getName() + "] x=" + location.getBlockX() + ", y=" + location.getBlockY() + ", z=" + location.getBlockZ();
}
public static double relDistanceSquared2D(@NotNull Location from, @NotNull Location to) {
public static double relDistance2DSquared(@NotNull Location from, @NotNull Location to) {
double toX = to.getX();
double toZ = to.getZ();
double fromX = from.getX();
@ -32,7 +32,7 @@ public class LocationUtil {
return NumberConversions.square(toX - fromX) + NumberConversions.square(toZ - fromZ);
}
public static double relDistanceSquared3D(@NotNull Location from, @NotNull Location to) {
public static double relDistance3DSquared(@NotNull Location from, @NotNull Location to) {
double toY = to.getY();
double fromY = from.getY();
@ -46,14 +46,14 @@ public class LocationUtil {
if (toY > from.getWorld().getMaxHeight())
toY = from.getWorld().getMaxHeight();
return relDistanceSquared2D(from, to) + NumberConversions.square(toY - fromY);
return relDistance2DSquared(from, to) + NumberConversions.square(toY - fromY);
}
public static double relDistance2D(@NotNull Location from, @NotNull Location to) {
return Math.sqrt(relDistanceSquared2D(from, to));
return Math.sqrt(relDistance2DSquared(from, to));
}
public static double relDistance3D(@NotNull Location from, @NotNull Location to) {
return Math.sqrt(relDistanceSquared3D(from, to));
return Math.sqrt(relDistance3DSquared(from, to));
}
}