diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java index 9defc2bc..8790686a 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java @@ -180,7 +180,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab } } - private double getHorizontalMotion() { + public double getHorizontalMotion() { return lastVel.horizontalLengthSquared(); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java index 0080544d..dc8a959a 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java @@ -452,11 +452,22 @@ public class Pony extends Living implements Copyable, Update @Override public boolean canBeSeenBy(Entity entity) { - if (entity instanceof HostileEntity && getActualSpecies() == Race.BAT) { - float velocityScale = MathHelper.clamp((float)this.entity.getVelocity().horizontalLength(), 0, 5) / 5F; - float lightScale = asWorld().getLightLevel(getPhysics().getHeadPosition()) / 15F; + if (entity instanceof HostileEntity hostile + && getActualSpecies() == Race.BAT + && hostile.getTarget() != this.entity + && hostile.getAttacker() != this.entity + && entity.distanceTo(this.entity) > entity.getWidth()) { + if (entity.isSneaking() && entity.distanceTo(this.entity) > 4) { + return false; + } - if (((velocityScale + lightScale) / 2F) < 0.6F) { + float vel = (float)getPhysics().getHorizontalMotion(); + float velocityScale = MathHelper.clamp(vel * 15, 0, 1); + int light = asWorld().getLightLevel(getPhysics().getHeadPosition()); + float lightScale = light / 15F; + float approachFactor = ((velocityScale + lightScale) / 2F); + + if (approachFactor < (entity.isSneaking() ? 0.8F : 0.6F)) { return false; } }