Explosion code?

Discussion in 'Plugin Development' started by Datdenkikniet, Jun 23, 2013.

Thread Status:
Not open for further replies.
  1. What kind of code do you use to create an explosion at the location of the variable:
    Player s = (Player) sender;?
     
  2. Offline

    Burnett1

    Bukkit.getWorld(s.getWorld().getName()).createExplosion(s.getLocation(), SIZE);
     
    Datdenkikniet likes this.
  3. Offline

    chasechocolate

    Code:java
    1. Location loc = player.getLocation();
    2.  
    3. loc.getWorld().createExplosion(loc, 4.0F); //4.0 is about the same as a TNT explosion
     
    Datdenkikniet likes this.
  4. Offline

    ThatCoffeeBean

    chasechocolate
    Is there anyway of creating consecutive explosions that go of above the player getting higher and higher each time?
     
  5. ThatCoffeeBean why the necrobump?
    answer to your question: To do that, just increase the Y value of the location each time you create the explosion by a certain amount
     
  6. Offline

    ThatCoffeeBean

    Datdenkikniet How do i create them so the are consecutive and not all at once? say every 10 ticks
     
  7. ThatCoffeeBean schedule a runnable to run every 10 ticks, and execute your code for the explosion in it
     
  8. Offline

    ThatCoffeeBean

    Give me an example. I'm kinda lost here.

    Datdenkikniet

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
  9. ThatCoffeeBean alright, first of all: use the edit button :) (so you don't have to post twice)
    Second: I'm not here to spoon-feed you code, so I'll just tell you what to do in steps
    1. get the player's location
    2. save the player's location
    3. create a runnable which runs every 10 ticks, using Bukkit.getScheduler().scheduleSyncRepeatingTask() (find more info about that method here)
    4. store the Y value of the player's location somewhere
    5. increase the Y value of the player's location, and create the explosion there
    6. cancel the task when done.
    7. Nudding :D
     
  10. Offline

    ChipDev

    Check if a variable is true, I think maybe he wants it to happen at certain times..
     
  11. ChipDev he wants it to happen every 10 ticks, scheduling a runnable makes that happen.
     
  12. Offline

    ChipDev

    Yes, but heres what I mean: He maybe wants it to happen like, well when a minigame starts, not when it is starting (for example if he is making a minigame)
     
    Datdenkikniet likes this.
  13. Offline

    ThatCoffeeBean

    No it's not a mini-game :p

    This didn't really help guys. I'm gonna look else where but thanks anyway.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
  14. Alright, Alright, good point

    lel, how did this not help? (If you didn't understand my instructions, consider learning java)
     
    mythbusterma likes this.
  15. Offline

    ThatCoffeeBean

    Here, I wrote this yet still nothing. Any ideas.

    @EventHandler
    public void unicorn(PlayerInteractEvent evt) {
    if (evt.getAction() == Action.LEFT_CLICK_AIR
    | evt.getAction() == Action.LEFT_CLICK_BLOCK
    | evt.getAction() == Action.RIGHT_CLICK_AIR
    | evt.getAction() == Action.RIGHT_CLICK_BLOCK) {

    if (evt.getPlayer().getItemInHand() == new ItemStack(
    Material.BLAZE_ROD))
    ;


    }
    }
    public void derp(PlayerInteractEvent evt) {
    final Player p = evt.getPlayer();
    final Location loc = p.getLocation();
    if (p.getItemInHand().isSimilar(new ItemStack(Material.BLAZE_ROD))) {
    Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new BukkitRunnable(){
    public void run() {
    p.getWorld().createExplosion(loc.add(0, 1, 0), 4.0F);
    }

    }, 10, 10);

    }
    }
    }

    Is that what you were talking about Datdenkikniet
     
  16. ThatCoffeeBean yes, but can you post the full class and put it between sytax=java tags?
     
  17. Offline

    AronTheGamer

    ThatCoffeeBean
    What about using || instead of |. A condition after || will only be checked when the previous one returned false. Saves time & power.
     
    Datdenkikniet likes this.
Thread Status:
Not open for further replies.

Share This Page