Package org.bukkit.block

Examples of org.bukkit.block.Block


   *
   * @param start position of the Minecart (NOT the rails!)
   * @param direction to start walking into
   */
  public TrackWalkIterator(Location start, BlockFace direction) {
    Block railsBlock = null;
    Block startBlock = start.getBlock();
    for (RailType type : RailType.values()) {
      if ((railsBlock = type.findRail(startBlock)) != null) {
        break;
      }
    }
View Full Code Here


    if (this.isDerailed() || member.isDerailed()) {
      return true;
    }

    // Same block?
    Block memberrail = member.getBlock();
    if (BlockUtil.equals(this.getBlock(), memberrail)) {
      return true;
    }

    // If moving, use current direction, otherwise be flexible and allow both directions
View Full Code Here

      this.directionFrom = this.directionTo;
    }

    // Destroy blocks
    if (!this.isDerailed() && this.getProperties().hasBlockBreakTypes()) {
      Block left = this.getBlockRelative(BlockFace.WEST);
      Block right = this.getBlockRelative(BlockFace.EAST);
      if (this.getProperties().canBreak(left)) {
        BlockInfo.get(left).destroy(left, 20.0f);
      }
      if (this.getProperties().canBreak(right)) {
        BlockInfo.get(right).destroy(right, 20.0f);
View Full Code Here

  }

  private void addPendingNodes() {
    if (!this.pendingNodes.isEmpty()) {
      for (PathNode node : this.pendingNodes) {
        Block startRail = node.location.getBlock();
        RailType startType = RailType.getType(startRail);
        if (startType == RailType.NONE) {
          // Track type can not be identified
          continue;
        }
View Full Code Here

    }
  }

  private void scheduleNode(PathNode node, Block startBlock, BlockFace direction) {
    for (RailType nextType : RailType.values()) {
      Block startRail = nextType.findRail(startBlock);
      if (startRail != null) {
        schedule(node, startRail, direction);
        return;
      }
    }
View Full Code Here

     */
    public boolean next() {
      if (!iter.hasNext()) {
        return true;
      }
      Block nextRail = iter.next();
      BlockLocation newNodeLocation;
      String newNodeName;
      boolean hasFinished = false;
      for (Block signblock : Util.getSignsFromRails(nextRail)) {
        SignActionEvent event = new SignActionEvent(signblock);
View Full Code Here

  public TrackMap generate(int size, double stepsize) {
    return this.generate((int) (stepsize * size));
  }
 
  public boolean find(Block rail, int maxstepcount) {
    Block next;
    for (;maxstepcount > 0; --maxstepcount) {
      next = this.next();
      if (next == null) return false;
      if (BlockUtil.equals(rail, next)) return true;
    }
View Full Code Here

  }
  public boolean hasNext() {
    return this.iterator.hasNext();
  }
  public Block next() {
    Block next = this.iterator.next();
    if (next != null) this.add(next);
    return next;
  }
View Full Code Here

    return getBlockStates(info, radius.x, radius.z);
  }

  public static Collection<BlockState> getBlockStates(SignActionEvent info, int radWidth, int radHeight) {
    // 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)) {
      radZ = 0;
    }
    List<BlockState> states = new ArrayList<BlockState>(BlockUtil.getBlockStates(centerBlock, radX, radY, radZ));

    // Get rid of twice-stored double chests
    try {
      Iterator<BlockState> iter = states.iterator();
      while (iter.hasNext()) {
        BlockState next = iter.next();
        if (!(next instanceof Chest)) {
          continue;
        }
        DoubleChestInventory inventory = CommonUtil.tryCast(((Chest) next).getInventory(), DoubleChestInventory.class);
        if (inventory == null) {
          continue;
        }
        if (chestsBuffer.add(inventory.getLeftSide().getHolder()) &&
            chestsBuffer.add(inventory.getRightSide().getHolder())) {
          continue;
        }
        // Already added chest(s), disregard
        iter.remove();
      }
    } finally {
      chestsBuffer.clear();
    }

    // Sort the resulting states based on distance from the center
    final boolean widthInv = radWidth < 0;
    final boolean heightInv = radHeight < 0;
    Collections.sort(states, new Comparator<BlockState>() {

      public int getIndex(BlockState state) {
        int dx = MathUtil.invert(Math.abs(centerBlock.getX() - state.getX()), widthInv);
        int dy = MathUtil.invert(Math.abs(centerBlock.getY() - state.getY()), heightInv);
        int dz = MathUtil.invert(Math.abs(centerBlock.getZ() - state.getZ()), widthInv);
        // Magical formula timez!
        return dx + 16 * dz + 256 * dy;
      }

      @Override
 
View Full Code Here

    String name;
    SignActionEvent info;
    for (BlockLocation location : blocks) {
      name = location.toString();
      // Destination sign? If so, fix up the name
      Block block = location.getBlock();
      if (block == null) {
        continue;
      }
      for (Block signBlock : Util.getSignsFromRails(block)) {
        info = new SignActionEvent(signBlock);
View Full Code Here

TOP

Related Classes of org.bukkit.block.Block

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.