Esempio n. 1
0
def bop_main(bop_dir, mcp_dir):
    sys.path.append(mcp_dir)
    from runtime.updatemd5 import updatemd5
    from bop import decompile, apply_initial_patches, apply_bop_patches, reset_logger, copytree

    print '=============================== Biomes O Plenty Setup Start ====================================='

    print '-=Decompiling=-'
    decompile(mcp_dir, bop_dir)
    print ' '
    print '-=Applying patches=-'
    apply_initial_patches(mcp_dir, bop_dir, os.path.join(mcp_dir, 'src'), True)
    os.chdir(mcp_dir)
    reset_logger()
    print ''
    print '-=Update MD5=-'
    updatemd5(None, True, False, False)
    reset_logger()
    print ''
    print '-=Copy Src=-'
    copytree(os.path.join(mcp_dir, 'src'), os.path.join(mcp_dir, 'src_base'))
    os.chdir(bop_dir)
    print ''
    print '-=Apply BoP Patches=-'
    apply_bop_patches(mcp_dir, bop_dir, os.path.join(mcp_dir, 'src'), True)
    shutil.rmtree(os.path.join(mcp_dir, 'eclipse'))
    copytree(os.path.join(bop_dir, 'tmpworkspace'),
             os.path.join(mcp_dir, 'eclipse'))
    print '=============================== Biomes O Plenty Setup Finished ================================='
Esempio n. 2
0
def soulforge_main(soulforge_dir, mcp_dir):
    sys.path.append(mcp_dir)
    from runtime.updatemd5 import updatemd5
    from soulforge import decompile, apply_initial_patches, apply_soulforge_patches, reset_logger, copytree
    
    print '=============================== Soulforge Setup Start ====================================='

    print 'Decompiling'
    decompile(mcp_dir, soulforge_dir)
    print 'Applying patches'
    apply_initial_patches(mcp_dir, soulforge_dir, os.path.join(mcp_dir, 'src'), True)
    os.chdir(mcp_dir)
    reset_logger()
    updatemd5(None, True, False, False)
    reset_logger()
    copytree(os.path.join(mcp_dir, 'src'), os.path.join(mcp_dir, 'src_base')) 
    os.chdir(soulforge_dir) 
    apply_soulforge_patches(mcp_dir, soulforge_dir, os.path.join(mcp_dir, 'src'), True)
    print 'Copy external libraries'
    copytree(os.path.join(soulforge_dir, 'lib'), os.path.join(mcp_dir, 'lib'))
    print 'Setup workspace'
    if os.path.isdir(os.path.join(mcp_dir, 'eclipse')):
        shutil.rmtree(os.path.join(mcp_dir, 'eclipse'))
    copytree(os.path.join(soulforge_dir, 'soulforgedev', 'tmpworkspace'), os.path.join(mcp_dir, 'eclipse')) 
    print '=============================== Soulforge Setup Finished ================================='
Esempio n. 3
0
def soulforge_main(soulforge_dir, mcp_dir):
    sys.path.append(mcp_dir)
    from runtime.updatemd5 import updatemd5
    from soulforge import decompile, apply_initial_patches, apply_soulforge_patches, reset_logger, copytree

    print '=============================== Soulforge Setup Start ====================================='

    print 'Decompiling'
    decompile(mcp_dir, soulforge_dir)
    print 'Applying patches'
    apply_initial_patches(mcp_dir, soulforge_dir, os.path.join(mcp_dir, 'src'),
                          True)
    os.chdir(mcp_dir)
    reset_logger()
    updatemd5(None, True, False, False)
    reset_logger()
    copytree(os.path.join(mcp_dir, 'src'), os.path.join(mcp_dir, 'src_base'))
    os.chdir(soulforge_dir)
    apply_soulforge_patches(mcp_dir, soulforge_dir,
                            os.path.join(mcp_dir, 'src'), True)
    print 'Copy external libraries'
    copytree(os.path.join(soulforge_dir, 'lib'), os.path.join(mcp_dir, 'lib'))
    print 'Setup workspace'
    if os.path.isdir(os.path.join(mcp_dir, 'eclipse')):
        shutil.rmtree(os.path.join(mcp_dir, 'eclipse'))
    copytree(os.path.join(soulforge_dir, 'soulforgedev', 'tmpworkspace'),
             os.path.join(mcp_dir, 'eclipse'))
    print '=============================== Soulforge Setup Finished ================================='
