Package org.bukkit.block

Examples of org.bukkit.block.Block


   * @param world the sign is in
   * @return the sign, or null if the sign isn't loaded or missing
   */
  public SignActionEvent getSignEvent(World world) {
    if (this.isLoaded(world)) {
      Block signblock = this.location.toBlock(world);
      if (MaterialUtil.ISSIGN.get(signblock)) {
        SignActionEvent event = new SignActionEvent(signblock);
        if (this.validate(event)) {
          return event;
        }
View Full Code Here


            iter.next();

            // Go and find the other blocks
            final int maxLength = Math.abs(diff.x) + Math.abs(diff.y) + Math.abs(diff.z);
            for (k = 0; k < maxLength && iter.hasNext(); k++) {
              final Block block = iter.next();
              if (from.x == block.getX() && from.y == block.getY() && from.z == block.getZ()) {
                // Found the end block
                break;
              }
              // Put the member
              blockSpace.put(new IntVector3(block), member);
            }
          }
        }
        blockSpace.put(owner.tail().getBlockPos(), owner.tail());
      }

      // First clear the live active sign buffer of all members
      for (MinecartMember<?> member : owner) {
        member.getBlockTracker().liveActiveSigns.clear();
      }

      // Add all active signs to the block tracker of all members
      World world = owner.getWorld();
      for (Entry<IntVector3, MinecartMember<?>> entry : blockSpace.entrySet()) {
        IntVector3 pos = entry.getKey();
        for (RailType type : RailType.values()) {
          if (type.isRail(world, pos.x, pos.y, pos.z)) {
            Block block = pos.toBlock(world);
            List<Block> signs = entry.getValue().getBlockTracker().liveActiveSigns;
            Util.addSignsFromRails(signs, block, type.getSignColumnDirection(block));
          }
        }
      }
View Full Code Here

   * @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)) {
          //check EVERYTHING
          for (BlockFace alter : FaceUtil.ATTACHEDFACESDOWN) {
            if (alter != face) {
              if (PowerState.get(attblock, alter, false) == PowerState.ON) {
                return !invert;
View Full Code Here

   * @return Signs below this sign
   */
  public Sign[] findSignsBelow() {
    ArrayList<Sign> below = new ArrayList<Sign>(1);
    //other signs below this sign we could parse?
    Block signblock = this.getBlock();
    while (MaterialUtil.ISSIGN.get(signblock = signblock.getRelative(BlockFace.DOWN))) {
      Sign sign = BlockUtil.getSign(signblock);
      if (sign == null || BlockUtil.getFacing(signblock) != this.getFacing()) {
        break;
      }
      below.add(sign);
View Full Code Here

    // Get the next minecart Block position
    RailType currentType = RailType.getType(getRails());
    if (!LogicUtil.contains(direction, currentType.getPossibleDirections(getRails()))) {
      return false;
    }
    Block posBlock = currentType.getNextPos(getRails(), direction);
    if (posBlock == null) {
      return false;
    }
    for (RailType type : RailType.values()) {
      Block railsBlock = type.findRail(posBlock);
      if (railsBlock != null) {
        // Check that the next block allows a connection with this Block
        return LogicUtil.contains(direction.getOppositeFace(), type.getPossibleDirections(railsBlock));
      }
    }
View Full Code Here

    if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) {
      return;
    }
    try {
      // Obtain the clicked block
      Block clickedBlock = event.getClickedBlock();
      if (clickedBlock == null) {
        // Use ray tracing to obtain the correct block
        clickedBlock = CommonEntity.get(event.getPlayer()).getTargetBlock();
        if (clickedBlock == null) {
          // No interaction occurred
View Full Code Here

    }
  }

  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void onBlockPhysics(BlockPhysicsEvent event) {
    final Block block = event.getBlock();
    final Material type = block.getType();
    if (Util.ISTCRAIL.get(type)) {
      if (!Util.isSupported(block)) {
        // No valid supporting block - clear the active signs of this rails
        onRailsBreak(block);
      } else if (updateRails(block)) {
View Full Code Here

  public boolean updateRails(final Block below) {
    if (!MaterialUtil.ISRAILS.get(below)) {
      return false;
    }
    // Obtain the vertical rail and the rail below it, if possible
    final Block vertRail = below.getRelative(BlockFace.UP);
    if (Util.ISVERTRAIL.get(vertRail)) {
      // Find and validate rails - only regular types are allowed
      Rails rails = BlockUtil.getRails(below);
      if (rails == null || rails.isCurve() || rails.isOnSlope()) {
        return false;
View Full Code Here

  public static void addSignsFromRails(List<Block> rval, Block railsBlock, BlockFace signDirection) {
    final boolean hasSignPost = FaceUtil.isVertical(signDirection);

    // Ignore mid-sections
    Block currentBlock = railsBlock.getRelative(signDirection);
    addAttachedSigns(currentBlock, rval);
    currentBlock = currentBlock.getRelative(signDirection);
    // Keep going into the sign direction
    while (true) {
      if (hasSignPost && MaterialUtil.isType(currentBlock, Material.SIGN_POST)) {
        // Found a sign post - add it and continue
        rval.add(currentBlock);
      } else if (!addAttachedSigns(currentBlock, rval)) {
        // No wall signs found either - end it here
        break;
      }
      currentBlock = currentBlock.getRelative(signDirection);
    }
  }
View Full Code Here

  }

  public static boolean addAttachedSigns(final Block middle, final Collection<Block> rval) {
    boolean found = false;
    for (BlockFace face : FaceUtil.AXIS) {
      Block b = middle.getRelative(face);
      if (MaterialUtil.ISSIGN.get(b) && BlockUtil.getAttachedFace(b) == face.getOppositeFace()) {
        found = true;
        if (rval != null) {
          rval.add(b);
        }
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.