Launch Minecraft listening for malmoenv connections.
    Args:
        port:  the TCP port to listen on.
        installdir: the install dir name. Defaults to MalmoPlatform.
        Must be same as given (or defaulted) in download call if used.
        replaceable: whether or not to automatically restart Minecraft (default is false).

def launch_minecraft(port, installdir="MalmoPlatform", replaceable=False):
    """Launch Minecraft listening for malmoenv connections.
    Args:
        port:  the TCP port to listen on.
        installdir: the install dir name. Defaults to MalmoPlatform.
        Must be same as given (or defaulted) in download call if used.
        replaceable: whether or not to automatically restart Minecraft (default is false).
    """
    launch_script = './launchClient.sh'
    if os.name == 'nt':
        launch_script = 'launchClient.bat'
    cwd = os.getcwd()
    os.chdir(installdir)
    os.chdir("Minecraft")
    try:
        cmd = [launch_script, '-port', str(port), '-env']
        if replaceable:
            cmd.append('-replaceable')
        subprocess.check_call(cmd)
    finally:
        os.chdir(cwd)