Exemplo n.º 1
0
def main(mcp_dir):
    print 'Using base dir: %s' % base_dir
    print 'Using mcp dir: %s (use -m <mcp-dir> to change)' % mcp_dir
    print 'Preferred architecture: %sbit - preferring %sbit native extraction (use -a 32 or -a 64 to change)' % (preferredarch, preferredarch)
    if dependenciesOnly:
        print 'Downloading dependencies ONLY'
    else:
        if nomerge is True:
            print 'NO Optifine merging'
        if nocompilefixpatch is True:
            print 'SKIPPING Apply compile fix patches'
        if nopatch is True:
            print 'SKIPPING Apply Minecrift patches'
        
    if clean == True:
        print 'Cleaning...'
        if force == False:
            print ''
            print 'WARNING:'
            print 'The clean option will delete all folders created by MCP, including the'
            print 'src folder which may contain changes you made to the code, along with any'
            print 'saved worlds from the client or server.'
            print 'Minecrift downloaded dependencies will also be removed and re-downloaded.'
            print 'Patches will be left alone however.'
            answer = raw_input('If you really want to clean up, enter "Yes" ')
            if answer.lower() not in ['yes']:
                print 'You have not entered "Yes", aborting the clean up process'
                sys.exit(1)        
        print 'Cleaning mcp dir...'
        reallyrmtree(mcp_dir)
        print 'Cleaning lib dir...'
        reallyrmtree(os.path.join(base_dir,'lib'))
        print 'Cleaning patchsrc dir...'
        reallyrmtree(os.path.join(base_dir,'patchsrc'))
        print 'Removing idea project files...'
        removeIdeaProject(base_dir)

    print 'Installing mcp...'
    installAndPatchMcp(mcp_dir)

    print("\nDownloading dependencies...")
    if includeForge:
        download_deps( mcp_dir, True, True ) # Forge libs

    download_deps( mcp_dir, True, False ) # Vanilla libs
    if dependenciesOnly:
        sys.exit(1)

    if nomerge == False:
        print("Applying Optifine...")
        optifine = os.path.join(mcp_dir,"jars","libraries","optifine","OptiFine",of_json_name,"OptiFine-"+of_json_name+".jar" )
        minecraft_jar = os.path.join( mcp_dir,"jars","versions",mc_version,mc_version+".jar")
        print ' Merging\n  %s\n into\n  %s' % (optifine, minecraft_jar)
        zipmerge( minecraft_jar, optifine )
    else:
        print("Skipping Optifine merge!")
    
    print("Decompiling...")
    src_dir = os.path.join(mcp_dir, "src","minecraft")
    if os.path.exists( src_dir ):
        shutil.rmtree( src_dir, True )
    sys.path.append(mcp_dir)
    os.chdir(mcp_dir)
    from runtime.decompile import decompile

    # This *has* to sync with the default options used in <mcpdir>/runtime/decompile.py for
    # the currently used version of MCP
    
    decompile(conffile=None,      # -c
              force_jad=False,    # -j
              force_csv=False,    # -s
              no_recompile=False, # -r
              no_comments=False,  # -d
              no_reformat=False,  # -a
              no_renamer=False,   # -n
              no_patch=False,     # -p
              only_patch=False,   # -o
              keep_lvt=False,     # -l
              keep_generics=mcp_uses_generics, # -g, True for MCP 1.8.8+, False otherwise
              only_client=True,   # --client
              only_server=False,  # --server
              force_rg=False,     # --rg
              workdir=None,       # -w
              json=None,          # --json
              nocopy=True         # --nocopy
              )

    os.chdir( base_dir )

    # Create original decompile src dir
    org_src_dir = os.path.join(mcp_dir, "src",".minecraft_orig")
    if os.path.exists( org_src_dir ):
        shutil.rmtree( org_src_dir, True )
    shutil.copytree( src_dir, org_src_dir )

    if nocompilefixpatch == False:
        compile_error_patching_done = False
        
        # Patch stage 1: apply only the patches needed to correct the
        # optifine merge decompile errors
        mcp_patch_dir = os.path.join( base_dir, "mcppatches", "patches" )
        if os.path.exists( mcp_patch_dir ):
            print("Patching Optifine merge decompile errors...")
            applychanges( mcp_dir, patch_dir="mcppatches/patches", backup=False, copyOriginal=False, mergeInNew=False )
            compile_error_patching_done = True
        
        # Address problem files - copy over directly
        problem_file_dir = os.path.join( base_dir, "mcppatches", "problemfiles" )
        if os.path.exists( problem_file_dir ):
            print("Addressing problem files...")        
            xp_problem_file = os.path.join(problem_file_dir, "xp.java")
            shutil.copy( xp_problem_file, os.path.join( mcp_dir, "src", "minecraft", "net", "minecraft", "src", "xp.java" ) )
            chunkrenderdispatcher_problem_file = os.path.join(problem_file_dir, "ChunkRenderDispatcher.java")
            shutil.copy( chunkrenderdispatcher_problem_file, os.path.join( mcp_dir, "src", "minecraft", "net", "minecraft", "client", "renderer", "chunk", "ChunkRenderDispatcher.java" ) )
            compile_error_patching_done = True

        # Update the client md5
        if compile_error_patching_done == True:
            print("Updating client.md5...")
            os.chdir(mcp_dir)
            from runtime.updatemd5 import updatemd5
            updatemd5( None, True, True, False )
            os.chdir( base_dir )

            # Now re-create the .minecraft_orig with the new buildable state
            if os.path.exists( org_src_dir ):
                shutil.rmtree( org_src_dir, True )
                shutil.copytree( src_dir, org_src_dir )
                
    if nopatch == False:
        # Patch stage 2: Now apply our main Minecrift patches, only
        # changes needed for Minecrift functionality
        print("Applying full Minecrift patches...")
        applychanges( mcp_dir )
    else:
        print("Apply patches skipped!")

    # create idea project if it doesn't already exist
    if not os.path.exists(os.path.join(base_dir, '.idea')):
        print("Creating idea project...")
        createIdeaProject(base_dir, mc_version, os.path.basename(mcp_dir), is32bitPreferred())
Exemplo n.º 2
0
def main(mcp_dir):
    print 'Using base dir: %s' % base_dir
    print 'Using mcp dir: %s (use -m <mcp-dir> to change)' % mcp_dir
    print 'Preferred architecture: %sbit - preferring %sbit native extraction (use -a 32 or -a 64 to change)' % (preferredarch, preferredarch)
    if dependenciesOnly:
        print 'Downloading dependencies ONLY'
    else:
        if nomerge is True:
            print 'NO Optifine merging'
        if nocompilefixpatch is True:
            print 'SKIPPING Apply compile fix patches'
        if nopatch is True:
            print 'SKIPPING Apply Minecrift patches'
        
    if clean == True:
        print 'Cleaning...'
        if force == False:
            print ''
            print 'WARNING:'
            print 'The clean option will delete all folders created by MCP, including the'
            print 'src folder which may contain changes you made to the code, along with any'
            print 'saved worlds from the client or server.'
            print 'Minecrift downloaded dependencies will also be removed and re-downloaded.'
            print 'Patches will be left alone however.'
            answer = raw_input('If you really want to clean up, enter "Yes" ')
            if answer.lower() not in ['yes']:
                print 'You have not entered "Yes", aborting the clean up process'
                sys.exit(1)        
        print 'Cleaning mcp dir...'
        reallyrmtree(mcp_dir)
        print 'Cleaning lib dir...'
        reallyrmtree(os.path.join(base_dir,'lib'))
        print 'Cleaning patchsrc dir...'
        reallyrmtree(os.path.join(base_dir,'patchsrc'))
        print 'Removing idea project files...'
        removeIdeaProject(base_dir)

    print 'Installing mcp...'
    installAndPatchMcp(mcp_dir)

    print("\nDownloading dependencies...")
    if includeForge:
        download_deps( mcp_dir, True, True ) # Forge libs

    download_deps( mcp_dir, False, False ) # Vanilla libs
    if dependenciesOnly:
        sys.exit(1)

    if nomerge == False:
        print("Applying Optifine...")
        optifine = os.path.join(mcp_dir,"jars","libraries","optifine","OptiFine",of_json_name,"OptiFine-"+of_json_name+".jar" )
        minecraft_jar = os.path.join( mcp_dir,"jars","versions",mc_version,mc_version+".jar")
        print ' Merging\n  %s\n into\n  %s' % (optifine, minecraft_jar)
        zipmerge( minecraft_jar, optifine )
    else:
        print("Skipping Optifine merge!")
    
    print("Decompiling...")
    src_dir = os.path.join(mcp_dir, "src","minecraft")
    if os.path.exists( src_dir ):
        shutil.rmtree( src_dir, True )
    sys.path.append(mcp_dir)
    os.chdir(mcp_dir)
    from runtime.decompile import decompile

    # This *has* to sync with the default options used in <mcpdir>/runtime/decompile.py for
    # the currently used version of MCP
    
    decompile(conffile=None,      # -c
              force_jad=False,    # -j
              force_csv=False,    # -s
              no_recompile=False, # -r
              no_comments=False,  # -d
              no_reformat=False,  # -a
              no_renamer=False,   # -n
              no_patch=False,     # -p
              only_patch=False,   # -o
              keep_lvt=False,     # -l
              keep_generics=mcp_uses_generics, # -g, True for MCP 1.8.8+, False otherwise
              only_client=True,   # --client
              only_server=False,  # --server
              force_rg=False,     # --rg
              workdir=None,       # -w
              json=None,          # --json
              nocopy=True         # --nocopy
              )

    os.chdir( base_dir )

    # Create original decompile src dir
    org_src_dir = os.path.join(mcp_dir, "src",".minecraft_orig")
    if os.path.exists( org_src_dir ):
        shutil.rmtree( org_src_dir, True )
    shutil.copytree( src_dir, org_src_dir )

    if nocompilefixpatch == False:
        compile_error_patching_done = False
        
        # Patch stage 1: apply only the patches needed to correct the
        # optifine merge decompile errors
        mcp_patch_dir = os.path.join( base_dir, "mcppatches", "patches" )
        if os.path.exists( mcp_patch_dir ):
            print("Patching Optifine merge decompile errors...")
            applychanges( mcp_dir, patch_dir="mcppatches/patches", backup=False, copyOriginal=False, mergeInNew=False )
            compile_error_patching_done = True
        
        # Address problem files - copy over directly
        problem_file_dir = os.path.join( base_dir, "mcppatches", "problemfiles" )
        if os.path.exists( problem_file_dir ):
            print("Addressing problem files...")        
            xp_problem_file = os.path.join(problem_file_dir, "xp.java")
            shutil.copy( xp_problem_file, os.path.join( mcp_dir, "src", "minecraft", "net", "minecraft", "src", "xp.java" ) )
            chunkrenderdispatcher_problem_file = os.path.join(problem_file_dir, "ChunkRenderDispatcher.java")
            shutil.copy( chunkrenderdispatcher_problem_file, os.path.join( mcp_dir, "src", "minecraft", "net", "minecraft", "client", "renderer", "chunk", "ChunkRenderDispatcher.java" ) )
            compile_error_patching_done = True

        # Update the client md5
        if compile_error_patching_done == True:
            print("Updating client.md5...")
            os.chdir(mcp_dir)
            from runtime.updatemd5 import updatemd5
            updatemd5( None, True, True, False )
            os.chdir( base_dir )

            # Now re-create the .minecraft_orig with the new buildable state
            if os.path.exists( org_src_dir ):
                shutil.rmtree( org_src_dir, True )
                shutil.copytree( src_dir, org_src_dir )
                
    if nopatch == False:
        # Patch stage 2: Now apply our main Minecrift patches, only
        # changes needed for Minecrift functionality
        print("Applying full Minecrift patches...")
        applychanges( mcp_dir )
    else:
        print("Apply patches skipped!")

    # create idea project if it doesn't already exist
    if not os.path.exists(os.path.join(base_dir, '.idea')):
        print("Creating idea project...")
        createIdeaProject(base_dir, mc_version, os.path.basename(mcp_dir), is32bitPreferred())