From f3b4ef14d43df30b68b6a34e64e9cf0f8ff9e669 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Mon, 3 Oct 2022 12:11:40 +0800 Subject: [PATCH] Limit the maximum range of pull ability --- .../atomicstryker/infernalmobs/common/mods/MM_Gravity.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/atomicstryker/infernalmobs/common/mods/MM_Gravity.java b/src/main/java/atomicstryker/infernalmobs/common/mods/MM_Gravity.java index fadb7e01..6d9ff10d 100644 --- a/src/main/java/atomicstryker/infernalmobs/common/mods/MM_Gravity.java +++ b/src/main/java/atomicstryker/infernalmobs/common/mods/MM_Gravity.java @@ -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) { @@ -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; } @@ -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; } } }