Jump to content

Minecraft Mod Installer


JRSmile
 Share

Recommended Posts

Hey there, im planning to build a installer for minecraft mods, the unzip and installation progess works fine so far, but the download of adf.ly mods is not fully implemented yet.

attached you find a rough copy of the functions i have developed for this reason.

(you will need the 7zip udf)

Regards,

JR.

#AutoIt3Wrapper_Change2CUI=y
#include "7Zip.au3"
#include <ie.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Crypt.au3>
#region debugging
FileCopy("minecraft-org.jar","minecraft.jar",1)
#endregion
ConsoleWrite(detect_version(@ScriptDir & "\minecraft.jar") & @CRLF)
Global $7zip = _7ZipStartup()
_MCModRemoveMETA_INF()
_MCModAdd("ModLoader_1_2_5.zip")
_MCModAdd("AudioMod_1_2_5.zip")
_MCModAdd("MinecraftForge-3.1.3.105-Client.zip")
_MCModAdd("4096-Fix-v4.2-mc1.2.5.zip")
_MCModAdd("CodeChickenCore-Client 0.5.2.zip")
_MCModAdd("NotEnoughItems-Client 1.2.2.zip")
_MCModAdd("Sparrow110 Client.zip")
_7ZipShutdown($7zip)
Func _MCModAdd($modfile)
ConsoleWrite("installing: " & $modfile & @CRLF)
Local $dst = "." & "\" & StringReplace($modfile, ".", "_")
_7ZipExtractEx($7zip, 0, $modfile, $dst, 0, 0, 1, 0, 0, 0, 0, 0, 1)
If Not @error Then
  $sFile2add = $dst & "\*"
  _7ZipAdd($7zip, 0, "minecraft.jar", $sFile2add, 0, 5, 1, 0, 0, 0, 0, 0, 0)
EndIf
DirRemove($dst, 1)
EndFunc   ;==>_MCModAdd
Func _MCModRemoveMETA_INF()
ConsoleWrite("removing META-INF folder..." & @CRLF)
$delete = _7ZipDelete($7zip, 0, "minecraft.jar", "META-INF", 1)
EndFunc   ;==>_MCModRemoveMETA_INF
Func detect_version($file)
Switch md5($file)
  case "0x8E8778078A175A33603A585257F28563"
   Return "+unmodded 1.2.5"
  case Else
   SetError(1)
   Return "!unknown hash: [" & md5($file) & "] can't determine version, already modded?"
EndSwitch
EndFunc
Func md5($file)
_Crypt_Startup()
Return _Crypt_HashFile($file, $CALG_MD5)
_Crypt_Shutdown()
EndFunc   ;==>md5

#cs
_IEErrorHandlerRegister()
$file = FileOpen("modlinks.txt", 0)
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
While 1
$line = FileReadLine($file)
If @error = -1 Then ExitLoop
$tmp = StringSplit($line, ";")
Do
$result = _MCModDownloadMod($tmp[1], $tmp[2])
Until $result = True
Sleep(1000)
WEnd
FileClose($file)
#ce
Func _MCModDownloadMod($adflyLink, $ModName)
Local $oIE = _IECreateEmbedded()
Local $Window = GUICreate("Downloading Mods... [" & $ModName & "]", 640, 80, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
Local $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 640, 125)
GUISetState($Window) ;Show GUI
_IENavigate($oIE, $adflyLink)
$timeout = TimerInit()
Do
  $done = False
  $html_raw = _IEBodyReadHTML($oIE)
  $html_array = StringSplit($html_raw, '"')
  For $i = 1 To $html_array[0]
   If StringInStr($html_array[$i], "http://adf.ly/go/") Then
    ConsoleWrite($html_array[$i] & @CRLF)
    InetGet($html_array[$i], $ModName & ".zip")
    $done = True
   EndIf
  Next
  Sleep(1)
Until $done Or TimerDiff($timeout) >= 10000
GUIDelete($Window)
If Not $done Then
  SetError(1)
  Return False
Else
  Return True
EndIf
EndFunc   ;==>_MCModDownloadMod
$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...