rayLength.multiply(exposure); Vector currentVelocity = entity.getVelocity(); currentVelocity.add(rayLength); entity.setVelocity(currentVelocity);
@Override public Vector getVelocity() { return base.getVelocity(); }
public Vector getVelocity() { return entity.getVelocity(); }
Entity arrow = event.getEntity(); Vector velocity = arrow.getVelocity(); Item item = arrow.getWorld().dropItem(arrow.getLocation(), ItemStack); item.setVelocity(velocity);
@Override public Vector getVector(NPC npc, Collection<NPC> nearby) { Vector velocities = new Vector(0, 0, 0); for (NPC neighbor : nearby) { if (!neighbor.isSpawned()) continue; velocities = velocities.add(neighbor.getEntity().getVelocity()); } Vector desired = velocities.multiply((double) 1 / nearby.size()); return desired.subtract(npc.getEntity().getVelocity()).multiply(weight); } }
static boolean collisionDown(Entity e) { Rectangle player = new Rectangle(e.getX(), e.getY() + e.getVelocity(), e.getWidth(), e.getHeight()); for(Block i : Game.blocks) { Rectangle block = new Rectangle(i.getX(), i.getY(), size, size ); if (player.intersects(block)) { //e.goUp(1); return true; } } return false; }
/** * Returns the launch Direction. * * @param entity entity * @return launchDirection */ private Vector getDirection(Entity entity) { final Vector vector = new Vector(); final double rotX = entity.getLocation().getYaw(); final double rotY = entity.getLocation().getPitch(); vector.setY(-Math.sin(Math.toRadians(rotY))); final double h = Math.cos(Math.toRadians(rotY)); vector.setX(-h * Math.sin(Math.toRadians(rotX))); vector.setZ(h * Math.cos(Math.toRadians(rotX))); vector.setY(0.5); vector.add(entity.getVelocity()); return vector.multiply(3); }
@Override public Vector3D getVelocity() { Vector v = e.getVelocity(); return new Vector3D(v.getX(), v.getY(), v.getZ()); }
/** * Returns the launch Direction. * * @param entity entity * @return launchDirection */ private Vector getDirection(Entity entity) { final Vector vector = new Vector(); final double rotX = entity.getLocation().getYaw(); final double rotY = entity.getLocation().getPitch(); vector.setY(-Math.sin(Math.toRadians(rotY))); final double h = Math.cos(Math.toRadians(rotY)); vector.setX(-h * Math.sin(Math.toRadians(rotX))); vector.setZ(h * Math.cos(Math.toRadians(rotX))); vector.setY(0.5); vector.add(entity.getVelocity()); return vector.multiply(3); }
/** * Returns the launch Direction. * * @param entity entity * @return launchDirection */ private Vector getDirection(Entity entity) { final Vector vector = new Vector(); final double rotX = entity.getLocation().getYaw(); final double rotY = entity.getLocation().getPitch(); vector.setY(-Math.sin(Math.toRadians(rotY))); final double h = Math.cos(Math.toRadians(rotY)); vector.setX(-h * Math.sin(Math.toRadians(rotX))); vector.setZ(h * Math.cos(Math.toRadians(rotX))); vector.setY(0.5); vector.add(entity.getVelocity()); return vector.multiply(3); }
/** * Returns the launch Direction. * * @param entity entity * @return launchDirection */ private Vector getDirection(Entity entity) { final Vector vector = new Vector(); final double rotX = entity.getLocation().getYaw(); final double rotY = entity.getLocation().getPitch(); vector.setY(-Math.sin(Math.toRadians(rotY))); final double h = Math.cos(Math.toRadians(rotY)); vector.setX(-h * Math.sin(Math.toRadians(rotX))); vector.setZ(h * Math.cos(Math.toRadians(rotX))); vector.setY(0.5); vector.add(entity.getVelocity()); return vector.multiply(3); }
/** * Returns the launch Direction. * * @param entity entity * @return launchDirection */ private Vector getDirection(Entity entity) { final Vector vector = new Vector(); final double rotX = entity.getLocation().getYaw(); final double rotY = entity.getLocation().getPitch(); vector.setY(-Math.sin(Math.toRadians(rotY))); final double h = Math.cos(Math.toRadians(rotY)); vector.setX(-h * Math.sin(Math.toRadians(rotX))); vector.setZ(h * Math.cos(Math.toRadians(rotX))); vector.setY(0.5); vector.add(entity.getVelocity()); return vector.multiply(3); }
/** * Returns the launch Direction. * * @param entity entity * @return launchDirection */ private Vector getDirection(Entity entity) { final Vector vector = new Vector(); final double rotX = entity.getLocation().getYaw(); final double rotY = entity.getLocation().getPitch(); vector.setY(-Math.sin(Math.toRadians(rotY))); final double h = Math.cos(Math.toRadians(rotY)); vector.setX(-h * Math.sin(Math.toRadians(rotX))); vector.setZ(h * Math.cos(Math.toRadians(rotX))); vector.setY(0.5); vector.add(entity.getVelocity()); return vector.multiply(3); }
/** * Returns the launch Direction. * * @param entity entity * @return launchDirection */ private Vector getDirection(Entity entity) { final Vector vector = new Vector(); final double rotX = entity.getLocation().getYaw(); final double rotY = entity.getLocation().getPitch(); vector.setY(-Math.sin(Math.toRadians(rotY))); final double h = Math.cos(Math.toRadians(rotY)); vector.setX(-h * Math.sin(Math.toRadians(rotX))); vector.setZ(h * Math.cos(Math.toRadians(rotX))); vector.setY(0.5); vector.add(entity.getVelocity()); return vector.multiply(3); }
@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)); } } };
public HorizontalVelocityTracker(final Entity e, final Player instigator, final long delay, final Ability ability) { if (!ProjectKorra.plugin.getConfig().getBoolean("Properties.HorizontalCollisionPhysics.Enabled")) { return; } remove(e); this.entity = e; this.instigator = instigator; this.fireTime = System.currentTimeMillis(); this.delay = delay; this.thisVelocity = e.getVelocity().clone(); this.launchLocation = e.getLocation().clone(); this.impactLocation = this.launchLocation.clone(); this.delay = delay; this.abil = ability; this.update(); instances.put(this.entity, this); }
@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))); }
@Override public Vector getVector(NPC npc, Collection<NPC> nearby) { Vector steering = new Vector(0, 0, 0); Vector pos = npc.getEntity().getLocation().toVector(); int c = 0; for (NPC neighbor : nearby) { if (!neighbor.isSpawned()) continue; double dist = neighbor.getEntity().getLocation().toVector().distance(pos); Vector repulse = pos.subtract(neighbor.getEntity().getLocation().toVector()).normalize() .divide(new Vector(dist, dist, dist)); steering = repulse.add(steering); c++; } steering = steering.divide(new Vector(c, c, c)); return steering.subtract(npc.getEntity().getVelocity()).multiply(weight); } }