Solved Disabling fireball block damage?

Discussion in 'Plugin Development' started by Zeryther, Apr 7, 2014.

Thread Status:
Not open for further replies.
  1. Hey there, Bukkit Community!

    I've got a problem:
    For a PvP Plugin, I made a class, that's able to cast spells like shooting arrows and fireballs. My problem is, that if a player shoots a fireball, he's breaking blocks. How can I disable that world damage?

    My code, if it helps:

    Code:java
    1. if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK){
    2. if(p.getItemInHand().getItemMeta().getDisplayName() == "§5§lZauberstab"){
    3. if(!plugin.used_fireball.contains(p.getName())){
    4. p.launchProjectile(Fireball.class);
    5. plugin.used_fireball.add(p.getName());
    6.  
    7. p.sendMessage(Vars.prefix + "Du hast den §4FIREBALL-SKILL §6benutzt!");
    8. p.sendMessage(Vars.prefix + "Du kannst diesen in 10 Sekunden wieder benutzen.");
    9. Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
    10.  
    11. @Override
    12. public void run(){
    13. plugin.used_fireball.remove(p.getName());
    14. p.sendMessage(Vars.prefix + "Du kannst nun wieder den §4FIREBALL-SKILL §6benutzen!");
    15. }
    16.  
    17. }, 20*10);
    18. }
    19.  
    20. if(plugin.used_fireball.contains(p.getName())){
    21. p.sendMessage("§cDer §4FIREBALL-SKILL §cmuss nachladen..");
    22. }
    23. }
    24. }
     
  2. Offline

    HeavyMine13

    ProjectileHitEvent, then cancel on instanceof Fireball.class, and e.getLocation().createExplostion(e.getEntity().getLocation(), 2.0f, false);;
     
  3. HeavyMine13
    There's no e.getLocation(), neither a e.getLocation().createExplosion() Method .. :-/
     
  4. Offline

    HeavyMine13

    What event ur using?
     
  5. Offline

    IkBenHarm

    Zeryther
    use instead of p.lacheProjectile();
    Code:
                        Location spawnAt = player.getEyeLocation().toVector().add(player.getEyeLocation().getDirection().multiply(3)).toLocation(player.getWorld());
                        Fireball fireball = player.getWorld().spawn(spawnAt, Fireball.class);
                        fireball.setDirection(vector.multiply(10));
                        fireball.setBounce(false);
                        fireball.setIsIncendiary(false);
                        fireball.setYield(4F);
                        fireball.setShooter(player);
    might wanna ad or remove some methods. But this gives you an idea
     
  6. Worked for me. Thanks :)

    HeavyMine13
    ProjectileHitEvent
     
Thread Status:
Not open for further replies.

Share This Page