Solved How to add blockiterator to this code ?

Discussion in 'Plugin Development' started by Krumb069, May 5, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Krumb069

    player.getTargetBlock is not working so I found this code to get target block but I don't know how to use it can you help to add blockiterator to code ?
    Block iterator:
    Code:
    BlockIterator iter = new BlockIterator(o, 50);
            while (iter.hasNext()) {
                Block next = iter.next();
                if (next.getType() != Material.AIR) return next;
            }
            return null;
        }
    Code:
    Code:
    @EventHandler
        public void onPlayerJoin(PlayerInteractEvent e) {
            Player o = (Player) e.getPlayer();
            LineEffect lineeffect = new LineEffect(effectManager);
                lineeffect.isZigZag = false;
                lineeffect.particle = ParticleEffect.FLAME;
                lineeffect.particles = 100;
                lineeffect.setTarget(targetblock);
                lineeffect.start();
        }
     
  2. The code you gave should work fine, also, if you want to use getTargetBlock you can use getTargetBlock((Set<Material>) null, <distance>)
     
    Krumb069 likes this.
  3. Offline

    Krumb069

    The code is working but I am noob I don't know to use the iterator in my code :D
    Thanks for the new getTargetBlock it is easier
     
Thread Status:
Not open for further replies.

Share This Page