Solved Whats the best way to create an explosion that only damages one player?

Discussion in 'Plugin Development' started by MCnumi, Jul 10, 2016.

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

    MCnumi

    Basically the title, but to be specific, in my case I am trying to create an explosion that will only damage one player. I have thought of sending an explosion effect packet, with the sound, to the player, then just manually take away 2 hearts, but that seems like too much. Would there be a simpler approach to this?

    thanks :)
     
  2. Create a global boolean, set it to true when you start the explosion

    In the EntityDamageEvent check if the entity is an player, the boolean is true and the damagecause is BLOCK_EXPLOSION or ENTITY_EXPLOSION, then do what you want with that player, either cancel or let him take damage.
    At the end set the boolean to false again
     
  3. Offline

    MCnumi

    Im not looking to check if the cause is an explosion, I am looking to see how I can explode a single player.
     
  4. Offline

    kampai

    lol you could cancel the event make the damage 0, get the player and personally damage him how much you want
     
  5. Just make an explosion and then do an EntityDamageEntityEvent and check if the cause is explosion and the player is the one you want, and if it isnt, cancel the event
     
    MCnumi likes this.
  6. Offline

    MCnumi

    I was thinking of that too, but for some reason I thought it would iterate over all players in the server... I'll do that, thanks for the info!
     
Thread Status:
Not open for further replies.

Share This Page