entity.setVelocity(currentVelocity);
@Override public void setVelocity(Vector arg0) { base.setVelocity(arg0); }
public void setVelocity(Vector arg0) { entity.setVelocity(arg0); }
@EventHandler public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { if (event.getDamager() instanceof Egg) { // If damager is an egg final Entity hurt = event.getEntity(); // Declare entity final so that we can use it in future scheduling Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { // Schedule a delayed task to run in one tick, plugin is main class public void run() { hurt.setVelocity(new Vector(0, 0, 0)); // Set velocity to zero vector, cancelling all motion } }); } }
@Override public void setVelocity(Vector3D velocity) { Vector v = new Vector(velocity.X(), velocity.Y(), velocity.Z()); e.setVelocity(v); }
public static void setVelocity(Entity entity, Vector velocity) { if (!MathUtils.isFinite(velocity.getX()) || !MathUtils.isFinite(velocity.getY()) || !MathUtils.isFinite(velocity.getZ())) { return; } if (Math.abs(velocity.getX()) > MAX_VELOCITY) velocity.setX(MAX_VELOCITY * Math.signum(velocity.getX())); if (Math.abs(velocity.getY()) > MAX_VELOCITY) velocity.setY(MAX_VELOCITY * Math.signum(velocity.getY())); if (Math.abs(velocity.getZ()) > MAX_VELOCITY) velocity.setZ(MAX_VELOCITY * Math.signum(velocity.getZ())); entity.setVelocity(velocity); } }
@Override public void onRun() { Entity entity = getEntity(); if (entity == null) { cancel(); return; } Vector v = entity.getVelocity(); v.setY(v.getY() + power); entity.setVelocity(v); }
@Override public void run() { if (npc.getEntity().getLocation(dummy).getBlock().getType() == Material.LADDER && current.next().getY() > current.previous().getY()) { npc.getEntity().setVelocity(npc.getEntity().getVelocity().setY(0.3)); } } };
private void moveEarth(final Vector apply, final Vector direction) { for (final Entity entity : GeneralMethods.getEntitiesAroundPoint(this.origin, 2)) { if (entity.getEntityId() != this.player.getEntityId()) { entity.setVelocity(apply); } } this.moveEarth(this.origin.clone().subtract(direction), direction, 3, false); }
@Override public void run() { Collection<NPC> nearby = flock.getNearby(npc); if (nearby.isEmpty()) return; Vector base = new Vector(0, 0, 0); for (FlockBehavior behavior : behaviors) { base.add(behavior.getVector(npc, nearby)); } base = clip(maxForce, base); npc.getEntity().setVelocity(npc.getEntity().getVelocity().add(base)); }
private void affect(final Entity entity) { final Vector direction = GeneralMethods.getDirection(this.origin, entity.getLocation()); direction.setY(0); direction.normalize(); entity.setVelocity(entity.getVelocity().clone().add(direction.multiply(this.knockback))); }
private void launch() { final Location location = this.player.getLocation(); for (final Entity entity : TARGETED_ENTITIES.keySet()) { final Location target = entity.getLocation().clone(); Vector vector = new Vector(0, 0, 0); if (location.getWorld().equals(target.getWorld())) { vector = GeneralMethods.getDirection(location, GeneralMethods.getTargetedLocation(this.player, location.distance(target))); } vector.normalize(); entity.setVelocity(vector.multiply(this.throwFactor)); new HorizontalVelocityTracker(entity, this.player, 200, this); } this.remove(); this.bPlayer.addCooldown(this); }
private void affect(final Entity entity) { if (entity instanceof LivingEntity) { DamageHandler.damageEntity(entity, this.damage, this); } final Vector vector = this.direction.clone(); vector.setY(.5); final double knock = this.bPlayer.isAvatarState() ? AvatarState.getValue(this.knockback) : this.knockback; entity.setVelocity(vector.clone().normalize().multiply(knock)); AirAbility.breakBreathbendingHold(entity); }
@Override public void tick(Block b, SlimefunItem item, Config data) { if (b.getType() != Material.HOPPER) { // we're no longer a hopper, we were probably destroyed. skipping this tick. return; } ArmorStand hologram = InfusedHopper.getArmorStand(b, true); boolean sound = false; for (Entity n: hologram.getNearbyEntities(3.5D, 3.5D, 3.5D)) { if (n instanceof Item && !n.hasMetadata("no_pickup") && n.getLocation().distance(hologram.getLocation()) > 0.4D) { n.setVelocity(new Vector(0, 0.1, 0)); n.teleport(hologram); sound = true; } } if (sound) b.getWorld().playSound(b.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 5F, 2F); }
@Override public void run() { if (location.getBlock().getType().equals(Material.SIGN_POST) || location.getBlock().getType().equals(Material.WALL_SIGN)) try { Location entityLocation = entity.getLocation(); entity.setVelocity(new Vector( entityLocation.getX() - location.getX(), entityLocation.getY() - location.getY(), entityLocation.getZ() - location.getZ()) .normalize().multiply(signLayoutConfig.getStrength()).setY(0.2D)); } catch (Exception ex) { ex.printStackTrace(); } } });
private void affect(final Location location) { for (final Entity entity : GeneralMethods.getEntitiesAroundPoint(location, this.attackRange)) { if (entity.getEntityId() == this.player.getEntityId()) { continue; } else if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation())) { continue; } else if (GeneralMethods.isObstructed(location, entity.getLocation())) { continue; } final double knock = this.bPlayer.isAvatarState() ? AvatarState.getValue(this.knockback) : this.knockback; entity.setVelocity(GeneralMethods.getDirection(this.player.getLocation(), location).normalize().multiply(knock)); if (entity instanceof LivingEntity) { DamageHandler.damageEntity(entity, this.damage, this); } AirAbility.breakBreathbendingHold(entity); } }
/** * Fires a snowball from the NPC at a target. */ public void fireSnowball(Location target) { sentinel.swingWeapon(); sentinel.stats_snowballsThrown++; sentinel.faceLocation(target); Vector forward = getLivingEntity().getEyeLocation().getDirection(); Location spawnAt = getLivingEntity().getEyeLocation().clone().add(forward.clone().multiply(sentinel.firingMinimumRange())); Entity ent = spawnAt.getWorld().spawnEntity(spawnAt, EntityType.SNOWBALL); ((Projectile) ent).setShooter(getLivingEntity()); ent.setVelocity(sentinel.fixForAcc(target.clone().subtract(spawnAt).toVector().normalize().multiply(2.0))); // TODO: Fiddle with '2.0'. }
/** * Fires an egg from the NPC at a target. */ public void fireEgg(Location target) { sentinel.swingWeapon(); sentinel.stats_eggsThrown++; sentinel.faceLocation(target); Vector forward = getLivingEntity().getEyeLocation().getDirection(); Location spawnAt = getLivingEntity().getEyeLocation().clone().add(forward.clone().multiply(sentinel.firingMinimumRange())); Entity ent = spawnAt.getWorld().spawnEntity(spawnAt, EntityType.EGG); ((Projectile) ent).setShooter(getLivingEntity()); ent.setVelocity(sentinel.fixForAcc(target.clone().subtract(spawnAt).toVector().normalize().multiply(2.0))); // TODO: Fiddle with '2.0'. }
/** * Fires a fireballs from the NPC at a target. */ public void fireFireball(Location target) { sentinel.swingWeapon(); sentinel.stats_fireballsFired++; sentinel.faceLocation(target); Vector forward = getLivingEntity().getEyeLocation().getDirection(); Location spawnAt = getLivingEntity().getEyeLocation().clone().add(forward.clone().multiply(sentinel.firingMinimumRange())); Entity ent = spawnAt.getWorld().spawnEntity(spawnAt, EntityType.SMALL_FIREBALL); ((Projectile) ent).setShooter(getLivingEntity()); ent.setVelocity(sentinel.fixForAcc(target.clone().subtract(spawnAt).toVector().normalize().multiply(4))); // TODO: Fiddle with '4'. }
/** * Fires a skull from the NPC at a target. */ public void fireSkull(Location target) { sentinel.swingWeapon(); sentinel.stats_skullsThrown++; sentinel.faceLocation(target); Vector forward = getLivingEntity().getEyeLocation().getDirection(); Location spawnAt = getLivingEntity().getEyeLocation().clone().add(forward.clone().multiply(sentinel.firingMinimumRange())); Entity ent = spawnAt.getWorld().spawnEntity(spawnAt, EntityType.WITHER_SKULL); ((Projectile) ent).setShooter(getLivingEntity()); ent.setVelocity(sentinel.fixForAcc(target.clone().subtract(spawnAt).toVector().normalize().multiply(4))); // TODO: Fiddle with '4'. }