Solved ExplodeOnSomeEvent

Discussion in 'Plugin Development' started by AlisiaRose, Aug 22, 2015.

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

    AlisiaRose

    Hello, Bukkit world!

    Is there any way to cause an explosion event that affects one and only one entity (and subsequently nullifying resultant fall damage, if any, but this I know how to handle), such that other entities are not affected by the damage or the force? I know of ways to cancel the damage event, but how does one cancel the explosive force for all but one entity?
     
  2. Offline

    au2001

    @AlisiaRose You probably want to create a fake explosion, then apply custom damage and velocity.
    I'm not aware of any other method to do that :/
     
  3. Offline

    SuperSniper

    Possibly just cancel the damage, then get nearby entities of the explosion, check if the entity is around it, if it is, damage that entity manually
     
  4. Offline

    au2001

  5. Offline

    SuperSniper

    Just change the entity's velocity by using entity.setVelocity
     
  6. Offline

    au2001

    @SuperSniper You would have to cancel block damage, entity damage (but one player), etc.
    Why wouldn't she just create a fake particle, then apply all that to the player she already has (I guess?) instead of looping through all the entities and check for a saved player? :p

    Don't save things so that you can do things you can do immediately, don't loop through useless entities, don't listen for useless events: you'll use less RAM so less heat will be produced, save the planet! Peace.
     
    Shortninja66 likes this.
  7. Offline

    Shortninja66

    You can create a particle effect and loop through the entities that are within a radius of your effect location. This way is a lot simpler.
     
  8. Offline

    au2001

    @Shortninja66 Well, no need to loop through entities as it is only affecting one entity...
    But yes, I'm absolutely in agreement with you.
    Just one thing: World#createExplosion with a 0.0f power would be fine I guess (but you wouldn't have "huge" explosions particles) :(
     
  9. Offline

    Shortninja66

    @au2001 You would surely have to loop through the entities in the radius to check if there is the entity that you want to damage, right? That's how I do my particle effects that damage entities.
     
  10. Offline

    AlisiaRose

    Ah, I didn't expect replies so soon >w<

    Thank you for the advice! I must ask, though, if I did indeed set nearby entities' velocities to 0, would that interfere with entities that shouldn't be randomly stopped (e.g. a minecart rail system or the like)? I wouldn't want that happening to players on a roller coaster (e.g. if a single selected player were to be explosively ejected from his/her seat or something)

    I will see what I can do tomorrow, though.
     
  11. @AlisiaRose
    Answering to the OP:
    Yes, there is:
    * Explode a TNT
    * Remove all blocks from the explosion events (if you don't want it to damage the enviornment)
    * check on entity damage by entity if the damager was a primed TNT
    * if the entity is not the desired one, cancel damage event
     
  12. Offline

    au2001

    Or:
    * Summon a fake TNT explosion (particles & sounds)
    * Damage the desired player and set his velocity

    Why would you set nearby entities velocity to 0?
    In either way, you don't have to interfere with any of the other entities:
    The other way: Since you cancel the event, the explosion won't affect anything, nor will it propulse players
    My way: The explosion is only made of particles, you won't have to care about blocks or any other entity
     
  13. Offline

    AlisiaRose

    Oh fine~

    Fake explosion works, too >w<
    At least I now have much more control over how hard and in which direction a player gets propelled without needing unnecessary stuffies.

    Thanks for the advice!
     
    au2001 likes this.
Thread Status:
Not open for further replies.

Share This Page