How to stop TNT explosions when near redstone

Discussion in 'Plugin Development' started by finalblade1234, Jan 26, 2013.

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

    finalblade1234

    How do i stop TNT explosions when its near when near redstone
     
  2. Offline

    Bench3

    Make a cube around the tnt then check if any of the blocks are restone. If so, cancel the event:

    Code:
    public boolean isNearRedstone(Block block){
        int x = block.getX(), y = block.getY(), z = block.getZ();
        for(int Bx = -5;Bx<5;Bx++){
            for(int By = -5;By<5;By++){
                for(int Bz = -5;Bz<5;Bz++){
                    if (block.getWorld().getBlockAt(x+Bx,y+By,z+Bz).getType() == Material.REDSTONE){ //can add more checks
                        return true;
                    }
                }
            }
        }
    return false;
    }
     
  3. Offline

    raGan.

Thread Status:
Not open for further replies.

Share This Page