On egg explosion add thick smoke in a radius of 6 blocks

Discussion in 'Plugin Development' started by Hogcraft, Sep 30, 2013.

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

    Hogcraft

    Hey guys,

    I want to kind of create a egg grenade which add smokes on the Projectille hit event, but I've no idea how to add it in thick way in a radius of x blocks. I was thinking of a runnable?

    I hope someone can help me!

    Thanks in advance :)!
     
  2. Offline

    Chinwe

    You could use nested for loops to loop through all blocks in a radius of x blocks, and play smoke in all directions there? Possibly-incorrect-code:
    Code:
    int rad = 3;
     
    for (int x = -rad; x <= rad; x++) {
      for (int y = -rad; y <= rad; y++) {
        for (int z = -rad; z <= rad; z++) {
          Block b = eggLocation.getBlock().getRelative(x,y,z);
          if (b.getType == Material.AIR)
            for (int i = 0; i < 8; i++) // plays in all directions
              b.getWorld().playEffect(b.getLocation(), Effect.SMOKE, i);
        }
      }
    }
       
    
     
  3. Offline

    MrSnare

    Get the location where you want the explosion and do this
    Code:java
    1.  
    2. for(int x = location.getX() - 6; x < location.getX() + 6; x++){
    3. for(int z = location.getZ() - 6; x < location.getZ() + 6; z++){
    4. Bukkit.getWorld().createExplosion(new Location(location.getWorld(), location.getX() + x, location.getY(), location.getZ() + z));
    5. }
    6. }


    Or something similar. That will create an explosion on every block around the location.
     
  4. Offline

    Garris0n

    I'm guessing what you mean by smoke is actually the blindness potion effect, otherwise there is no way to add "thick smoke" at the area.
     
  5. Offline

    Hogcraft

    Garris0n No I didn't mean that and it is actually possible to add thick smoke (just a VERY fast runnble spawning a LOT of smoke)
     
  6. Offline

    Zarkopafilis

    Spawn many OR make an Thread(NOT thread SAFE but with sleep) / Runnable(thread-safe, without sleep)
     
  7. Offline

    VpDefault

    That would be awesome though but probably requires a mod.
     
  8. Offline

    Hogcraft

Thread Status:
Not open for further replies.

Share This Page