Minecraft forge 1.18.1 no targetable jar

Third option is another callback function in the chain that pretty much does the same thing. I am thinking that separating things into a handler class or separating the functions into separate files or something might be able to reduce the size of the monolith that is mineos.js

function(err,cb){
        // in theory this will only run if the launch jar is forge*installer.jar and the run.sh has been generated. (meaning this could be run multiple times)
        var runPath = `${self.env.cwd}/run.sh`; //set the runPath to location of run.sh
        if(sc.java.jarfile.includes('forge') && sc.java.jarfile.includes('installer') && fs.existsSync(runPath)){ //if the selcted jar has forge and installer in the name and the run.sh exists
          var binary = which.sync('screen');
          var run = fs.readFileSync(runPath, 'utf8').split('\n').filter(line => line.charAt(0) !== '#' && line !== '')[0]; //read the run.sh and just get the executable line 
          var unixArgsLoc = run.split('@')[2].split('unix_args.txt')[0];
          var unix_args = `@${unixArgsLoc}unix_args.txt`; //get the unix_args.txt location 
          var dir = fs.readdirSync(`${self.env.cwd}/${unixArgsLoc}`).filter(elm=> elm.includes('universal'));
          var universal = `${self.env.cwd}/${unixArgsLoc}${dir[0]}`;
          fs.copyFileSync(universal, `${self.env.cwd}/${dir[0]}`);

          self.modify_sc('java','jarfile',dir[0]);
          self.modify_sc('java','java_tweaks',unix_args);
          self.modify_sc('java','java_xmx', '1024');

          cb();
        } else {
          cb();
        }
      }
1 Like