/** * Get a new block vector. * * @return vector */ @Override public BlockVector clone() { return (BlockVector) super.clone(); }
/** * Sets the velocity that the entity will have after exiting the portal. */ public void setAfter(Vector after) { this.after = after.clone(); }
/** * Gets the velocity. * <p> * Note: Modifying the returned Vector will not change the velocity, you * must use {@link #setVelocity(org.bukkit.util.Vector)} instead. * * @return A Vector for the dispensed item's velocity */ public Vector getVelocity() { return velocity.clone(); }
/** * Gets a copy of the velocity that the entity has before entering the * portal. * * @return velocity of entity before entering portal */ public Vector getBefore() { return this.before.clone(); }
/** * Gets a copy of the velocity that the entity will have after exiting the * portal. * * @return velocity of entity after exiting portal */ public Vector getAfter() { return this.after.clone(); }
@Override public Vector getVelocity() { return velocity.clone(); }
/** * Returns the displacement of the maximum corner from the minimum corner. * @return the displacement of the maximum corner from the minimum corner */ public Vector getSize() { return maxCorner.clone().subtract(minCorner); }
/** * Creates a bounding box given its minimum corner and its size. * @param pos the minimum corner * @param size the displacement of the maximum corner from the minimum corner * @return a bounding box from {@code pos} to {@code pos.clone().add(size)} */ public static BoundingBox fromPositionAndSize(Vector pos, Vector size) { BoundingBox box = new BoundingBox(); box.minCorner.copy(pos); box.maxCorner.copy(pos.clone().add(size)); return box; }
private int countAvailableBlocks(Vector from, Vector to, World world) { int n = 0; Vector target = to.subtract(from); int maxDistance = Math.max(Math.abs(target.getBlockY()), Math.max(Math.abs(target.getBlockX()), Math.abs(target.getBlockZ()))); float dx = (float) target.getX() / maxDistance; float dy = (float) target.getY() / maxDistance; float dz = (float) target.getZ() / maxDistance; for (int i = 0; i <= maxDistance; i++, n++) { target = from.clone() .add(new Vector((double) (0.5F + i * dx), 0.5F + i * dy, 0.5F + i * dz)); if (target.getBlockY() < 0 || target.getBlockY() > 255 || !overridables.contains(blockTypeAt( target.getBlockX(), target.getBlockY(), target.getBlockZ(), world))) { return n; } } return -1; }
/** * Maps {0, 0, 0} to {0, 1, 0} and all other vectors to their normalized form. * * @param ray the ray to transform * @return a ray of length 1 */ public static Vector getVelocityRay(Vector ray) { Vector velocityRay = ray.clone(); if (velocityRay.lengthSquared() == 0) { velocityRay.setX(0); velocityRay.setY(1); velocityRay.setZ(0); } else { velocityRay.normalize(); } return velocityRay; }
float dz = (float) branch.getZ() / maxDistance; for (int i = 0; i <= maxDistance; i++) { branch = base.clone().add( new Vector(0.5 + i * dx, 0.5 + i * dy, 0.5 + i * dz)); int x = Math.abs(branch.getBlockX() - base.getBlockX());
Vector movement = this.movement.clone(); movement.multiply(mag);
.callEvent(new EntityPortalExitEvent(this, previousLocation, location .clone(), velocity.clone(), new Vector())); if (!e.getAfter().equals(velocity)) { setVelocity(e.getAfter());
this.maxDistance = maxDistance; Vector startClone = start.clone();
/** * Get a new block vector. * * @return vector */ @Override public BlockVector clone() { return (BlockVector) super.clone(); }
/** * Gets a copy of the velocity that the entity has before entering the * portal. * * @return velocity of entity before entering portal */ public Vector getBefore() { return this.before.clone(); }
/** * Gets a copy of the velocity that the entity will have after exiting the * portal. * * @return velocity of entity after exiting portal */ public Vector getAfter() { return this.after.clone(); }
@Nullable protected Vector getIntersection(double fDst1, double fDst2, Vector p1, Vector p2, int side) { if ((fDst1 * fDst2) >= 0.0f) return null; if (fDst1 == fDst2) return null; Vector p2Clone = p2.clone(); p2Clone = p1.clone().add(p2Clone.subtract(p1).multiply(-fDst1 / (fDst2 - fDst1))); return inBox(p2Clone, side) ? p2Clone : null; }
void setVelocity(Vector velocity) { try { this.times = (int) (50 * this.ball.getMeta().getModifiers().getRollingDistanceModifier()); this.getSpigotEntity().setVelocity(velocity); final Vector normalized = velocity.clone().normalize(); this.originVector = velocity.clone(); this.reduceVector = new Vector(normalized.getX() / this.times , 0.0784 * this.ball.getMeta().getModifiers().getGravityModifier() , normalized.getZ() / this.times); } catch (IllegalArgumentException ignored) { } }
void setVelocity(Vector velocity) { try { this.times = (int) (50 * this.ball.getMeta().getModifiers().getRollingDistanceModifier()); this.getSpigotEntity().setVelocity(velocity); final Vector normalized = velocity.clone().normalize(); this.originVector = velocity.clone(); this.reduceVector = new Vector(normalized.getX() / this.times , 0.0784 * this.ball.getMeta().getModifiers().getGravityModifier() , normalized.getZ() / this.times); } catch (IllegalArgumentException ignored) { } }