Esempio n. 4
0
def bop_main(bop_dir, mcp_dir):
    sys.path.append(mcp_dir)
    from runtime.updatemd5 import updatemd5
    from bop import decompile, apply_initial_patches, apply_bop_patches, reset_logger, copytree
    
    print '=============================== Biomes O Plenty Setup Start ====================================='

    print '-=Decompiling=-'
    decompile(mcp_dir, bop_dir)
    print ' '
    print '-=Applying patches=-'
    apply_initial_patches(mcp_dir, bop_dir, os.path.join(mcp_dir, 'src'), True)
    os.chdir(mcp_dir)
    reset_logger()
    print ''
    print '-=Update MD5=-'
    updatemd5(None, True, False, False)
    reset_logger()
    print ''
    print '-=Copy Src=-'
    copytree(os.path.join(mcp_dir, 'src'), os.path.join(mcp_dir, 'src_base')) 
    os.chdir(bop_dir)
    print ''
    print '-=Apply BoP Patches=-'
    apply_bop_patches(mcp_dir, bop_dir, os.path.join(mcp_dir, 'src'), True)  
    shutil.rmtree(os.path.join(mcp_dir, 'eclipse'))
    copytree(os.path.join(bop_dir, 'tmpworkspace'), os.path.join(mcp_dir, 'eclipse')) 
    print '=============================== Biomes O Plenty Setup Finished ================================='
Esempio n. 5
0
def main(mcp_dir):
    src_dir = os.path.join(mcp_dir, 'src')

    print '================ Forge ModLoader Setup Start ==================='
    setup_mcp(fml_dir, mcp_dir, True)
    setup_fml(fml_dir, mcp_dir)
    apply_fml_patches(fml_dir, mcp_dir, os.path.join(mcp_dir, 'src'))
    finish_setup_fml(fml_dir, mcp_dir)
    print '================  Forge ModLoader Setup End  ==================='

    sys.path.append(mcp_dir)
    from runtime.updatenames import updatenames
    from runtime.updatemd5 import updatemd5

    print '=============================== Minecraft Forge Setup Start ====================================='
    print 'Applying forge patches'
    apply_forge_patches(os.path.join(forge_dir, 'fml'), mcp_dir, forge_dir,
                        src_dir, True)
    os.chdir(mcp_dir)
    updatenames(None, True, True, False)
    reset_logger()
    updatemd5(None, True, True, False)
    reset_logger()
    os.chdir(forge_dir)
    print '=============================== Minecraft Forge Setup Finished ================================='
