Remove fireball explosion and firespread?

Discussion in 'Plugin Development' started by paalbra, Jul 28, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    paalbra

    Hi

    I'm trying to learn how to create plugins(Totaly new to it) and right now i'm trying to remove the explosion and firespread when a fireball hits something, but i can't make the firespread go away.

    I first thought that i just could cancel the explode event, but it still spreads fire. Then i tried to falsify the incendiary option, but no go. What can i do about this?

    This is part of my code with block damage properly removed, but not firespread:
    Code:
    public void onEntityExplode(EntityExplodeEvent event) {
        Entity ent = event.getEntity();
    
    if (ent instanceof Fireball) {
            ((Fireball) ent).setIsIncendiary(false);
            event.setCancelled(true);
        }
    }
    I'm running craftbukkit v.1000 with no other plugins. Just my tiny "testing and learning plugin"(As i said: i'm new to this).
     
  2. You almost have it. But I don't know if you need access to the fireball before it hit's a target. Where does the ball come from?
    Anyway, this is from a plugin I'm currently working on:
    Code:
    fireball.setIsIncendiary(false);
    fireball.setYield(0F);
    In that case the fireball is created right before:
    Code:
    Fireball fireball = block.getWorld().spawn(start, Fireball.class);
    fireball.setDirection(new Vector(0,5,0));
    The yield should stop explosion/fire completely. If you want a big bam try to set it to a high value... But you can easyily destoy large areas of a map with such balls. You have been warned. ;)

    //EDIT: Of course the ball burns and I don't know if that fire will spread, but that's contolled by the fireTicks. Set them to 0 and you should have a non-fire-fireball...
     
    PogoStick29 likes this.
  3. Offline

    paalbra

    It entered my mind that i might have to do it before. But this fireball is spawned by a normal ghast, and i can't find any events that triggers when a ghast fires a fireball. How can i get the fireball entity while in flight/when spawned?

    And i though that the fire around the ball was just a visual effect, but if it's not i could set the fireTicks to 0, as you say :)

    Thanks for the reply
     
  4. Offline

    Tster

    ent.setFireTicks(0)?

    That should work, also set incediary to false, and use a block break event to recover exploded blocks rather than cancelling entity_explode

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 18, 2016
  5. Offline

    paalbra

    Hm? This doesn't help because the fireball has hit something already and caused fire?
    Why not simply cancel the event rather than recovering all the blocks?
     
  6. Offline

    Tster

    Well I havent tried but It seems logical to me, have you tried the simplest form of entity explode?, also there is a chance it maybe under PROJECTILE_HIT
     
  7. Good question, I didn't had a look into something similar before,
    Maybe onItemSpawn or onCreatureSpawn can be used?
     
  8. Offline

    nisovin

    Try using ExplosionPrime rather than EntityExplode.
     
  9. Offline

    paalbra

    Ok. I've now tested more and i do think i've managed to accomplish what i wanted. What i wanted is:
    * Creepers shouldn't do block damage, but they should damage players.
    * Ghast should fire fireballs, but the fireball shouldn't do block damage, nor should it make blocks turn on fire.
    These methods fixes this:
    Code:
    public void onEntityExplode(EntityExplodeEvent event) {
    	Entity ent = event.getEntity();
    	
    	if (ent instanceof Creeper || ent instanceof Fireball) {
    		event.setCancelled(true); //Removes block damage
    	}
    }
    public void onExplosionPrime(ExplosionPrimeEvent event) {
    	event.setFire(false); //Only really needed for fireballs
    	
    	Entity ent = event.getEntity();
    	if (ent instanceof Fireball)
    		event.setRadius(2); //Increased from default(1), since the fireball now don't cause fire
    }
    I find it kind of odd that the setCancelled removes the block damage, but not playerdamage. But since this is what i want it's all good :) But if anybody know why this is, please explain :)

    Thanks for all the inputs on this :)
     
  10. Maybe you have to cancel onEntityInteract for no player damage, too?
     
  11. Offline

    paalbra

    There seem to be called an EntityDamageEvent that damages the player if you are in the radius of the explosion. I guess you could cancel this event or sett the damage to 0, but i want the player to be damaged, so i'm not gonna try it out. If anybody else feel like trying this out, please tell us what you find out :)

    But i find it kinda odd that this event is triggered. Shouldn't one believe that this event builds upon the EntityExplodeEvent, and therefore also would be canceled?
     
  12. And if so: How would you cancel block damage or player damage, then? You could only cancel block+player damage and never finish your plugin. :D

    //EDIT: But entityDamage whould prevent you from getting health changes if you eat something o get hitted fom another event when the exploison happens! That's why I was thinking about onEntityInteract or something which traces the explosion back to the fireball. ;)
     
Thread Status:
Not open for further replies.

Share This Page