Package org.bukkit.block

Examples of org.bukkit.block.Block


    public void repair()
    {
        if (getWorld().getBlockAt(getX(), getY(), getZ()).getState().getData() instanceof Door)
            return;

        Block b = getWorld().getBlockAt(x,y,z);
        if (b.getTypeId() == 0)
            b.setTypeId(1);
       
        super.repair();
        other.getBlock().setTypeIdAndData(getId(), (byte) (getData() + 8), false);
    }
View Full Code Here


public class Flood implements Ability
{
    @Override
    public void execute(Arena arena, MABoss boss) {
        Player p = AbilityUtils.getRandomPlayer(arena);
        Block block = p.getLocation().getBlock();
       
        if (block.getTypeId() == 0) {
            block.setTypeId(8);
            arena.addBlock(block);
        }
    }
View Full Code Here

        LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), true);
       
        final World world = arena.getWorld();
        final Location loc;

        Block b = world.getBlockAt(target.getLocation());
        for (int i = 0; i < 3; i++) {
            if (b.getType() == Material.AIR) {
                break;
            }
            b = b.getRelative(BlockFace.UP);
        }
        loc = b.getLocation();

        if (b.getType() != Material.AIR) {
            Messenger.warning("Failed to place Obsidian Bomb at: " + target.getLocation());
            return;
        }

        b.setType(Material.OBSIDIAN);
        arena.addBlock(b);

        arena.scheduleTask(new Runnable() {
            public void run() {
                if (!arena.isRunning())
View Full Code Here

        private boolean chests(PlayerInteractEvent event) {
            if (!event.hasBlock()) {
                return false;
            }

            Block b = event.getClickedBlock();
            switch (event.getAction()) {
                case LEFT_CLICK_BLOCK:  chests(b, true)return true;
                case RIGHT_CLICK_BLOCK: chests(b, false); return true;
            }
            return false;
View Full Code Here

  public boolean onBlockCollision(MinecartMember<?> member, Block railsBlock, Block hitBlock, BlockFace hitFace) {
    if (!super.onBlockCollision(member, railsBlock, hitBlock, hitFace)) {
      return false;
    }
    // Handle collision (ignore UP/DOWN, recalculate hitFace for this)
    Block posBlock = findMinecartPos(railsBlock);
    hitFace = FaceUtil.getDirection(hitBlock, posBlock, false);
    final BlockFace hitToFace = hitFace.getOppositeFace();
    if (posBlock.getY() == hitBlock.getY()) {
      // If the hit face is not a valid direction to go to, ignore it
      int dx = hitBlock.getX() - posBlock.getX();
      int dz = hitBlock.getZ() - posBlock.getZ();
      if (Math.abs(dx) > 0 && Math.abs(dz) > 0) {
        // CANCEL: we hit a corner block
        return false;
      }
      BlockFace[] possible = this.getPossibleDirections(railsBlock);
      if (!LogicUtil.contains(hitToFace, possible)) {
        // CANCEL: we hit a block that is not an end-direction
        return false;
      }
    }
    if (member.isOnSlope()) {
      // Cancel collisions with blocks two above this sloped rail
      if (hitBlock.getX() == posBlock.getX() && hitBlock.getZ() == posBlock.getZ()) {
        int dy = hitBlock.getY() - posBlock.getY();
        if (dy >= 2) {
          return false;
        }
      }

      // Cancel collisions with blocks at the heading of sloped rails when going up vertically
      BlockFace railDirection = this.getDirection(railsBlock);
      if (hitToFace == railDirection && Util.isVerticalAbove(posBlock, railDirection)) {
        return false;
      }

      // Cancel collisions with blocks 'right above' the next rail when going down the slope
      IntVector3 diff = new IntVector3(hitBlock).subtract(posBlock.getX(), posBlock.getY(), posBlock.getZ());
      if (diff.x == hitToFace.getModX() && diff.z == hitToFace.getModZ() &&
          (diff.y > 1 || (diff.y == 1 && railDirection != hitToFace))) {
        return false;
      }
    }
View Full Code Here

      }
      return currentTrack.getRelative(nextDir);
    } else if (sloped) {
      if (railDirection == currentDirection) {
        // Moving up the slope
        Block above = currentTrack.getRelative(BlockFace.UP);
        if (Util.ISVERTRAIL.get(above) && Util.getVerticalRailDirection(above) == currentDirection) {
          // Go to vertical rails above
          return above;
        } else {
          // Go up one and then forward
          return above.getRelative(railDirection);
        }
      } else {
        // Moving down the slope, follow slope end-direction
        return currentTrack.getRelative(railDirection.getOppositeFace());
      }
View Full Code Here

    entity.vel.xz.add(this.getDirection(), entity.vel.getY());
    entity.vel.y.setZero();

    // Stop movement if colliding with a block at the slope
    double blockedDistance = Double.MAX_VALUE;
    Block inside = member.getRailType().findMinecartPos(member.getBlock());
    Block heading = inside.getRelative(this.getDirection().getOppositeFace());
    if (!member.isMoving() || member.isHeadingTo(this.getDirection().getOppositeFace())) {
      if (MaterialUtil.SUFFOCATES.get(heading)) {
        blockedDistance = entity.loc.xz.distance(heading) - 1.0;
      }
    } else if (member.isHeadingTo(this.getDirection())) {
      Block above = inside.getRelative(BlockFace.UP);
      if (MaterialUtil.SUFFOCATES.get(above)) {
        blockedDistance = entity.loc.xz.distance(above);
      }
    }
    if (entity.vel.xz.length() > blockedDistance) {
View Full Code Here

  }

  @Override
  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

    if (rail1dirs.length == 0 || rail2dirs.length == 0) {
      return false;
    }

    // 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);
View Full Code Here

   *
   * @param startRail (NOT position block)
   * @param direction to start walking into
   */
  public TrackWalkIterator(Block startRail, BlockFace direction) {
    Block startBlock = RailType.getType(startRail).findMinecartPos(startRail);
    Location startLoc = startBlock == null ? null : startBlock.getLocation().add(0.5, 0.5, 0.5);
    this.walker = new TrackWalkingPoint(startLoc, startRail, direction);
    this.current = this.next = walker.currentPosition == null ? null : walker.currentPosition.clone();
  }
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.