Esempio n. 6
0
def soulforge_main(soulforge_dir, mcp_dir):
    sys.path.append(mcp_dir)
    from runtime.updatemd5 import updatemd5
    from runtime.reobfuscate import reobfuscate
    from soulforge import (
        decompile,
        apply_initial_patches,
        apply_soulforge_patches,
        recompile,
        unzipbtw,
        copyinitialreobfuscatedfiles,
        rezipbtw,
        apply_mod_patches,
        reset_logger,
        copytree,
    )

    print "=============================== Soulforge Setup Start ====================================="

    print "Decompiling"
    decompile(mcp_dir, soulforge_dir)
    print "Applying patches"
    apply_initial_patches(mcp_dir, soulforge_dir, os.path.join(mcp_dir, "src"), True)
    os.chdir(mcp_dir)
    updatemd5(None, True, False, False)
    reset_logger()
    os.chdir(soulforge_dir)
    apply_soulforge_patches(mcp_dir, soulforge_dir, os.path.join(mcp_dir, "src"), True)
    copytree(os.path.join(soulforge_dir, "src", "minecraft"), os.path.join(mcp_dir, "src", "minecraft"))
    copytree(os.path.join(soulforge_dir, "src", "common"), os.path.join(mcp_dir, "src", "minecraft"))
    copytree(os.path.join(soulforge_dir, "src", "minecraft_server"), os.path.join(mcp_dir, "src", "minecraft_server"))
    copytree(os.path.join(soulforge_dir, "src", "common"), os.path.join(mcp_dir, "src", "minecraft_server"))
    print "Copy external libraries"
    copytree(os.path.join(soulforge_dir, "lib"), os.path.join(mcp_dir, "lib"))
    os.chdir(mcp_dir)
    print "Recompiling"
    recompile(None, False, False)
    reset_logger()
    print "Reobfuscating"
    reobfuscate(None, False, False, False, False, False, False)
    reset_logger()
    print "Unzipping BTW"
    unzipbtw(soulforge_dir)
    print "Copying Reobfuscated Files"
    copyinitialreobfuscatedfiles(soulforge_dir, mcp_dir)
    print "Rezipping Files"
    rezipbtw(soulforge_dir)
    updatemd5(None, True, False, False)
    reset_logger()
    os.chdir(soulforge_dir)
    copytree(os.path.join(mcp_dir, "src"), os.path.join(mcp_dir, "src_base"))
    apply_mod_patches(mcp_dir, soulforge_dir, os.path.join(mcp_dir, "src"), True)
    print "Setup workspace"
    if os.path.isdir(os.path.join(mcp_dir, "eclipse")):
        shutil.rmtree(os.path.join(mcp_dir, "eclipse"))
    copytree(os.path.join(soulforge_dir, "addondev", "tmpworkspace"), os.path.join(mcp_dir, "eclipse"))
    print "=============================== Soulforge Setup Finished ================================="
Esempio n. 7
0
def soulforge_main(soulforge_dir, mcp_dir):
    sys.path.append(mcp_dir)
    from runtime.updatemd5 import updatemd5
    from runtime.reobfuscate import reobfuscate
    from soulforge import decompile, apply_initial_patches, apply_soulforge_patches, recompile, unzipbtw, copyinitialreobfuscatedfiles, rezipbtw, apply_mod_patches, reset_logger, copytree

    print '=============================== Soulforge Setup Start ====================================='

    print 'Decompiling'
    decompile(mcp_dir, soulforge_dir)
    print 'Applying patches'
    apply_initial_patches(mcp_dir, soulforge_dir, os.path.join(mcp_dir, 'src'),
                          True)
    os.chdir(mcp_dir)
    updatemd5(None, True, False, False)
    reset_logger()
    os.chdir(soulforge_dir)
    apply_soulforge_patches(mcp_dir, soulforge_dir,
                            os.path.join(mcp_dir, 'src'), True)
    copytree(os.path.join(soulforge_dir, 'src', 'minecraft'),
             os.path.join(mcp_dir, 'src', 'minecraft'))
    copytree(os.path.join(soulforge_dir, 'src', 'common'),
             os.path.join(mcp_dir, 'src', 'minecraft'))
    copytree(os.path.join(soulforge_dir, 'src', 'minecraft_server'),
             os.path.join(mcp_dir, 'src', 'minecraft_server'))
    copytree(os.path.join(soulforge_dir, 'src', 'common'),
             os.path.join(mcp_dir, 'src', 'minecraft_server'))
    print 'Copy external libraries'
    copytree(os.path.join(soulforge_dir, 'lib'), os.path.join(mcp_dir, 'lib'))
    os.chdir(mcp_dir)
    print 'Recompiling'
    recompile(None, False, False)
    reset_logger()
    print 'Reobfuscating'
    reobfuscate(None, False, False, False, False, False, False)
    reset_logger()
    print 'Unzipping BTW'
    unzipbtw(soulforge_dir)
    print 'Copying Reobfuscated Files'
    copyinitialreobfuscatedfiles(soulforge_dir, mcp_dir)
    print 'Rezipping Files'
    rezipbtw(soulforge_dir)
    updatemd5(None, True, False, False)
    reset_logger()
    os.chdir(soulforge_dir)
    copytree(os.path.join(mcp_dir, 'src'), os.path.join(mcp_dir, 'src_base'))
    apply_mod_patches(mcp_dir, soulforge_dir, os.path.join(mcp_dir, 'src'),
                      True)
    print 'Setup workspace'
    if os.path.isdir(os.path.join(mcp_dir, 'eclipse')):
        shutil.rmtree(os.path.join(mcp_dir, 'eclipse'))
    copytree(os.path.join(soulforge_dir, 'addondev', 'tmpworkspace'),
             os.path.join(mcp_dir, 'eclipse'))
    print '=============================== Soulforge Setup Finished ================================='
Esempio n. 8
0
File: fml.py Progetto: Beliaar/FML
def finish_setup_fml(fml_dir, mcp_dir):
    sys.path.append(mcp_dir)
    from runtime.updatenames import updatenames
    from runtime.updatemd5 import updatemd5
    from runtime.updatemcp import updatemcp
    
    os.chdir(mcp_dir)
    updatenames(None, True)
    reset_logger()
    updatemd5(None, True)
    reset_logger()
    os.chdir(fml_dir)
Esempio n. 9
0
File: fml.py Progetto: Samu50/FML
def finish_setup_fml(fml_dir, mcp_dir, enable_server=False, disable_client=False):
    sys.path.append(mcp_dir)
    from runtime.updatenames import updatenames
    from runtime.updatemd5 import updatemd5
    from runtime.updatemcp import updatemcp
    
    os.chdir(mcp_dir)
    updatenames(None, True, not disable_client, enable_server)
    reset_logger()
    updatemd5(None, True, not disable_client, enable_server)
    reset_logger()
    os.chdir(fml_dir)
Esempio n. 10
0
def finish_setup_fml(fml_dir, mcp_dir):
    sys.path.append(mcp_dir)
    from runtime.updatenames import updatenames
    from runtime.updatemd5 import updatemd5
    from runtime.updatemcp import updatemcp

    os.chdir(mcp_dir)
    updatenames(None, True, False, False)
    reset_logger()
    updatemd5(None, True, False, False)
    reset_logger()
    os.chdir(fml_dir)
Esempio n. 11
0
def finish_setup_fml(fml_dir, mcp_dir, enable_server=False, disable_client=False, disable_rename=False):
    sys.path.append(mcp_dir)
    from runtime.updatenames import updatenames
    from runtime.updatemd5 import updatemd5
    from runtime.updatemcp import updatemcp
    
    os.chdir(mcp_dir)
    if not disable_rename:
        updatenames(None, True, not disable_client, enable_server)
        reset_logger()
    updatemd5(None, True, not disable_client, enable_server)
    reset_logger()
    os.chdir(fml_dir)
Esempio n. 12
0
def forge_main(forge_dir, fml_dir, mcp_dir):
    sys.path.append(mcp_dir)
    sys.path.append(fml_dir)
    from runtime.updatenames import updatenames
    from runtime.updatemd5 import updatemd5
    from forge import apply_forge_patches
    from fml import reset_logger
    
    print '=============================== Minecraft Forge Setup Start ====================================='
    print 'Applying forge patches'
    apply_forge_patches(fml_dir, mcp_dir, forge_dir, os.path.join(mcp_dir, 'src'), True)
    os.chdir(mcp_dir)
    updatenames(None, True, True, False)
    reset_logger()
    updatemd5(None, True, True, False)
    reset_logger()
    os.chdir(forge_dir)    
    print '=============================== Minecraft Forge Setup Finished ================================='
