} else { Vector direction = boostedEntity.getLocation().getDirection(); Vector velocity = boostedEntity.getVelocity();
/** * Knocks a target back from damage received (for hacked-in damage applications when required by config). */ public void knockback(LivingEntity entity) { Vector relative = entity.getLocation().toVector().subtract(getLivingEntity().getLocation().toVector()); relative = relative.normalize(); relative.setY(0.75); relative.multiply(0.5 / Math.max(1.0, entity.getVelocity().length())); entity.setVelocity(entity.getVelocity().multiply(0.25).add(relative)); if (SentinelPlugin.debugMe) { debug("applied knockback velocity adder of " + relative); } } }
/** * Fires a pearl from the NPC at a target. */ public void firePearl(LivingEntity target) { sentinel.swingWeapon(); sentinel.faceLocation(target.getEyeLocation()); // TODO: Maybe require entity is-on-ground? sentinel.stats_pearlsUsed++; target.setVelocity(target.getVelocity().add(new Vector(0, sentinel.getDamage(), 0))); }
@Override public boolean onHit(EntityDamageByEntityEvent e, LivingEntity n) { if (SlimefunManager.isItemSimiliar(Variables.arrows.get(e.getDamager().getUniqueId()), SlimefunItems.EXPLOSIVE_BOW, true)) { Vector vector = n.getVelocity(); vector.setY(0.6); n.setVelocity(vector); n.getWorld().createExplosion(n.getLocation(), 0F); n.getWorld().playSound(n.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1F, 1F); return true; } else return false; } });
if (Math.abs(e.getVelocity().getY()) < 1) e.setVelocity(e.getVelocity().setY(0.5));
if (distance != 0.0D) { double motFactor = (1.0D - distancePercent); final Vector velocity = livingEntity.getVelocity(); velocity.multiply(motFactor); new BukkitRunnable() {
if (waw.grabbedEntity != null) { GRABBED_ENTITIES.remove(waw.grabbedEntity); waw.grabbedEntity.setVelocity(waw.grabbedEntity.getVelocity().multiply(2.5));
ItemStack item = itemHelper.getArrow(); if (item != null) { weaponHelper.fireArrow(item, entity.getEyeLocation(), entity.getVelocity()); if (sentinel.needsAmmo) { itemHelper.reduceDurability(); if (SentinelTarget.v1_9) { weaponHelper.firePotion(getLivingEntity().getEquipment().getItemInMainHand(), entity.getEyeLocation(), entity.getVelocity()); entity.getEyeLocation(), entity.getVelocity());