Package org.bukkit.util

Examples of org.bukkit.util.Vector


    // Update the entity shape
    entity.setPosition(entity.loc.getX(), entity.loc.getY(), entity.loc.getZ());

    if (getGroup().getProperties().isManualMovementAllowed() && entity.hasPassenger()) {
      Vector vel = entity.getPassenger().getVelocity();
      vel.setY(0.0);
      if (vel.lengthSquared() > 1.0E-4 && entity.vel.xz.lengthSquared() < 0.01) {
        entity.vel.xz.add(vel.multiply(0.1));
      }
    }

    // Perform any pre-movement rail updates
    getRailType().onPreMove(this);
View Full Code Here


  }

  @Override
  public boolean parseSet(String key, String arg) {
    if (key.equals("exitoffset")) {
      Vector vec = Util.parseVector(arg, null);
      if (vec != null) {
        exitOffset = vec;
      }
    } else if (key.equals("exityaw")) {
      exitYaw = ParseUtil.parseFloat(arg, 0.0f);
View Full Code Here

    return getLocation(this.from);
  }

  public boolean update() {
    if (--this.ticksToFinish > 0) {
      Vector dir = this.item.item.loc.offsetTo(this.getTo());
      double distancePerTick = dir.length();
      distancePerTick /= (double) this.ticksToFinish;
      dir.normalize().multiply(distancePerTick);
      this.item.update(dir);
    } else {
      return true;
    }
    return false;
View Full Code Here

  public boolean isMoving() {
    return Math.abs(motX) >= CommonEntity.MIN_MOVE_SPEED || Math.abs(motZ) >= CommonEntity.MIN_MOVE_SPEED;
  }

  public void setVelocity(double velocity) {
    Vector vel = new Vector(this.motX, 0.0, this.motZ).normalize().multiply(velocity);
    this.motX = vel.getX();
    this.motZ = vel.getZ();
  }
View Full Code Here

  }

  @Override
  public boolean parseSet(String key, String arg) {
    if (key.equals("exitoffset")) {
      Vector vec = Util.parseVector(arg, null);
      if (vec != null) {
        for (CartProperties prop : this) {
          prop.exitOffset = vec;
        }
      }
View Full Code Here

    }
  }

  public static Vector parseVector(String text, Vector def) {
    String[] offsettext = splitBySeparator(text);
    Vector offset = new Vector();
    if (offsettext.length == 3) {
      offset.setX(ParseUtil.parseDouble(offsettext[0], 0.0));
      offset.setY(ParseUtil.parseDouble(offsettext[1], 0.0));
      offset.setZ(ParseUtil.parseDouble(offsettext[2], 0.0));
    } else if (offsettext.length == 2) {
      offset.setX(ParseUtil.parseDouble(offsettext[0], 0.0));
      offset.setZ(ParseUtil.parseDouble(offsettext[1], 0.0));
    } else if (offsettext.length == 1) {
      offset.setY(ParseUtil.parseDouble(offsettext[0], 0.0));
    } else {
      return def;
    }
    if (offset.length() > TrainCarts.maxEjectDistance) {
      offset.normalize().multiply(TrainCarts.maxEjectDistance);
    }
    return offset;
  }
View Full Code Here

    }
    if (this.isOnVertical()) {
      this.pushDirection = Util.getVerticalFace((entity.loc.getY() - EntityUtil.getLocY(human)) > 0.0);
    } else {
      BlockFace dir = FaceUtil.getRailsCartDirection(this.getRailDirection());
      if (MathUtil.isHeadingTo(dir, new Vector(entity.loc.getX() - EntityUtil.getLocX(human), 0.0, entity.loc.getZ() - EntityUtil.getLocZ(human)))) {
        this.pushDirection = dir;
      } else {
        this.pushDirection = dir.getOppositeFace();
      }
    }
View Full Code Here

                    if (!Rotation.isFacingLocation(entity, location, rotationThreshold)) {

                        Rotation.faceLocation(entity, location);
                    }

                    Vector v1 = entity.getLocation().toVector();
                    Vector v2 = location.toVector();
                    Vector v3 = v2.clone().subtract(v1).normalize().multiply(speed);

                    entity.setVelocity(v3);

                    // If freeflight is off, check if the entity has reached its
                    // destination, and remove the destination if that happens
View Full Code Here

    @Override
    public float getCost(BlockSource source, PathPoint point) {

        // TODO: Understand cost weight :D

        Vector pos = point.getVector();
        Material above = source.getMaterialAt(pos.clone().add(UP));
        Material below = source.getMaterialAt(pos.clone().add(DOWN));
        Material in = source.getMaterialAt(pos);

        // Discourage walking up a Z level
        if (point.getVector().getBlockY() > npc.getEntity().getLocation().getBlockY())
            return 5f;
View Full Code Here

        return .5f;
    }

    @Override
    public PassableState isPassable(BlockSource source, PathPoint point) {
        Vector pos = point.getVector();
        Material above = source.getMaterialAt(pos.clone().add(UP));
        Material below = source.getMaterialAt(pos.clone().add(DOWN));
        Material in = source.getMaterialAt(pos);
        if (!below.isBlock() || !canStandOn(below)) {
            return PassableState.UNPASSABLE;
        }
        if (!canStandIn(above) || !canStandIn(in)) {
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.