Examples of BlockFace


Examples of org.bukkit.block.BlockFace

   * @param direction to launch into
   * @param distance to launch
   */
  public void launchTo(BlockFace direction, double distance) {
    double newDistance = distance;
    BlockFace newDirection = direction;
    if (!wasCentered) {
      // Apply distance correction from center cart to station
      CartToStationInfo stationInfo = getCartToStationInfo();
      // Adjust the direction and distance
      if (stationInfo.centerDir == direction) {
View Full Code Here

Examples of org.bukkit.block.BlockFace

    }
  }

  public Location getPoint(int index) {
    Location loc = this.get(index).getLocation();
    BlockFace dir = getDirection(index);
    loc.setYaw(FaceUtil.faceToYaw(dir) + 90);
    return loc.add(0.5, 0, 0.5);
  }
View Full Code Here

Examples of org.bukkit.block.BlockFace

    // Obtain the BlockFaces using absolute width and height
    final Block centerBlock = info.getRails();
    int radX = Math.abs(radWidth);
    int radY = Math.abs(radHeight);
    int radZ = Math.abs(radWidth);
    BlockFace dir = info.getRailDirection();
    if (FaceUtil.isVertical(dir)) {
      radY = 0;
    } else if (FaceUtil.isAlongX(dir)) {
      radX = 0;
    } else if (FaceUtil.isAlongZ(dir)) {
View Full Code Here

Examples of org.bukkit.block.BlockFace

   * @param member to get the velocity of
   * @return Forwards velocity of the minecart
   */
  public double getForwardVelocity(MinecartMember<?> member) {
    final CommonEntity<?> e = member.getEntity();
    final BlockFace direction = member.getDirection();
    double vel = 0.0;
    vel += e.vel.getX() * FaceUtil.cos(direction);
    vel += e.vel.getY() * direction.getModY();
    vel += e.vel.getZ() * FaceUtil.sin(direction);
    return vel;
  }
View Full Code Here

Examples of org.bukkit.block.BlockFace

      if (motLength > 0.01) {
        // Simple motion boosting when already moving
        entity.vel.xz.add(entity.vel.xz, TrainCarts.poweredRailBoost / motLength);
      } else {
        // Launch away from a suffocating block
        BlockFace dir = member.getRailDirection();
        org.bukkit.block.Block block = member.getBlock();
        boolean pushFrom1 = MaterialUtil.SUFFOCATES.get(block.getRelative(dir.getOppositeFace()));
        boolean pushFrom2 = MaterialUtil.SUFFOCATES.get(block.getRelative(dir));
        // If pushing from both directions, block all movement
        if (pushFrom1 && pushFrom2) {
          entity.vel.xz.setZero();
        } else if (pushFrom1 != pushFrom2) {
          // Boosting to the open spot
          final double boost = MathUtil.invert(START_BOOST, pushFrom2);
          entity.vel.xz.set(boost * dir.getModX(), boost * dir.getModZ());
        }
      }
    }
  }
 
View Full Code Here

Examples of org.bukkit.block.BlockFace

   * Checks if this sign is powered, ignoring settings on the sign
   * @param invert True to invert the power as a result, False to get the normal result
   * @return True if powered when not inverted, or not powered and inverted
   */
  public boolean isPoweredRaw(boolean invert) {
    BlockFace att = BlockUtil.getAttachedFace(this.signblock);
    Block attblock = this.signblock.getRelative(att);
    if (attblock.isBlockPowered()) {
      boolean found = false;
      for (BlockFace face : FaceUtil.ATTACHEDFACES) {
        if (BlockUtil.isType(attblock.getRelative(face), Material.LEVER)) {
View Full Code Here

Examples of org.bukkit.block.BlockFace

      return false;
    }
    if (!member.isMoving()) {
      return true;
    }
    final BlockFace dir = this.isAction(SignActionType.MEMBER_MOVE) ? member.getDirectionTo() : member.getDirectionFrom();
    return this.isWatchedDirection(dir);
  }
View Full Code Here

Examples of org.bukkit.block.BlockFace

          // Place a TrainCart/Minecart on top of the rails, and handles permissions
          return handleMinecartPlacement(player, clickedBlock, type);
        } else if (type == heldItem.getType() && MaterialUtil.ISRAILS.get(type) && TrainCarts.allowRailEditing && clickInterval >= MAX_INTERACT_INTERVAL) {
          if (BlockUtil.canBuildBlock(clickedBlock, type)) {
            // Edit the rails to make a connection/face the direction the player clicked
            BlockFace direction = FaceUtil.getDirection(player.getLocation().getDirection(), false);
            BlockFace lastDirection = LogicUtil.fixNull(lastClickedDirection.get(player), direction);
            Rails rails = BlockUtil.getRails(clickedBlock);
            // First check whether we are clicking towards an up-slope block
            if (MaterialUtil.ISSOLID.get(clickedBlock.getRelative(direction))) {
              // Sloped logic
              if (rails.isOnSlope()) {
                if (rails.getDirection() == direction) {
                  // Switch between sloped and flat
                  rails.setDirection(direction, false);
                } else {
                  // Other direction slope
                  rails.setDirection(direction, true);
                }
              } else {
                // Set to slope
                rails.setDirection(direction, true);
              }
            } else if (type == Material.RAILS) {
              // This needs advanced logic for curves and everything!
              BlockFace[] faces = FaceUtil.getFaces(rails.getDirection());
              if (!LogicUtil.contains(direction.getOppositeFace(), faces)) {
                // Try to make a connection towards this point
                // Which of the two faces do we sacrifice?
                BlockFace otherFace = faces[0] == lastDirection.getOppositeFace() ? faces[0] : faces[1];
                rails.setDirection(FaceUtil.combine(otherFace, direction.getOppositeFace()), false);
              }
            } else {
              // Simple switching (straight tracks)
              rails.setDirection(direction, false);
View Full Code Here

Examples of org.bukkit.block.BlockFace

      return true;
    }

    // Place logic for special rail types
    if (MaterialUtil.ISPRESSUREPLATE.get(railType)) {
      BlockFace dir = Util.getPlateDirection(clickedBlock);
      if (dir == BlockFace.SELF) {
        dir = FaceUtil.yawToFace(player.getLocation().getYaw() - 90, false);
      }
      at.setYaw(FaceUtil.faceToYaw(dir));
      MinecartMemberStore.spawnBy(at, player);
    } else if (Util.ISVERTRAIL.get(railType)) {
      BlockFace dir = Util.getVerticalRailDirection(clickedBlock);
      at.setYaw(FaceUtil.faceToYaw(dir));
      at.setPitch(-90.0f);
      MinecartMemberStore.spawnBy(at, player);
    } else {
      // Set ownership and convert during the upcoming minecart spawning (entity add) event
View Full Code Here

Examples of org.bukkit.block.BlockFace

      // Find and validate rails - only regular types are allowed
      Rails rails = BlockUtil.getRails(below);
      if (rails == null || rails.isCurve() || rails.isOnSlope()) {
        return false;
      }
      BlockFace railDir = rails.getDirection();
      BlockFace dir = Util.getVerticalRailDirection(vertRail);
      // No other directions going on for this rail?
      if (railDir != dir && railDir != dir.getOppositeFace()) {
        if (Util.getRailsBlock(below.getRelative(railDir)) != null) {
          return false;
        }
        if (Util.getRailsBlock(below.getRelative(railDir.getOppositeFace())) != null) {
          return false;
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.