From fe740cac67af33c269000c2fc0f2f9e7dca5ab2b Mon Sep 17 00:00:00 2001 From: Auxilor Date: Mon, 14 Sep 2020 19:57:16 +0100 Subject: [PATCH] Fixed infinite vectors for hook and reel --- .../ecoenchants/enchantments/ecoenchants/normal/Hook.java | 5 ++++- .../ecoenchants/enchantments/ecoenchants/normal/Reel.java | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hook.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hook.java index 67cc92b1..7ab55967 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hook.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Hook.java @@ -5,6 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; +import com.willfp.ecoenchants.util.VectorUtils; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -45,6 +46,8 @@ public class Hook extends EcoEnchant { double baseMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-multiplier"); Vector vector = player.getLocation().toVector().clone().subtract(victim.getLocation().toVector()).normalize().multiply(level * baseMultiplier); - victim.setVelocity(vector); + if(VectorUtils.isFinite(vector)) { + victim.setVelocity(vector); + } } } diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reel.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reel.java index 0377f314..4d4bc9e3 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reel.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Reel.java @@ -5,6 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.integrations.antigrief.AntigriefManager; +import com.willfp.ecoenchants.util.VectorUtils; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -41,6 +42,8 @@ public class Reel extends EcoEnchant { double baseMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-multiplier"); Vector vector = player.getLocation().toVector().clone().subtract(victim.getLocation().toVector()).normalize().multiply(level * baseMultiplier); - victim.setVelocity(vector); + if(VectorUtils.isFinite(vector)) { + victim.setVelocity(vector); + } } }