HaniiPuppy

block iterator example

Jan 28th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1.     public void onProjectileHitListener(ProjectileHitEvent event)
  2.     {
  3.         Block blockhit = null;
  4.         //blockhit = block actually hit by the egg.
  5.  
  6.         if(event.getEntityType() != EntityType.EGG)
  7.             return;
  8.  
  9.         World world = event.getEntity().getWorld();
  10.         BlockIterator iterator = new BlockIterator(world, event.getEntity().getLocation().toVector(), event.getEntity().getVelocity().normalize(), 0, 4);
  11.         blockhit = null;
  12.  
  13.         while (iterator.hasNext())
  14.         {
  15.             blockhit = iterator.next();
  16.  
  17.             if (blockhit.getTypeId() != 0)
  18.                 break;
  19.         }
  20.  
  21.         if(blockhit == null || blockhit.getType() == Material.GLASS)
  22.             return;
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment