JMCCC, 启动和下载Minecraft的强大开放源码库

分享于 

6分钟阅读

GitHub

 
An open-source library for launching Minecraft (included mclaunch-util-lib by Kronos666)
  • 源代码名称:JMCCC
  • 源代码网址:http://www.github.com/to2mbn/JMCCC
  • JMCCC源代码文档
  • JMCCC源代码下载
  • Git URL:
    git://www.github.com/to2mbn/JMCCC.git
    Git Clone代码到本地:
    git clone http://www.github.com/to2mbn/JMCCC
    Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/to2mbn/JMCCC
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
    
    JMCCC

    用于启动和下载Minecraft的强大的开源库。

    许可证

    JMCCC is licensed under the MIT license.

    功能

    启动所有版本的Minecraft可扩展认证支持Yggdrasil/Offline,并且可以扩展下载所有版本的Minecraft支持Forge/Liteloader支持Liteloader快照可定制的下载源异步任务系统支持bio nio可以在快速入门

    依赖性

    依赖描述
    org.to2mbn:jmccc Minecraft启动功能,
    org.to2mbn:jmccc-yggdrasil-authenticator Yggdrasil身份验证功能,
    org.to2mbn:jmccc-mcdownloader Minecraft下载功能,
    org.to2mbn:jmccc-mojang-api Mojang API客户端,

    快照存储库:

    <repository>
     <id>ossrh</id>
     <url>https://oss.sonatype.org/content/groups/public/</url>
     <snapshots>
     <enabled>true</enabled>
     </snapshots>
    </repository>

    启动Minecraft

    MinecraftDirectory dir =newMinecraftDirectory("/home/user/.minecraft");Launcher launcher =LauncherBuilder.buildDefault();
    launcher.launch(newLaunchOption("1.10", YggdrasilAuthenticator.password("<email>", "<password>"), dir));

    你可以替换YggdrasilAuthenticator.password("<email>","<password>")new OfflineAuthenticator("<username>") 如果要使用脱机身份验证。

    下载Minecraft

    MinecraftDirectory dir =newMinecraftDirectory("/home/user/.minecraft");MinecraftDownloader downloader =MinecraftDownloaderBuilder.buildDefault();
    downloader.downloadIncrementally(dir, "1.10", newCallbackAdapter<Version>() {
     @Overridepublicvoidfailed(Throwablee) {
     // when the task fails }
     @Overridepublicvoiddone(Versionresult) {
     // when the task finishes }
     @Overridepublicvoidcancelled() {
     // when the task cancels }
     @Overridepublic<R>DownloadCallback<R>taskStart(DownloadTask<R>task) {
     // when a new sub download task starts// return a DownloadCallback to listen the status of the taskreturnnewCallbackAdapter<R>() {
     @Overridepublicvoiddone(Rresult) {
     // when the sub download task finishes }
     @Overridepublicvoidfailed(Throwablee) {
     // when the sub download task fails }
     @Overridepublicvoidcancelled() {
     // when the sub download task cancels }
     @OverridepublicvoidupdateProgress(longdone, longtotal) {
     // when the progress of the sub download task has updated }
     @Overridepublicvoidretry(Throwablee, intcurrent, intmax) {
     // when the sub download task fails, and the downloader decides to retry the task// in this case, failed() won't be called }
     };
     }
    });

    如果不想监视整个任务,可以传递null回调,如果不想监视子任务,也可以在null中返回taskStart()

    不要忘记关闭下载器,当你不再使用它。

    downloader.shutdown();

    下载Forge/Liteloader

    MinecraftDirectory dir =newMinecraftDirectory("/home/user/.minecraft");ForgeDownloadProvider forgeProvider =newForgeDownloadProvider();LiteloaderDownloadProvider liteloaderProvider =newLiteloaderDownloadProvider();MinecraftDownloader downloader =MinecraftDownloaderBuilder.create()
     .providerChain(DownloadProviderChain.create()
     .addProvider(forgeProvider)
     .addProvider(liteloaderProvider))
     .build();
    downloader.downloadIncrementally(dir, "1.8-forge1.8-11.14.3.1514", newCallbackAdapter<Version>() {...});
    downloader.downloadIncrementally(dir, "1.7.10-LiteLoader1.7.10", newCallbackAdapter<Version>() {...});
    downloader.download(forgeProvider.forgeVersionList(), newCallbackAdapter<ForgeVersionList>() {...});
    downloader.download(liteloaderProvider.liteloaderVersionList(), newCallbackAdapter<LiteloaderVersionList>() {...});

    FML选项

    JMCCC不添加fml选项(例如-Dfml.ignoreInvalidMinecraftCertificates=true-Dfml.ignorePatchDiscrepancies=true 自动)到命令行,如果在启动forge时遇到问题,可能需要手动添加这些参数,这些参数已在类ExtraArgumentsTemplates中定义。

    option.extraJvmArguments().add(ExtraArgumentsTemplates.FML_IGNORE_INVALID_MINECRAFT_CERTIFICATES);
    option.extraJvmArguments().add(ExtraArgumentsTemplates.FML_IGNORE_PATCH_DISCREPANCISE);