Solved Exploding Splash Potion

Discussion in 'Plugin Development' started by jasonderlo22, Aug 9, 2013.

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

    jasonderlo22

    How would I make it so that if you dropped a splash potion of Fire Resistance it make a creeper explosion that destroys blocks.

    Thanks, Jason
     
  2. Offline

    evilguy4000

    jasonderlo22
    you need to get the location of where that potion was thrown and then you need to initialize an explosion at that place ;)
    You should try that :)
     
  3. Offline

    jasonderlo22

    evilguy4000
    How would I do that? Could I have an example? Would I use getLocation?
     
  4. My best tip: Try. Use google. this is rather easy and has been asked quite a lot of times ;)
     
    evilguy4000 likes this.
  5. Offline

    evilguy4000

  6. Offline

    jasonderlo22

  7. Offline

    The_Doctor_123

    Code:
        @EventHandler
        public void onPotionSplash(PotionSplashEvent event)
        {
            event.getEntity().getWorld().createExplosion(event.getEntity().getLocation(), 3F);
        }
    
    Supposing you know how to work with events, this will work.


    Explanation of the createExplosion() method:

    Arg #1: The location where you want the explosion.

    Arg #2: Power of the explosion. I believe 4 is creeper sized. Not sure. J:
     
  8. Offline

    jasonderlo22

    With this do I have to add anything to my class. Do I put it n my main class that extends JavaPlugin, or do I have to make it in another class, and implement anything?
     
  9. Offline

    The_Doctor_123

    Actually, I'm pretty sure he doesn't know the event API.

    Yes, you will have to. To make things nice and simple, register events to the main class by adding this:

    Code:
    @Override
    public void onEnable()
    {
    PluginManager pm = this.getServer().getPluginManager();
    pm.registerEvents(this, this);
    }
    
    Also, make your main class implement Listener

    Code:
    public class Main extends JavaPlugin implements Listener
    
    If you do all this, everything should work correctly. ;)
     
    jasonderlo22 likes this.
  10. Offline

    jasonderlo22

    Thank you so much I have now solved all my problems that have been bugging me. Again Thanks!
     
Thread Status:
Not open for further replies.

Share This Page