Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler
- public void onProjectileHit(ProjectileHitEvent event) {
- if (!(event.getEntity() instanceof Arrow)) {
- return;
- }
- if (event.getEntity().isOnGround() && !event.getEntity().isDead()) {
- Block hitBlock = null;
- BlockIterator iterator = new BlockIterator(event.getEntity().getWorld(), event.getEntity().getLocation().toVector(), event.getEntity().getVelocity().normalize(), 0.0D, 4);
- while (iterator.hasNext()) {
- hitBlock = iterator.next();
- if (hitBlock.getType() != Material.AIR) {
- break;
- }
- }
- Block finalblock = hitBlock;
- for (Entity e : finalblock.getWorld().getNearbyEntities(finalblock.getLocation(), 50, 50, 50)) {
- if (e.getType() == EntityType.PLAYER) {
- Player p = (Player) e;
- p.sendBlockChange(finalblock.getLocation(), Material.GLASS, (byte) 1);
- }
- }
- Bukkit.getScheduler().runTaskLater(this, ()-> finalblock.getState().update(), 20);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement