Examples of BlockFace


Examples of org.bukkit.block.BlockFace

        Material type = WorldUtil.getBlockType(world, nextPos.x, nextPos.y, nextPos.z);
        int data = WorldUtil.getBlockData(world, nextPos);
        if (this.isRail(type, data)) {
          // Check that the direction of the rail is correct
          Rails rails = CommonUtil.tryCast(BlockUtil.getData(type, data), Rails.class);
          BlockFace lastDirection = railTracker.getLastLogic().getDirection();
          if (rails != null && rails.isOnSlope() && rails.getDirection() == lastDirection) {
            // We got a winner!
            // Some position and velocity adjustment prior to moving between the types
            CommonMinecart<?> entity = member.getEntity();
            entity.loc.xz.set(nextPos.x + 0.5, nextPos.z + 0.5);
View Full Code Here

Examples of org.bukkit.block.BlockFace

  public RailLogic getLogic(MinecartMember<?> member, Block railsBlock) {
    Rails rails = BlockUtil.getRails(railsBlock);
    if (rails == null) {
      return RailLogicGround.INSTANCE;
    }
    BlockFace direction = rails.getDirection();

    // Sloped logic
    if (rails.isOnSlope()) {
      // To vertical
      if (Util.isVerticalAbove(railsBlock, direction)) {
View Full Code Here

Examples of org.bukkit.block.BlockFace

          return currentTrack.getRelative(currentDirection);
        }
      }

      // Get connected faces
      BlockFace dir = currentDirection.getOppositeFace();
      BlockFace nextDir;
      if (possible[0].equals(dir)) {
        nextDir = possible[1];
      } else if (possible[1].equals(dir)) {
        nextDir = possible[0];
        // south-east rule
View Full Code Here

Examples of org.bukkit.block.BlockFace

    return new Vector(newLocX, newLocY, newLocZ);
  }

  @Override
  public BlockFace getMovementDirection(MinecartMember<?> member, Vector movement) {
    final BlockFace raildirection = this.getDirection();
    final boolean isHorizontalMovement = Math.abs(movement.getX()) >= 0.0001 || Math.abs(movement.getZ()) >= 0.0001;
    BlockFace direction;

    if (this.isSloped()) {
      // Sloped rail logic
      if (isHorizontalMovement) {
        // Deal with minecarts moving on straight slopes
        float moveYaw = MathUtil.getLookAtYaw(movement);
        float diff1 = MathUtil.getAngleDifference(moveYaw, FaceUtil.faceToYaw(raildirection));
        float diff2 = MathUtil.getAngleDifference(moveYaw, FaceUtil.faceToYaw(raildirection.getOppositeFace()));
        // Compare with the previous direction to sort out equality problems
        if (diff1 == diff2) {
          diff1 = FaceUtil.getFaceYawDifference(member.getDirectionFrom(), raildirection);
          diff2 = FaceUtil.getFaceYawDifference(member.getDirectionFrom(), raildirection.getOppositeFace());
        }
        // Use the opposite direction if needed
        if (diff1 > diff2) {
          direction = raildirection.getOppositeFace();
        } else {
          direction = raildirection;
        }
      } else {
        // Deal with vertically moving or standing still minecarts on slopes
        if (Math.abs(movement.getY()) > 0.0001) {
          // Going from vertical to a slope
          if (movement.getY() > 0.0) {
            direction = raildirection;
          } else {
            direction = raildirection.getOppositeFace();
          }
        } else {
          // Gravity sends it down the slope at some point
          direction = raildirection.getOppositeFace();
        }
      }
    } else if (this.curved) {
      // Curved rail logic
      BlockFace movementDir = FaceUtil.getDirection(movement);
      BlockFace[] possibleDirections = FaceUtil.getFaces(raildirection.getOppositeFace());
      if (FaceUtil.isSubCardinal(movementDir)) {
        direction = movementDir;
      } else {
        // Evaluate ingoing/outgoing faces with direction
        BlockFace directionTo;
        if (possibleDirections[0] == movementDir) {
          // Move towards 0
          directionTo = possibleDirections[0];
        } else if (possibleDirections[1] == movementDir) {
          // Move towards 1
View Full Code Here

Examples of org.bukkit.block.BlockFace

  public Block getNextPos(Block currentTrack, BlockFace currentDirection) {
    if (currentDirection == BlockFace.UP) {
      Block next = currentTrack.getRelative(BlockFace.UP);
      if (!Util.ISTCRAIL.get(next)) {
        // Check for a possible sloped rail leading up from next
        BlockFace dir = Util.getVerticalRailDirection(currentTrack);
        Block possible = next.getRelative(dir);
        Rails rails = BlockUtil.getRails(possible);
        if (rails != null && rails.isOnSlope() && rails.getDirection() == dir) {
          return possible;
        }
View Full Code Here

Examples of org.bukkit.block.BlockFace

    final CommonMinecart<?> entity = member.getEntity();
    // Apply velocity modifiers
    final boolean invert;
    if (this.curved) {
      // Invert only if heading towards the exit-direction of the curve
      BlockFace from = member.getDirectionTo();
      invert = from == this.faces[0] || from == this.faces[1];
    } else {
      // Invert only if the direction is inverted relative to cart velocity
      invert = (entity.vel.getX() * this.dx + entity.vel.getZ() * this.dz) < 0.0;
    }
View Full Code Here

Examples of org.bukkit.block.BlockFace

  @Override
  public Block next() {
    if (!this.hasNext()) {
      throw new NoSuchElementException("No next track is available");
    }
    BlockFace oldDirection = this.currentDirection();
    this.genNextBlock();
    BlockFace newDirection = this.currentDirection();
    this.distance++;
    if (oldDirection == newDirection || oldDirection == newDirection.getOppositeFace()) {
      // Took a straight piece
      this.cartDistance += 1.0;
    } else {
      // Took a curve
      this.cartDistance += MathUtil.HALFROOTOFTWO;
View Full Code Here

Examples of org.bukkit.block.BlockFace

    // Figure out where a Minecart is located on this Rail
    Block pos1 = rail1type.findMinecartPos(rail1);
    Block pos2 = rail1type.findMinecartPos(rail2);

    // Figure out which direction is more likely to lead to the other
    BlockFace dir1 = getPreferredDirection(rail1dirs, pos1, pos2);
    BlockFace dir2 = getPreferredDirection(rail2dirs, pos2, pos1);

    // Now, start looking into the directions
    final int maxDistance = BlockUtil.getManhattanDistance(pos1, pos2, true) + 2;
    TrackIterator iter = new TrackIterator(null, null, maxDistance, false);
    if (bothways) {
View Full Code Here

Examples of org.bukkit.block.BlockFace

    // Calculate the to direction
    if (FaceUtil.isSubCardinal(this.direction)) {
      // Compare with the rail direction for curved rails
      // TODO: Turn this into an understandable transformation
      final BlockFace raildirection = this.getRailDirection();
      if (this.direction == BlockFace.NORTH_EAST) {
        this.directionTo = raildirection == BlockFace.NORTH_WEST ? BlockFace.EAST : BlockFace.NORTH;
      } else if (this.direction == BlockFace.SOUTH_EAST) {
        this.directionTo = raildirection == BlockFace.NORTH_EAST ? BlockFace.SOUTH : BlockFace.EAST;
      } else if (this.direction == BlockFace.SOUTH_WEST) {
View Full Code Here

Examples of org.bukkit.block.BlockFace

        newpitch = MathUtil.clamp(-0.7f * MathUtil.getLookAtPitch(-movedX, -movedY, -movedZ), 60.0f);
        orientPitch = true;
      }
    } else {
      // Update yaw
      BlockFace dir = this.getDirection();
      if (FaceUtil.isVertical(dir)) {
        newyaw = FaceUtil.faceToYaw(this.getRailDirection());
      } else {
        newyaw = FaceUtil.faceToYaw(this.getDirection());
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.