TNT Block Explosion

Discussion in 'Archived: Plugin Requests' started by TheCoolGuy123_5, Mar 7, 2014.

  1. Offline

    TheCoolGuy123_5

    Plugin category: ?

    Suggested name: TNTExplosion

    What I want: I want a plugin that makes it so when TNT blows up, all the blocks blow up in the air (as fallingsand) and fall back down. I would love that and probably the players on my server.
    Everyone can do it by default.

    Ideas for commands: A way to disable possibly

    Ideas for permissions: PluginName.Disallow - Whoever has the perm cannot use it

    When I'd like it by: As soon as you can.
     
  2. Offline

    filbert66

    I have something similar to that in my plugin,
    http://dev.bukkit.org/bukkit-plugins/AntiCreeper/
    . Set nerf_tnt.blockphysics to true.
    At first I tried throwing the blocks, as falling sand as you suggest such that they fell somewhere else, but found it odd that it was "building" as a result of explosion. So now it throws the blocks as items (dropped blocks). Give it a try.
     
  3. Offline

    TheCoolGuy123_5

    filbert66 I don't think that's a feature. Do you want me to show a picture? [It will be hard to get it]
     
  4. Offline

    Splated

    This appeals to my interests.

    Are you thinking like a cartoon, the bomb blows the blocks up then they fall back down into the same spots they left?

    Or the blocks are relocated around the rim of the crater randomly?
     
  5. Offline

    filbert66

    I know that AntiCreeper's blockphysics doesn't do exactly what you're asking. But it's close. Wouldn't be hard to modify back to throwing the blocks if you are insistent on that.

    I have same question as Splated: do blocks fall back where they started or get spread about randomly?
     
  6. Offline

    TheCoolGuy123_5

    Splated The blocks relocated.

    filbert66 I tried AntiCreeper and I couldn't even use it, no config, no settings, etc. (I just loaded it from another plugin, never restarted server maybe)
     
  7. Offline

    Splated

    TheCoolGuy123_5

    I think this could be done but where it will cause extra lag in a huge explosion.


    I can experiment and add it to http://dev.bukkit.org/bukkit-plugins/boom-guard/


    Heres what I'm thinking pseudo code;
    Code:java
    1.  
    2. void on explode (event){
    3. Block GroundZero = center of explosion;
    4.  
    5. List of affected block = event.getlist();
    6.  
    7. for (b = blocks in list){
    8. if (b.gety() > GroundZero.gety() && some random % of blocks) {
    9.  
    10. loc = (some vector calculation based position relative to GroundZero);
    11.  
    12. loc = loc * some random force;
    13. world.makeFallingblockat( loc, b.gettype);
    14.  
    15. }
    16.  
    17.  
    18. }
    19.  
     
  8. Offline

    TheCoolGuy123_5

  9. Offline

    GetGoodKid

    The reason this plugin hasn't been created yet is because it is basically impossible to achieve the effect you want without a client-side mod. Sorry to burst your bubble.
     
  10. Offline

    timtower Moderator Moderator

    Sorry to burst your bubble but it is possible:
    http://forums.bukkit.org/threads/singularity-grenade.149054/
    Falling sand blocks
     
  11. Offline

    TheCoolGuy123_5

    GetGoodKid I've seen bukkit servers with it happening, that's where I got the idea.
     
  12. Offline

    Splated

    GetGoodKid

    Its totally possible.

    I got it working but I need some help with the vector calculations.

    When I location.add(0.5,0.5,0.5) to the blocks, should be center of block, the flying blocks are way off to one side.
    And i need to make v.multiply(3); stronger when its closer to the bomb.


    Code:java
    1. @EventHandler(priority = EventPriority.LOW)
    2. public void onEntityExplode(EntityExplodeEvent event) {
    3. List<String> list = this.getConfig().getStringList("BlockName");
    4.  
    5.  
    6.  
    7. World world = event.getLocation().getWorld();
    8.  
    9.  
    10. List<Block> destroyed = event.blockList();
    11.  
    12. Iterator<Block> it = destroyed.iterator();
    13. while (it.hasNext()) {
    14. Block block = it.next();
    15. String name = block.getType().toString();
    16.  
    17. if( list.contains(name) ) it.remove();
    18.  
    19.  
    20. if (this.getConfig().getBoolean("BlowUP")){
    21. Location first_location = event.getLocation();
    22.  
    23. Location Second_location = block.getLocation();
    24.  
    25.  
    26.  
    27. Vector v = Second_location.toVector().subtract(first_location.toVector());
    28.  
    29. v.multiply(3);
    30.  
    31.  
    32. Block b = first_location.getBlock().getRelative(v.getBlockX(), v.getBlockY(), v.getBlockZ());
    33.  
    34.  
    35. if (b.getType() == Material.AIR){
    36.  
    37. //b.setType(block.getType());
    38.  
    39.  
    40. world.spawnFallingBlock(b.getLocation(), block.getType(), block.getData());
    41. }
    42.  
    43.  
    44.  
    45. }
    46.  
    47.  
    48.  
    49. }
    50.  
    51.  
    52.  
    53.  
    54.  
    55.  
    56. }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  13. Offline

    GetGoodKid

    I stand corrected. My apologies :p
     
    timtower likes this.
  14. Offline

    filbert66

    Physics laws say power will dissipate from spherical explosion by distance from center squared, so Splated take max power and divide by v.length() * v.length() (before you multiply by 3).
     
  15. Offline

    Splated

  16. Offline

    TheCoolGuy123_5

    Splated I tried using it, Its not working for me. I see no fallingsand blocks except on trees (only like 4).
     
  17. Offline

    Splated

    There needs to be air blocks where the blocks will be blasted too.
    Try putting the tnt a block under ground?

    TheCoolGuy123_5 I added more config options so you can turn up the distance the blocks are thrown and turn gravity on and off.

    http://dev.bukkit.org/bukkit-plugins/boom-guard/files/6-boom_guard-vb-3-1/


    I'm having fun with this, I may expand or remake boom guard to have lots of tnt tweaks.

    [​IMG]

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  18. Offline

    filbert66

    I guess the advantage to this vs. vanilla is that the "missing" blocks don't despawn; someone can collect them and put them back in place. Of course, you could just use AntiCreeper so that the block damage doesn't happen at all...
     
  19. Offline

    Splated

    I disabled the random and distance*power calculations. Theres 1 tnt in the center.
    and gravity is off.


    [​IMG]

    i need to blow up some villages like this lol.

    I was thinking about that singularity-grenade Idea. I could have all the blocks that are affected become air and respawn the block as an item, at the explosions center of the blast, could look cool.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  20. Offline

    filbert66

    Splated you are having too much fun.
     
    Splated and timtower like this.
  21. Offline

    Splated

    filbert66 well yeah, I don't make plugins that are boring, thats like doing work. :p

    The singularity thing didn't work to well its covered by the explosion particle effects.

    Wow falling blocks are affected by TNT. :)


    Not sure when it will finish uploading.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  22. Offline

    Mysticate

  23. Offline

    Splated

    I think my video broke i'll upload again when I get home.

    But a small tweak in the code and now the falling blocks go flying. :)

    Code:java
    1. if (this.getConfig().getBoolean("BlowUP-WithGravity")){
    2. FallingBlock fallb = world.spawnFallingBlock(block.getLocation(), block.getType(), block.getData());
    3. block.setType(Material.AIR);
    4. fallb.setVelocity(v.normalize());
    5. it.remove();
    6.  
    7. continue;
    8. }
     
  24. Offline

    TheCoolGuy123_5

    Its getting close, but one problem is. I mined into a wall put tnt and ignited, the blocks fly through the ground

    [​IMG]
    [​IMG]
     
  25. Offline

    Mysticate

  26. Offline

    TheCoolGuy123_5

  27. Offline

    filbert66

    Are you spawning the falling blocks at their destination or at their origin? If you do at origin, they will hit other blocks and stop there. Kind of kills mining with TNT method.
     
  28. Offline

    Splated

    fixed it

    filbert66 what I did to start was spawned the falling block at the destination(if its air), My new idea is, I turned all the affected blocks into falling blocks, then applied the momentum to to them. a lot of them smash into the walls becoming items. so it basically works.

    Then for fun i inverted the momentum making them implode. :)



    hehe i figured it out. The recording and huge explosion made it a tad laggy

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
    filbert66 likes this.
  29. Offline

    filbert66

    Where do all the blocks go in the singularity? The singularty request there ended with them all exploding outward with great velocity
     
  30. Offline

    Splated

    I could make them explode out after currently they are randomly destroyed until none are left.

    The problem is you need a big explosion to make it work, otherwise they hit a sold block and "land" becoming a block again.

    I'm going to make a new mod and leave boom guard alone.
     

Share This Page