Fixed Annihilate infinite vector

This commit is contained in:
Auxilor 2020-12-19 17:21:21 +00:00
parent b07db4c12c
commit 293027fc23

View File

@ -2,6 +2,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.util.VectorUtils;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.util.Vector;
@ -19,7 +20,9 @@ public class Annihilate extends EcoEnchant {
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
double baseMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity-multiplier");
Vector vector = attacker.getLocation().toVector().clone().subtract(victim.getLocation().toVector()).normalize().multiply(level * baseMultiplier).multiply(-1);
if(!VectorUtils.isFinite(vector)) return;
vector.setY(0.2);
if(!VectorUtils.isFinite(vector)) return;
victim.setVelocity(vector);
}
}