Package org.bukkit.util

Examples of org.bukkit.util.Vector


        float bY = (float) (vec.getY() * cospitch - vec.getX() * sinpitch);
        return new Vector(bX * cosyaw - vec.getZ() * sinyaw, bY, bX * sinyaw + vec.getZ() * cosyaw);
    }

    public static double launchAngle(Location from, Vector to, double v, double elev, double g) {
        Vector victor = from.toVector().subtract(to);
        Double dist = Math.sqrt(Math.pow(victor.getX(), 2) + Math.pow(victor.getZ(), 2));
        double v2 = Math.pow(v,2);
        double v4 = Math.pow(v,4);
        double derp = g * (g * Math.pow(dist, 2) + 2 * elev * v2);
        if( v4 < derp) {
            // Max optimal (won't hit!)
View Full Code Here


  public VectorHelper(Player player, Block block, int byWhat, int constraint) {
    coordX = block.getX();
    coordY = block.getY();
    coordZ = block.getZ();

    Vector v = player.getEyeLocation().getDirection().normalize();

    //    System.out.println("vecX:" + vecX + " vecY:" + vecY + " vecZ:" + vecZ);

    if (byWhat == VECTOR_BY_PLAYER) {

      Vector dir = player.getEyeLocation().getDirection();
      double dirX = dir.getX();
      double dirY = dir.getY();
      double dirZ = dir.getZ();

      vecX = (int) Math.signum(dirX);
      vecY = (int) Math.signum(dirY);
      vecZ = (int) Math.signum(dirZ);
View Full Code Here

    final boolean isTrain = info.isTrainSign() && info.isAction(SignActionType.GROUP_ENTER);
    if (!isCart && !isTrain) {
      return;
    }
    // Parse offset
    Vector offset = Util.parseVector(info.getLine(2), new Vector(0.0, 0.0, 0.0));
    if (offset.lengthSquared() == 0.0) {
      return;
    }
    // Rotate the offset so it becomes aligned with the sign
    float yaw = FaceUtil.faceToYaw(info.getFacing().getOppositeFace());
    offset = MathUtil.rotate(yaw, 0.0f, offset);
    // Jump
    if (isCart) {
      jump(info.getMember(), offset);
    } else {
      for (MinecartMember<?> member : info.getGroup()) {
        jump(member, offset.clone());
      }
    }
  }
View Full Code Here

    return true;
  }

  public void eject(SignActionEvent info) {
    final boolean hasSettings = !info.getLine(2).isEmpty() || !info.getLine(3).isEmpty();
    Vector offset = new Vector();
    float yaw = 0F;
    float pitch = 0F;
    if (hasSettings) {
      // Read the offset
      offset = Util.parseVector(info.getLine(2), offset);
View Full Code Here

                        cancel();
                        return;
                    }

                    if(newLocation.getY() > p.getLocation().getY()) {
                        p.setVelocity(new Vector(0, speed,0));
                        if(!BlockType.canPassThrough(p.getLocation().add(0, 2, 0).getBlock().getTypeId()))
                            p.teleport(p.getLocation().add(0, speed, 0));
                    } else if (newLocation.getY() < p.getLocation().getY()) {
                        p.setVelocity(new Vector(0, -speed,0));
                        if(!BlockType.canPassThrough(p.getLocation().add(0, -1, 0).getBlock().getTypeId()))
                            p.teleport(p.getLocation().add(0, -speed, 0));
                    } else {
                        teleportFinish(player, destination, shift);
                        if(flyingPlayers.contains(p.getUniqueId())) {
View Full Code Here

        cart.setVelocity(cart.getVelocity().normalize().multiply(-1));
    }

    public static void stop(Minecart cart) {

        cart.setVelocity(new Vector(0, 0, 0));
    }
View Full Code Here

            return;
        }

        BlockFace dir = SignUtil.getFacing(event.getBlocks().sign);

        Vector normalVelocity = event.getMinecart().getVelocity().normalize();

        switch (dir) {
            case NORTH:
                if (normalVelocity.getBlockZ() != -1) {
                    reverse(event.getMinecart());
                }
                break;
            case SOUTH:
                if (normalVelocity.getBlockZ() != 1) {
                    reverse(event.getMinecart());
                }
                break;
            case EAST:
                if (normalVelocity.getBlockX() != 1) {
                    reverse(event.getMinecart());
                }
                break;
            case WEST:
                if (normalVelocity.getBlockX() != -1) {
                    reverse(event.getMinecart());
                }
                break;
            default:
                reverse(event.getMinecart());
View Full Code Here

        if(getLine(2).isEmpty() || block == null)
            block = new ItemStack(Material.SAND,1);

        if(getLine(3).isEmpty())
            velocity = new Vector(0,0.5,0);
        else {
            String[] split2 = RegexUtil.COLON_PATTERN.split(getSign().getLine(3));
            velocity = new Vector(Double.parseDouble(split2[0]), Double.parseDouble(split2[1]), Double.parseDouble(split2[2]));
        }
    }
View Full Code Here

        @Override
        public void verify(ChangedSign sign) throws ICVerificationException {
            if(!sign.getLine(3).isEmpty()) {
                try {
                    String[] split2 = RegexUtil.COLON_PATTERN.split(sign.getLine(3));
                    new Vector(Double.parseDouble(split2[0]), Double.parseDouble(split2[1]), Double.parseDouble(split2[2]));
                } catch (Exception ignored) {
                    throw new ICVerificationException("Velocity must be in x:y:z format!");
                }
            }
        }
View Full Code Here

            multiplier = 0.5;
        else
            return;

        // speed up or down
        Vector newVelocity;
        if (multiplier != 1) {
            newVelocity = event.getVehicle().getVelocity().multiply(multiplier);
        } else return;
        // go
        event.getVehicle().setVelocity(newVelocity);
View Full Code Here

TOP

Related Classes of org.bukkit.util.Vector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.