Package org.bukkit.util

Examples of org.bukkit.util.BlockIterator


        if (Double.isNaN(projectile.getLocation().getDirection().normalize().getX()))
            return; // I can't explain this one either. It also chooses to happen whenever it pleases.

        Block block = null;
        try {
            BlockIterator bi = new BlockIterator(projectile.getLocation().getWorld(),
                    projectile.getLocation().toVector(), projectile.getLocation().getDirection().normalize(), 0, 4);
            while(bi.hasNext()) {
                block = bi.next();
                if(block.getTypeId() != 0) {
                    break;
                }
            }
        }
View Full Code Here


                    }
                }
            }

            // Find the valid target
            BlockIterator bi;
            try {
                bi = new BlockIterator(getPlayerEntity(), range);
            }
            catch (IllegalStateException e) {
                return null;
            }
            Block b;
            Location l;
            int bx, by, bz;
            double ex, ey, ez;

            // Loop through player's line of sight
            while (bi.hasNext()) {
                b = bi.next();
                bx = b.getX();
                by = b.getY();
                bz = b.getZ();

                if (b.getType() != Material.AIR) {
View Full Code Here

            return null;

        Block block;
        Block previousBlock = null;

        Iterator<Block> itr = new BlockIterator(me, 200);
        while (itr.hasNext())
        {
            block = itr.next();
            if (block.getType() != Material.AIR && block.getType() != Material.LONG_GRASS)
            {
                return previousBlock;
            }
            previousBlock = block;
View Full Code Here

        if (maxDistance > 120) {
            maxDistance = 120;
        }

        LinkedList<Block> blocks = new LinkedList<>();
        Iterator<Block> itr = new BlockIterator(this, maxDistance);
        while (itr.hasNext()) {
            Block block = itr.next();
            blocks.add(block);
            if (maxLength != 0 && blocks.size() > maxLength) {
                blocks.removeFirst();
            }
            int id = block.getTypeId();
View Full Code Here

        setMaxStackSize(16);
    }

    @Override
    public void rightClickAir(GlowPlayer player, ItemStack holding) {
        Iterator<Block> itr = new BlockIterator(player, 5);
        Block target = null;
        // Used to determine the side the block was clicked on:
        Block previousTarget = null;
        BlockType targetBlockType = null;
        boolean validTarget = false;

        // Find the next available non-air liquid block type which is collectible in a radius of 5 blocks
        while (itr.hasNext()) {
            previousTarget = target;
            target = itr.next();
            targetBlockType = ItemTable.instance().getBlock(target.getType());
            if (targetBlockType != null && targetBlockType instanceof BlockLiquid) {
                if (((BlockLiquid) targetBlockType).isCollectible((GlowBlockState) target.getState())) {
                    validTarget = true;
                    break;
View Full Code Here

   * @param end
   * @throws IllegalStateException randomly (Bukkit bug)
   */
  @SuppressWarnings("null")
  public BlockLineIterator(final Block start, final Block end) throws IllegalStateException {
    super(new BlockIterator(start.getWorld(), fitInWorld(start.getLocation().add(0.5, 0.5, 0.5), end.getLocation().subtract(start.getLocation()).toVector()),
        end.equals(start) ? new Vector(1, 0, 0) : end.getLocation().subtract(start.getLocation()).toVector(), 0, 0), // should prevent an error if start = end
    new NullableChecker<Block>() {
      private final double overshotSq = Math.pow(start.getLocation().distance(end.getLocation()) + 2, 2);
     
      @Override
View Full Code Here

   * @param dir
   * @param dist
   * @throws IllegalStateException randomly (Bukkit bug)
   */
  public BlockLineIterator(final Location start, final Vector dir, final double dist) throws IllegalStateException {
    super(new BlockIterator(start.getWorld(), fitInWorld(start, dir), dir, 0, 0), new NullableChecker<Block>() {
      private final double distSq = dist * dist;
     
      @Override
      public boolean check(final @Nullable Block b) {
        return b != null && b.getLocation().add(0.5, 0.5, 0.5).distanceSquared(start) >= distSq;
View Full Code Here

TOP

Related Classes of org.bukkit.util.BlockIterator

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.