Skip to content

Commit

Permalink
Limit the maximum range of pull ability
Browse files Browse the repository at this point in the history
  • Loading branch information
Glease committed Oct 3, 2022
1 parent 5992594 commit f3b4ef1
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class MM_Gravity extends MobModifier
{
private long nextAbilityUse = 0L;
private static long coolDown;
private static double maxDistanceSquared;

public MM_Gravity(@Nullable MobModifier next)
{
Expand Down Expand Up @@ -52,7 +53,7 @@ public float onHurt(EntityLivingBase mob, DamageSource source, float damage)

private void tryAbility(EntityLivingBase mob, EntityLivingBase target)
{
if (target == null || !mob.canEntityBeSeen(target))
if (target == null || !mob.canEntityBeSeen(target) || mob.getDistanceSqToEntity(target) >= maxDistanceSquared)
{
return;
}
Expand Down Expand Up @@ -134,6 +135,8 @@ public MM_Gravity make(@Nullable MobModifier next) {
@Override
public void loadConfig(Configuration config) {
coolDown = config.get(getModifierClassName(), "coolDownMillis", 5000L, "Time between ability uses").getInt(5000) / 50;
double maxDistance = config.get(getModifierClassName(), "maxDistance", 40, "Range of ability.").getDouble(40);
maxDistanceSquared = maxDistance * maxDistance;
}
}
}

0 comments on commit f3b4ef1

Please sign in to comment.