public ItemProjectile(Player caster, float power) { this.caster = caster; this.power = power; Location location = caster.getEyeLocation().add(0, yOffset, 0); location.setPitch(0f); if (vertSpeedUsed) { vel = caster.getLocation().getDirection().setY(0).multiply(speed).setY(vertSpeed); } else { vel = caster.getLocation().getDirection().multiply(speed); } entity = caster.getWorld().dropItem(location, item.clone()); MagicSpells.getVolatileCodeHandler().setGravity(entity, projectileHasGravity); playSpellEffects(EffectPosition.PROJECTILE, entity); playTrackingLinePatterns( EffectPosition.DYNAMIC_CASTER_PROJECTILE_LINE, caster.getLocation(), entity.getLocation(), caster, entity); entity.teleport(location); entity.setPickupDelay(1000000); entity.setVelocity(vel); taskId = MagicSpells.scheduleRepeatingTask(this, 3, 3); }
public static void checkSecond() { for (Item i : Bukkit.getWorld("PrisonMap").getEntitiesByClass(Item.class)) { if (tnts.contains(i.getUniqueId())) { ParticleEffect.SMOKE_NORMAL.display( 0.25f, 0.25f, 0.25f, 0.0001f, 5, i.getLocation().clone().add(0, 0.5, 0), 100); if (i.getTicksLived() > 30) { ParticleEffect.EXPLOSION_HUGE.display( 0.5f, 0.5f, 0.5f, 0.1f, 5, i.getLocation().clone().add(0, 1, 0), 100); for (Entity e : i.getNearbyEntities(3.5, 3.5, 3.5)) { if (e instanceof Player) { Location midPoint = i.getLocation(); Vector direction = e.getLocation().toVector().subtract(midPoint.toVector()).normalize(); direction.multiply(1.1).setY(0.7); e.setVelocity(direction); ((Player) e).damage(0.0); } } final List<Location> blocks = new ArrayList<Location>(); int radius = 3; int bX = i.getLocation().getBlockX(); int bY = i.getLocation().getBlockY(); int bZ = i.getLocation().getBlockZ(); for (int x = bX - radius; x <= bX + radius; x++) { for (int y = bY - radius; y <= bY + radius; y++) { for (int z = bZ - radius; z <= bZ + radius; z++) { double distance = ((bX - x) * (bX - x) + ((bZ - z) * (bZ - z)) + ((bY - y) * (bY - y))); if (distance < radius * radius) { Location loc = new Location(i.getWorld(), x, y, z); if (loc.getBlock().getType() != Material.AIR) { blocks.add(loc); } } } } } for (Location loc : blocks) { Random r = new Random(); int i1 = r.nextInt(3) + 1; if (Game.isBreakable(loc.getBlock().getType()) && (i1 == 1 || i1 == 2)) { loc.getBlock().setType(Material.AIR); } } Game.playSound(Sound.EXPLODE, i.getLocation(), 1f, 1f); tnts.remove(i.getUniqueId()); i.teleport(i.getLocation().subtract(0, 500, 0)); } } } }