Turn off fire when lightning strikes

Discussion in 'Plugin Development' started by alexander7567, Oct 15, 2013.

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

    alexander7567

    I am currently working on my first plugin, LightingStick.

    I am trying to figure out how to disable the strike causing a fire at the base. Here is what I have tried without success:

    Code:
    LightningStrike lightning = p.getWorld().strikeLightning(loc);
    lightning.setFireTicks(0);
    I am not sure if there is a way to disable the fire, or if I have to extinguish the block right after the strike (which I am not sure how to do that either).

    Thanks for any help!
     
  2. Offline

    Rocoty

    use strikeLightningEffect instead
     
    akminecrafthowto likes this.
  3. Offline

    johnnywoof

    If you want to use lightning just for the effects and sounds, you can use
    Code:
    p.getWorld().strikeLightningEffect(loc);
    However if you want the kill power in the lighting, you'll need to extinguish the block.

    I was so close :'(

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

    alexander7567

    Thank you... that was it!

    wait.. This also disables damage to an entity. Is there any way to enable damage but disable fire?

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

    MrSnare

    create a new EntityDamageByEntityEvent and call it
     
  6. Offline

    Rocoty

    You could get all entities within a small radius and damage them.
     
  7. Offline

    alexander7567

    How can I extinguish the block? I would rather this than just lightning effect.
     
  8. Offline

    metalhedd

    on BlockIgniteEvent, check if the ignition cause is LIGHTNING, if so, cancel it.

    Code:java
    1.  
    2. @EventHandler
    3. public void onBlockIgnite(BlockIgniteEvent event) {
    4. if (event.getCause() == IgniteCause.LIGHTNING) {
    5. event.setCancelled(true);
    6. }
    7. }
    8.  
     
  9. Offline

    alexander7567

    But wouldn't this effect all lightning on the server? I am wanting a method that will only effect the lightning that is caused by my plugin?
     
  10. Offline

    EcMiner

    Maybe, i'm not sure, you could store the location where the lightning strikes, then in BlockIgniteEvent check if the block that was ignited is the same as the location (or same x and y if the height is different) and then cancel the event
     
    MrSnare likes this.
  11. Offline

    johnnywoof

    Well, this is your only option. If you don't like it then I'm not sure what will. This will make lightning, disable the fire from it, and damage entities. Also I made it in to a nice neat method.
    Please note: I typed all of this here, there could be mistakes.

    Code:
    public void strikelightningwithoutfire(Location loc){
        loc.getWorld().strikeLightningEffect(loc);
        for(LivingEntity e : loc.getWorld().getLivingEntities()){
               if(e.getLocation().distance(loc) < 3D){
                    e.damage(2); //one heart
               }
         }
    }
    
     
    Fozie likes this.
  12. Offline

    alexander7567

    Thanks, I like that and will probably use it on my next release! I think bukkit should make it where we can edit those kinds of things in our code when we create lightning and various things like that.
     
Thread Status:
Not open for further replies.

Share This Page