// @EventHandler(priority = EventPriority.NORMAL) public void explodingArrow(ProjectileHitEvent event) { Entity projectile = event.getEntity(); World w = projectile.getWorld(); Location hit = projectile.getLocation(); if (w.getName().equals(name)) { if (projectile instanceof Arrow) { Arrow arrow = (Arrow) projectile; Entity shooter = arrow.getShooter(); Location l = shooter.getLocation(); Block bl = l.getBlock(); Block b = bl.getRelative(BlockFace.DOWN, 2); Material mat = b.getType(); if (shooter instanceof Player) { Player p = (Player) shooter; ItemStack is = p.getItemInHand(); Material i = is.getType(); if (i == Material.BOW && mat == Material.SPONGE) { p.getInventory().removeItem(new ItemStack(Material.ARROW, 20)); w.createExplosion(hit, 8); int strikes = 0; while (strikes < 20) { strikes++; w.strikeLightning(hit); } } Bukkit.getWorld(name).playEffect(arrow.getLocation(), Effect.STEP_SOUND, 10); } } } }
public WorldEditorException(final String msg, final Location loc) { super( msg + " at " + loc.getWorld().getName() + ":" + loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ()); this.loc = loc; }
public void lookAtPoint(final Location point) { if (this.getEntity().getBukkitEntity().getWorld() != point.getWorld()) return; final Location npcLoc = ((LivingEntity) this.getEntity().getBukkitEntity()).getEyeLocation(); final double xDiff = point.getX() - npcLoc.getX(); final double yDiff = point.getY() - npcLoc.getY(); final double zDiff = point.getZ() - npcLoc.getZ(); final double DistanceXZ = Math.sqrt(xDiff * xDiff + zDiff * zDiff); final double DistanceY = Math.sqrt(DistanceXZ * DistanceXZ + yDiff * yDiff); double newYaw = Math.acos(xDiff / DistanceXZ) * 180 / Math.PI; final double newPitch = Math.acos(yDiff / DistanceY) * 180 / Math.PI - 90; if (zDiff < 0.0) newYaw = newYaw + Math.abs(180 - newYaw) * 2; this.setYaw((float) (newYaw - 90)); this.setPitch((float) newPitch); }
public void putInBed(final Location bed) { this.getEntity().setPosition(bed.getX(), bed.getY(), bed.getZ()); this.getEntity().a((int) bed.getX(), (int) bed.getY(), (int) bed.getZ()); }