Create Explosion

Discussion in 'Plugin Development' started by thatdubstepgamer, Sep 15, 2013.

Thread Status:
Not open for further replies.
  1. How do I create an explosion when I through a snowball and get the location of the snowball and create a explosion there
     
  2. Offline

    uyuyuy99

    thatdubstepgamer Listen for the ProjectileHitEvent, get the entity from it, and check if it's a snowball. Then, get its location, and use World.createExplosion(location)
     
  3. Yeah ive tried many things I know to use World.createExplosion but I cant get the location!
     
  4. Offline

    chasechocolate

  5. so how do I add this into my code?
     
  6. Offline

    chasechocolate

    thatdubstepgamer listen for ProjectileHitEvent, check if event.getEntity() instanceof Snowball, create a variable: Snowball snowball = (Snowball) event.getEntity(), then use snowball.getWorld().createExplosion(snowball.getLocation(), 4.0F).
     
  7. Offline

    JPG2000

    thatdubstepgamer Do exactly what chasechocolate said. If you still don't get it, heres an example:
    Code:java
    1. @EventHandler
    2. public void onSnowBallHit(ProjectileHitEvent event) {
    3. if (event.getEntity() instanceof Snowball) {
    4. Snowball ball = (Snowball) event.getEntity();
    5. ball.getWorld().createExplosion(ball.getLocation(); 4.0)
    6. }
    7. }
     
Thread Status:
Not open for further replies.

Share This Page