mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-27 09:42:37 +01:00
Modify blockbreaker distance calculations
This commit is contained in:
parent
659a5b17ad
commit
8c4b72c5f8
@ -49,10 +49,6 @@ public abstract class AbstractBlockBreaker extends BlockBreaker {
|
||||
setTarget = false;
|
||||
}
|
||||
|
||||
private double distance() {
|
||||
return entity.getLocation().distance(Util.getCenterLocation(location.getBlock()));
|
||||
}
|
||||
|
||||
protected abstract float getDamage(int tickDifference);
|
||||
|
||||
protected ItemStack getItemStack() {
|
||||
@ -60,6 +56,13 @@ public abstract class AbstractBlockBreaker extends BlockBreaker {
|
||||
: entity instanceof LivingEntity ? ((LivingEntity) entity).getEquipment().getItemInHand() : null;
|
||||
}
|
||||
|
||||
private boolean inRange() {
|
||||
Location center = Util.getCenterLocation(location.getBlock());
|
||||
Location loc = entity.getLocation();
|
||||
double xz = Math.sqrt(Math.pow(center.getX() - loc.getX(), 2) + Math.pow(center.getZ() - loc.getZ(), 2));
|
||||
return xz <= configuration.radius() && Math.abs(center.getY() - loc.getY()) <= 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
cancelNavigation();
|
||||
@ -80,7 +83,7 @@ public abstract class AbstractBlockBreaker extends BlockBreaker {
|
||||
}
|
||||
currentTick = (int) (System.currentTimeMillis() / 50);
|
||||
if (configuration.radius() > 0) {
|
||||
if (distance() >= configuration.radius()) {
|
||||
if (!inRange()) {
|
||||
startDigTick = currentTick;
|
||||
if (entity instanceof NPCHolder) {
|
||||
NPC npc = ((NPCHolder) entity).getNPC();
|
||||
|
Loading…
Reference in New Issue
Block a user