Esempio n. 13
0
def main():

    print '================ Forge ModLoader Setup Start ==================='
    setup_mcp(fml_dir, mcp_dir, True)
    setup_fml(fml_dir, mcp_dir)
    apply_fml_patches(fml_dir, mcp_dir, os.path.join(mcp_dir, 'src'))
    finish_setup_fml(fml_dir, mcp_dir)
    print '================  Forge ModLoader Setup End  ==================='

    sys.path.append(mcp_dir)    
    from runtime.updatenames import updatenames
    from runtime.updatemd5 import updatemd5
    
    print '=============================== Minecraft Forge Setup Start ====================================='
    print 'Applying forge patches'
    apply_forge_patches(os.path.join(forge_dir, 'fml'), mcp_dir, forge_dir, src_dir, True)
    os.chdir(mcp_dir)
    updatenames(None, True, True, False)
    reset_logger()
    updatemd5(None, True, True, False)
    reset_logger()
    os.chdir(forge_dir)    
    print '=============================== Minecraft Forge Setup Finished ================================='
Esempio n. 14
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())
Esempio n. 15
0
        except SystemExit, e:
            print 'Decompile Exception: %d ' % e.code
            raise e   

    if not os.path.isdir(src_dir):
        print 'Something went wrong, src folder not found at: %s' % src_dir
        sys.exit(1)
        
    cleanup_source(src_dir)
    
    setup_fml()
    
    os.chdir(mcp_dir)
    updatenames(None, True)
    reset_logger()
    updatemd5(None, True)
    reset_logger()
    os.chdir(forge_dir)
    
    base_dir = os.path.join(mcp_dir, 'src_base')
    work_dir = os.path.join(mcp_dir, 'src_work')
    
    if os.path.isdir(base_dir):
        shutil.rmtree(base_dir)
    if os.path.isdir(work_dir):
        shutil.rmtree(work_dir)
        
    print 'Setting up source directories'    
    shutil.copytree(src_dir, base_dir)
    shutil.copytree(src_dir, work_dir)
    
Esempio n. 16
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 'Installing mcp...'
        installAndPatchMcp(mcp_dir)

    print("\nDownloading dependencies...")
    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
    #         Conf  JAD    CSV    -r     -d     -a     -n     -p     -o     -l     -g     -c    -s     --rg   -w    json  --nocopy
    decompile(None, False, False, False, False, False, False, False, False,
              False, False, True, False, False, None, None, True)

    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!")
Esempio n. 17
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())
Esempio n. 18
0
    if has_client:
        if os.path.isdir(os.path.join(forge_dir, 'patches', 'minecraft')):
            apply_patches(os.path.join(forge_dir, 'patches', 'minecraft'),
                          src_dir)
        if os.path.isdir(os.path.join(forge_dir, 'src', 'minecraft')):
            copytree(os.path.join(forge_dir, 'src', 'minecraft'),
                     os.path.join(src_dir, 'minecraft'))
    if has_server:
        if os.path.isdir(os.path.join(forge_dir, 'patches',
                                      'minecraft_server')):
            apply_patches(
                os.path.join(forge_dir, 'patches', 'minecraft_server'),
                src_dir)
        if os.path.isdir(os.path.join(forge_dir, 'src', 'minecraft_server')):
            copytree(os.path.join(forge_dir, 'src', 'minecraft_server'),
                     os.path.join(src_dir, 'minecraft_server'))

    os.chdir(mcp_dir)
    updatemcp(None, True)
    reset_logger()
    updatenames(None, True)
    reset_logger()
    updatemd5(None, True)
    reset_logger()
    os.chdir(forge_dir)

    print '=================================== Minecraft Forge Setup Finished ================================='


if __name__ == '__main__':
    main()
Esempio n. 19
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 'Installing mcp...'
        installAndPatchMcp(mcp_dir)


    print("\nDownloading dependencies...")
    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
    #         Conf  JAD    CSV    -r     -d     -a     -n     -p     -o     -l     -g     -c    -s     --rg   -w    json  --nocopy
    decompile(None, False, False, False, False, False, False, False, False, False, False, True, False, False, None, None, True  )

    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!")