Advertisement
Leymooo

Untitled

Sep 19th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. @EventHandler
  2. public void onProjectileHit(ProjectileHitEvent event) {
  3. if (!(event.getEntity() instanceof Arrow)) {
  4. return;
  5. }
  6. if (event.getEntity().isOnGround() && !event.getEntity().isDead()) {
  7. Block hitBlock = null;
  8. BlockIterator iterator = new BlockIterator(event.getEntity().getWorld(), event.getEntity().getLocation().toVector(), event.getEntity().getVelocity().normalize(), 0.0D, 4);
  9. while (iterator.hasNext()) {
  10. hitBlock = iterator.next();
  11. if (hitBlock.getType() != Material.AIR) {
  12. break;
  13. }
  14. }
  15. Block finalblock = hitBlock;
  16. for (Entity e : finalblock.getWorld().getNearbyEntities(finalblock.getLocation(), 50, 50, 50)) {
  17. if (e.getType() == EntityType.PLAYER) {
  18. Player p = (Player) e;
  19. p.sendBlockChange(finalblock.getLocation(), Material.GLASS, (byte) 1);
  20. }
  21. }
  22. Bukkit.getScheduler().runTaskLater(this, ()-> finalblock.getState().update(), 20);
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement