@EventHandler(priority = EventPriority.NORMAL) public void onMonsterDamage(EntityDamageEvent event) { if (event instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent entityDamageByEntityEvent = (EntityDamageByEntityEvent) event; //logger.info(entityDamageByEntityEvent.getDamager()); if(entityDamageByEntityEvent.getDamager() instanceof Fireball) { Fireball fb = (Fireball) entityDamageByEntityEvent.getDamager(); if (fb.getShooter() instanceof Player) { if (fb instanceof SmallFireball) { entityDamageByEntityEvent.setDamage(entityDamageByEntityEvent.getDamage() * 3); } else // Big fireball { entityDamageByEntityEvent.setDamage(entityDamageByEntityEvent.getDamage() * 5); } } } } }
@Override public void onInteract(PlayerInteractEvent event) { event.setCancelled(true); Player player = event.getPlayer(); User user = Zephyrus.getUser(player); Block block = (Block) user.getTarget(this).getTarget(); int delay = user.getDelay(getInternalName()); if (delay > 0) { Language.sendError("item.delay", player, "[SECONDS]", delay + ""); return; } if (Zephyrus.getHookManager().canBuild(player, block)) { if (getLevel(player.getItemInHand().getItemMeta().getLore()) > 5) { player.launchProjectile(Fireball.class); } else { player.launchProjectile(SmallFireball.class); } user.setDelay(getName(), levelToDelay(getLevel(player.getItemInHand().getItemMeta().getLore()))); return; } Language.sendError("item.rodoffire.failure", player); }
@Override public void rightClick(Player player) { long cooldown; RPGValue value = RPGValue.get(player, item, "tnt.fireball"); if (value == null) { cooldown = System.currentTimeMillis() / 50; value = new RPGValue(player, item, "tnt.fireball", cooldown); } else { cooldown = value.asLong(); } if (cooldown <= System.currentTimeMillis() / 50) { value.set(System.currentTimeMillis() / 50 + cooldownTime); player.playSound(player.getLocation(), Sound.GHAST_FIREBALL, 1.0f, 1.0f); player.launchProjectile(SmallFireball.class); } else { player.sendMessage(ChatColor.AQUA + String.format(Locale.get("message.cooldown", Locale.getPlayerLocale(player)), ((double) (cooldown - System.currentTimeMillis() / 50)) / 20d)); } }
@Override public void rightClick(Player player) { long cooldown; if (item.getHasPermission() == true && player.hasPermission(item.getPermission()) == false){ }else{ RPGValue value = RPGValue.get(player, item, "tnt.fireball"); if (value == null) { cooldown = System.currentTimeMillis() / 50; value = new RPGValue(player, item, "tnt.fireball", cooldown); } else { cooldown = value.asLong(); } if (cooldown <= System.currentTimeMillis() / 50) { value.set(System.currentTimeMillis() / 50 + cooldownTime); player.playSound(player.getLocation(), Sound.GHAST_FIREBALL, 1.0f, 1.0f); player.launchProjectile(SmallFireball.class); } else { player.sendMessage(ChatColor.AQUA + String.format(Locale.get("message.cooldown", Locale.getPlayerLocale(player)), ((double) (cooldown - System.currentTimeMillis() / 50)) / 20d)); } } }
@Override public boolean cast(Player p, PlayerDataRPG pd, int level) { SmallFireball fireball = (SmallFireball) p.launchProjectile(SmallFireball.class); fireball.setIsIncendiary(false); fireball.setShooter(p); int damage = pd.getDamage(true); damage *= functions[0].applyAsDouble(level) / 100.0; fireball.setMetadata(RMetadata.META_DAMAGE, new FixedMetadataValue(Spell.plugin, damage)); Spell.notify(p, "You shoot off a fireball."); return true; }
public void executeMagic(Player player) { SmallFireball fb = player.launchProjectile(SmallFireball.class); fb.setIsIncendiary(true); fb.setBounce(false); fb.setShooter(player); //fb.setVelocity(new Vector(1.0, 0, 0)); //fb.setDirection(p.getVelocity().add(p.getLocation().toVector().subtract(this.b.getEntity().getLocation().toVector()).normalize().multiply(Integer.MAX_VALUE))); }
public static void smallFireballHit(SmallFireball fb) { Location loc = fb.getLocation(); World world = loc.getWorld(); showCracks(loc, 1); world.playEffect(loc, Effect.MOBSPAWNER_FLAMES, 0); }
@SuppressWarnings("unchecked") public <T extends Projectile> T launchProjectile(Class<? extends T> projectile) { net.minecraft.world.World world = ((CraftWorld) getWorld()).getHandle(); net.minecraft.entity.Entity launch = null; if (Snowball.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.projectile.EntitySnowball(world, getHandle()); } else if (Egg.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.projectile.EntityEgg(world, getHandle()); } else if (EnderPearl.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.item.EntityEnderPearl(world, getHandle()); } else if (Arrow.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.projectile.EntityArrow(world, getHandle(), 1); } else if (Fireball.class.isAssignableFrom(projectile)) { Location location = getEyeLocation(); Vector direction = location.getDirection().multiply(10); if (SmallFireball.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.projectile.EntitySmallFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ()); } else if (WitherSkull.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.projectile.EntityWitherSkull(world, getHandle(), direction.getX(), direction.getY(), direction.getZ()); } else { launch = new net.minecraft.entity.projectile.EntityLargeFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ()); } launch.func_70012_b(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); } Validate.notNull(launch, "Projectile not supported"); world.func_72838_d(launch); return (T) launch.getBukkitEntity(); }
@SuppressWarnings("deprecation") @Override public boolean run(Player player, String[] args, int power) { BlockBreakEvent e = new BlockBreakEvent(player.getTargetBlock(null, 1000), player); Bukkit.getPluginManager().callEvent(e); if (e.isCancelled()) { return false; } player.launchProjectile(SmallFireball.class); return true; }
@SuppressWarnings("unchecked") public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) { net.minecraft.world.World world = ((CraftWorld) getWorld()).getHandle(); net.minecraft.entity.Entity launch = null; if (Snowball.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.projectile.EntitySnowball(world, getHandle()); } else if (Egg.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.projectile.EntityEgg(world, getHandle()); } else if (EnderPearl.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.item.EntityEnderPearl(world, getHandle()); } else if (Arrow.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.projectile.EntityArrow(world, getHandle(), 1); } else if (ThrownPotion.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.projectile.EntityPotion(world, getHandle(), CraftItemStack.asNMSCopy(new ItemStack(Material.POTION, 1))); } else if (ThrownExpBottle.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.item.EntityExpBottle(world, getHandle()); } else if (Fish.class.isAssignableFrom(projectile) && getHandle() instanceof net.minecraft.entity.player.EntityPlayer) { launch = new net.minecraft.entity.projectile.EntityFishHook(world, (net.minecraft.entity.player.EntityPlayer) getHandle()); } else if (Fireball.class.isAssignableFrom(projectile)) { Location location = getEyeLocation(); Vector direction = location.getDirection().multiply(10); if (SmallFireball.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.projectile.EntitySmallFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ()); } else if (WitherSkull.class.isAssignableFrom(projectile)) { launch = new net.minecraft.entity.projectile.EntityWitherSkull(world, getHandle(), direction.getX(), direction.getY(), direction.getZ()); } else { launch = new net.minecraft.entity.projectile.EntityLargeFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ()); } ((net.minecraft.entity.projectile.EntityFireball) launch).projectileSource = this; launch.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); } Validate.notNull(launch, "Projectile not supported"); if (velocity != null) { ((T) launch.getBukkitEntity()).setVelocity(velocity); } world.spawnEntityInWorld(launch); return (T) launch.getBukkitEntity(); }
/** * It hit the ground maybe! * * @param event the impact event, we ignore any that aren't just blockhits */ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void gunBulletHitGroundEvent(ProjectileHitEvent event) { if (!EntityType.SMALL_FIREBALL.equals(event.getEntityType())) return; if (event.getHitBlock() == null) return; SmallFireball bullet = (SmallFireball) event.getEntity(); if (!bullet.getName().equals(this.tag)) return; Location end = event.getHitBlock().getLocation().clone().add(0.5, 0.5, 0.5); World world = end.getWorld(); // make a new sound where it hits. world.playSound(end, Sound.ENTITY_FIREWORK_BLAST, 1.0f, 1.5f); // make a splash world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.5, 0.0, 0.0), 5); world.spawnParticle(Particle.BLOCK_DUST, end.clone().add(-0.5, 0.0, 0.0), 5); world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.0, 0.5, 0.0), 5); world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.0,-0.5, 0.0), 5); world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.0, 0.0, 0.5), 5); world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.0, 0.0,-0.5), 5); Entity hit = event.getEntity(); if (hit == null) { Location start = travelPaths.remove(bullet.getUniqueId()); if (start != null) { double distance = end.distance(start); Vector vector = end.subtract(start).toVector(); vector = vector.multiply(1.0d / distance); for (int i = 0; i < distance; i++) { world.spawnParticle(Particle.FLAME, start.add(vector), 5); } } bullet.remove(); return; } }
@Override public CastResult onCast(User user, int power, String[] args) { user.getPlayer().launchProjectile(SmallFireball.class); return CastResult.SUCCESS; }
@Override public void effect(Event e, ItemStack item, int level) { EntityShootBowEvent event = (EntityShootBowEvent) e; event.setCancelled(true); event.getEntity().launchProjectile(SmallFireball.class); }
@Override public boolean use(Player player) { SmallFireball fireball = player.launchProjectile(SmallFireball.class); fireball.setMetadata("isFireBreath", new FixedMetadataValue(plugin, true)); return true; }
@Override public boolean run(Player player, ConfigurationSection config) { player.launchProjectile(SmallFireball.class); return true; }
public Bullet(SwornGuns plugin, GunPlayer shooter, Gun shotFrom, Vector velocity) { this.plugin = plugin; this.shotFrom = shotFrom; this.shooter = shooter; this.velocity = velocity; this.active = true; if (shotFrom.isThrowable()) { ItemStack thrown = shotFrom.getMaterial().newItemStack(1); this.projectile = shooter.getPlayer().getWorld().dropItem(shooter.getPlayer().getEyeLocation(), thrown); this.id = projectile.getEntityId(); ((Item) projectile).setPickupDelay(9999999); this.startLocation = projectile.getLocation(); } else { Class<? extends Projectile> mclass = Snowball.class; String check = shotFrom.getProjType().toLowerCase().replaceAll("_", "").replaceAll(" ", ""); switch (check) { case "arrow": mclass = Arrow.class; break; case "egg": mclass = Egg.class; break; case "enderpearl": mclass = EnderPearl.class; break; case "fireball": mclass = Fireball.class; break; case "fish": case "fishhook": mclass = FishHook.class; break; case "largefireball": mclass = LargeFireball.class; break; case "smallfireball": mclass = SmallFireball.class; break; case "thrownexpbottle": mclass = ThrownExpBottle.class; break; case "thrownpotion": mclass = ThrownPotion.class; break; case "witherskull": mclass = WitherSkull.class; break; default: break; } this.projectile = shooter.getPlayer().launchProjectile(mclass); this.id = projectile.getEntityId(); ((Projectile) projectile).setShooter(shooter.getPlayer()); this.startLocation = projectile.getLocation(); } if (shotFrom.getReleaseTime() == -1) { this.releaseTime = 80 + (shotFrom.isThrowable() ? 0 : 1) * 400; } else { this.releaseTime = shotFrom.getReleaseTime(); } }