Skip to content

Commit

Permalink
Merge pull request #11 from GTNewHorizons/feature/pull-range-limit
Browse files Browse the repository at this point in the history
Limit the maximum range of pull ability
  • Loading branch information
Dream-Master committed Oct 3, 2022
2 parents 5992594 + f3b4ef1 commit acce825
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 acce825

Please sign in to comment.