Summoning an explosion help.

Discussion in 'Plugin Development' started by mkezar, Jun 14, 2014.

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

    mkezar

    Hi. I am making a meteor plugin. When you right click a fire charge, where your crosshairs are looking, it will spawn an explosion 20 blocks above the crosshairs target. Then after 3 ticks it will spawn another explosion 19 blocks above the target. Then it will eventually reach 18, 17, 16, 15, 14, 13, 13, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 until it reaches the ground. We'll first, how would I make it so it will actually spawn a TNT explosion 20 blocks above the crosshairs. I know how to make it directly on the crosshairs but how would I make it 20 blocks above the crosshairs location? After I solve this question I will do the same to all the numbers all the way down to 1. Once I solve this, how would I separate each explosion by 3 ticks? Thank you! :)
     
  2. Offline

    jpjunho

    use Location.add(); method to get the block 20 blocks higher and then start a repeating task of 3 ticks and subtract the numbers and just keep creating explosion with World.createExplosion(); method
     
  3. Offline

    bdubz4552

    Lets pretend we just used the command "/meteor leeroy", and this will drop the meteor as you said you wanted it to happen, on the player "leeroy".
    Code:java
    1. //First we get the target player from the command, his position, and set the meteor's position relative to him.
    2. if (args.length == 1) {
    3. Player player = Bukkit.getPlayer(args[0]);
    4. Location location = player.getLocation();
    5. Location meteorStart = new Location(player.getWorld(), location.getX(), location.getY() + 20, location.getZ());
    6. }

    Now, to do the 3 tick incrementing, you will need to use the Bukkit scheduler and create a task to run in 3 tick intervals. I do not have experience with this, and do not feel comfortable blindly guiding you through it.
    However, once you set up your scheduled task, you can have it run:
    Code:java
    1. player.getWorld().createExplosion(meteor, 4);
    2. //Something to decrease the meteor's height

    And that should create the effect you're looking for.
     
  4. Offline

    mkezar

    Bump

    Thanks

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
Thread Status:
Not open for further replies.

Share This Page