feat: Legacy Fabric 自动安装 (#5090)

This commit is contained in:
辞庐
2026-01-19 20:35:56 +08:00
committed by GitHub
parent e8c6c07e6a
commit 8077b0bae1
32 changed files with 657 additions and 181 deletions

View File

@@ -321,6 +321,8 @@ public final class HMCLGameRepository extends DefaultGameRepository {
return VersionIconType.FABRIC.getIcon(); return VersionIconType.FABRIC.getIcon();
else if (libraryAnalyzer.has(LibraryAnalyzer.LibraryType.QUILT)) else if (libraryAnalyzer.has(LibraryAnalyzer.LibraryType.QUILT))
return VersionIconType.QUILT.getIcon(); return VersionIconType.QUILT.getIcon();
else if (libraryAnalyzer.has(LibraryAnalyzer.LibraryType.LEGACY_FABRIC))
return VersionIconType.LEGACY_FABRIC.getIcon();
else if (libraryAnalyzer.has(LibraryAnalyzer.LibraryType.NEO_FORGE)) else if (libraryAnalyzer.has(LibraryAnalyzer.LibraryType.NEO_FORGE))
return VersionIconType.NEO_FORGE.getIcon(); return VersionIconType.NEO_FORGE.getIcon();
else if (libraryAnalyzer.has(LibraryAnalyzer.LibraryType.FORGE)) else if (libraryAnalyzer.has(LibraryAnalyzer.LibraryType.FORGE))

View File

@@ -36,7 +36,9 @@ public enum VersionIconType {
FURNACE("/assets/img/furnace.png"), FURNACE("/assets/img/furnace.png"),
QUILT("/assets/img/quilt.png"), QUILT("/assets/img/quilt.png"),
APRIL_FOOLS("/assets/img/april_fools.png"), APRIL_FOOLS("/assets/img/april_fools.png"),
CLEANROOM("/assets/img/cleanroom.png"); CLEANROOM("/assets/img/cleanroom.png"),
LEGACY_FABRIC("/assets/img/legacyfabric.png")
;
// Please append new items at last // Please append new items at last

View File

@@ -92,37 +92,18 @@ public class InstallerItem extends Control {
this.id = id; this.id = id;
this.style = style; this.style = style;
switch (id) { iconType = switch (id) {
case "game": case "game" -> VersionIconType.GRASS;
iconType = VersionIconType.GRASS; case "fabric", "fabric-api" -> VersionIconType.FABRIC;
break; case "legacyfabric", "legacyfabric-api" -> VersionIconType.LEGACY_FABRIC;
case "fabric": case "forge" -> VersionIconType.FORGE;
case "fabric-api": case "cleanroom" -> VersionIconType.CLEANROOM;
iconType = VersionIconType.FABRIC; case "liteloader" -> VersionIconType.CHICKEN;
break; case "optifine" -> VersionIconType.OPTIFINE;
case "forge": case "quilt", "quilt-api" -> VersionIconType.QUILT;
iconType = VersionIconType.FORGE; case "neoforge" -> VersionIconType.NEO_FORGE;
break; default -> null;
case "cleanroom": };
iconType = VersionIconType.CLEANROOM;
break;
case "liteloader":
iconType = VersionIconType.CHICKEN;
break;
case "optifine":
iconType = VersionIconType.OPTIFINE;
break;
case "quilt":
case "quilt-api":
iconType = VersionIconType.QUILT;
break;
case "neoforge":
iconType = VersionIconType.NEO_FORGE;
break;
default:
iconType = null;
break;
}
} }
public String getLibraryId() { public String getLibraryId() {
@@ -201,6 +182,8 @@ public class InstallerItem extends Control {
InstallerItem fabricApi = new InstallerItem(FABRIC_API, style); InstallerItem fabricApi = new InstallerItem(FABRIC_API, style);
InstallerItem forge = new InstallerItem(FORGE, style); InstallerItem forge = new InstallerItem(FORGE, style);
InstallerItem cleanroom = new InstallerItem(CLEANROOM, style); InstallerItem cleanroom = new InstallerItem(CLEANROOM, style);
InstallerItem legacyfabric = new InstallerItem(LEGACY_FABRIC, style);
InstallerItem legacyfabricApi = new InstallerItem(LEGACY_FABRIC_API, style);
InstallerItem neoForge = new InstallerItem(NEO_FORGE, style); InstallerItem neoForge = new InstallerItem(NEO_FORGE, style);
InstallerItem liteLoader = new InstallerItem(LITELOADER, style); InstallerItem liteLoader = new InstallerItem(LITELOADER, style);
InstallerItem optiFine = new InstallerItem(OPTIFINE, style); InstallerItem optiFine = new InstallerItem(OPTIFINE, style);
@@ -208,11 +191,11 @@ public class InstallerItem extends Control {
InstallerItem quiltApi = new InstallerItem(QUILT_API, style); InstallerItem quiltApi = new InstallerItem(QUILT_API, style);
Map<InstallerItem, Set<InstallerItem>> incompatibleMap = new HashMap<>(); Map<InstallerItem, Set<InstallerItem>> incompatibleMap = new HashMap<>();
mutualIncompatible(incompatibleMap, forge, fabric, quilt, neoForge, cleanroom); mutualIncompatible(incompatibleMap, forge, fabric, quilt, neoForge, cleanroom, legacyfabric);
addIncompatibles(incompatibleMap, liteLoader, fabric, quilt, neoForge, cleanroom); addIncompatibles(incompatibleMap, liteLoader, fabric, quilt, neoForge, cleanroom, legacyfabric);
addIncompatibles(incompatibleMap, optiFine, fabric, quilt, neoForge, cleanroom); addIncompatibles(incompatibleMap, optiFine, fabric, quilt, neoForge, cleanroom, liteLoader, legacyfabric);
addIncompatibles(incompatibleMap, fabricApi, forge, quiltApi, neoForge, liteLoader, optiFine, cleanroom); addIncompatibles(incompatibleMap, fabricApi, forge, quiltApi, neoForge, liteLoader, optiFine, cleanroom, legacyfabricApi, legacyfabricApi);
addIncompatibles(incompatibleMap, quiltApi, forge, fabric, fabricApi, neoForge, liteLoader, optiFine, cleanroom); addIncompatibles(incompatibleMap, quiltApi, forge, fabric, fabricApi, neoForge, liteLoader, optiFine, cleanroom, legacyfabric, legacyfabricApi);
for (Map.Entry<InstallerItem, Set<InstallerItem>> entry : incompatibleMap.entrySet()) { for (Map.Entry<InstallerItem, Set<InstallerItem>> entry : incompatibleMap.entrySet()) {
InstallerItem item = entry.getKey(); InstallerItem item = entry.getKey();
@@ -246,7 +229,7 @@ public class InstallerItem extends Control {
game.versionProperty.set(new InstalledState(gameVersion, false, false)); game.versionProperty.set(new InstalledState(gameVersion, false, false));
} }
InstallerItem[] all = {game, forge, neoForge, liteLoader, optiFine, fabric, fabricApi, quilt, quiltApi, cleanroom}; InstallerItem[] all = {game, forge, neoForge, liteLoader, optiFine, fabric, fabricApi, quilt, quiltApi, legacyfabric, legacyfabricApi, cleanroom};
for (InstallerItem item : all) { for (InstallerItem item : all) {
if (!item.resolvedStateProperty.isBound()) { if (!item.resolvedStateProperty.isBound()) {
@@ -263,9 +246,9 @@ public class InstallerItem extends Control {
if (gameVersion == null) { if (gameVersion == null) {
this.libraries = all; this.libraries = all;
} else if (gameVersion.equals("1.12.2")) { } else if (gameVersion.equals("1.12.2")) {
this.libraries = new InstallerItem[]{game, forge, cleanroom, liteLoader, optiFine}; this.libraries = new InstallerItem[]{game, forge, cleanroom, liteLoader, legacyfabric, legacyfabricApi, optiFine};
} else if (GameVersionNumber.compare(gameVersion, "1.13") < 0) { } else if (GameVersionNumber.compare(gameVersion, "1.13.2") <= 0) {
this.libraries = new InstallerItem[]{game, forge, liteLoader, optiFine}; this.libraries = new InstallerItem[]{game, forge, liteLoader, optiFine, legacyfabric, legacyfabricApi};
} else { } else {
this.libraries = new InstallerItem[]{game, forge, neoForge, optiFine, fabric, fabricApi, quilt, quiltApi}; this.libraries = new InstallerItem[]{game, forge, neoForge, optiFine, fabric, fabricApi, quilt, quiltApi};
} }

View File

@@ -41,6 +41,7 @@ import org.jackhuang.hmcl.download.forge.ForgeOldInstallTask;
import org.jackhuang.hmcl.download.game.GameAssetDownloadTask; import org.jackhuang.hmcl.download.game.GameAssetDownloadTask;
import org.jackhuang.hmcl.download.game.GameInstallTask; import org.jackhuang.hmcl.download.game.GameInstallTask;
import org.jackhuang.hmcl.download.java.mojang.MojangJavaDownloadTask; import org.jackhuang.hmcl.download.java.mojang.MojangJavaDownloadTask;
import org.jackhuang.hmcl.download.legacyfabric.LegacyFabricInstallTask;
import org.jackhuang.hmcl.download.liteloader.LiteLoaderInstallTask; import org.jackhuang.hmcl.download.liteloader.LiteLoaderInstallTask;
import org.jackhuang.hmcl.download.neoforge.NeoForgeInstallTask; import org.jackhuang.hmcl.download.neoforge.NeoForgeInstallTask;
import org.jackhuang.hmcl.download.neoforge.NeoForgeOldInstallTask; import org.jackhuang.hmcl.download.neoforge.NeoForgeOldInstallTask;
@@ -164,6 +165,8 @@ public final class TaskListPane extends StackPane {
task.setName(i18n("install.installer.install", i18n("install.installer.game"))); task.setName(i18n("install.installer.install", i18n("install.installer.game")));
} else if (task instanceof CleanroomInstallTask) { } else if (task instanceof CleanroomInstallTask) {
task.setName(i18n("install.installer.install", i18n("install.installer.cleanroom"))); task.setName(i18n("install.installer.install", i18n("install.installer.cleanroom")));
} else if (task instanceof LegacyFabricInstallTask) {
task.setName(i18n("install.installer.install", i18n("install.installer.legacyfabric")));
} else if (task instanceof ForgeNewInstallTask || task instanceof ForgeOldInstallTask) { } else if (task instanceof ForgeNewInstallTask || task instanceof ForgeOldInstallTask) {
task.setName(i18n("install.installer.install", i18n("install.installer.forge"))); task.setName(i18n("install.installer.install", i18n("install.installer.forge")));
} else if (task instanceof NeoForgeInstallTask || task instanceof NeoForgeOldInstallTask) { } else if (task instanceof NeoForgeInstallTask || task instanceof NeoForgeOldInstallTask) {
@@ -427,23 +430,25 @@ public final class TaskListPane extends StackPane {
// CHECKSTYLE:OFF // CHECKSTYLE:OFF
// @formatter:off // @formatter:off
switch (stageKey) { message = switch (stageKey) {
case "hmcl.modpack": message = i18n("install.modpack"); break; case "hmcl.modpack" -> i18n("install.modpack");
case "hmcl.modpack.download": message = i18n("launch.state.modpack"); break; case "hmcl.modpack.download" -> i18n("launch.state.modpack");
case "hmcl.install.assets": message = i18n("assets.download"); break; case "hmcl.install.assets" -> i18n("assets.download");
case "hmcl.install.libraries": message = i18n("libraries.download"); break; case "hmcl.install.libraries" -> i18n("libraries.download");
case "hmcl.install.game": message = i18n("install.installer.install", i18n("install.installer.game") + " " + stageValue); break; case "hmcl.install.game" -> i18n("install.installer.install", i18n("install.installer.game") + " " + stageValue);
case "hmcl.install.forge": message = i18n("install.installer.install", i18n("install.installer.forge") + " " + stageValue); break; case "hmcl.install.forge" -> i18n("install.installer.install", i18n("install.installer.forge") + " " + stageValue);
case "hmcl.install.cleanroom": message = i18n("install.installer.install", i18n("install.installer.cleanroom") + " " + stageValue); break; case "hmcl.install.cleanroom" -> i18n("install.installer.install", i18n("install.installer.cleanroom") + " " + stageValue);
case "hmcl.install.neoforge": message = i18n("install.installer.install", i18n("install.installer.neoforge") + " " + stageValue); break; case "hmcl.install.neoforge" -> i18n("install.installer.install", i18n("install.installer.neoforge") + " " + stageValue);
case "hmcl.install.liteloader": message = i18n("install.installer.install", i18n("install.installer.liteloader") + " " + stageValue); break; case "hmcl.install.liteloader" -> i18n("install.installer.install", i18n("install.installer.liteloader") + " " + stageValue);
case "hmcl.install.optifine": message = i18n("install.installer.install", i18n("install.installer.optifine") + " " + stageValue); break; case "hmcl.install.optifine" -> i18n("install.installer.install", i18n("install.installer.optifine") + " " + stageValue);
case "hmcl.install.fabric": message = i18n("install.installer.install", i18n("install.installer.fabric") + " " + stageValue); break; case "hmcl.install.fabric" -> i18n("install.installer.install", i18n("install.installer.fabric") + " " + stageValue);
case "hmcl.install.fabric-api": message = i18n("install.installer.install", i18n("install.installer.fabric-api") + " " + stageValue); break; case "hmcl.install.fabric-api" -> i18n("install.installer.install", i18n("install.installer.fabric-api") + " " + stageValue);
case "hmcl.install.quilt": message = i18n("install.installer.install", i18n("install.installer.quilt") + " " + stageValue); break; case "hmcl.install.legacyfabric" -> i18n("install.installer.install", i18n("install.installer.legacyfabric") + " " + stageValue);
case "hmcl.install.quilt-api": message = i18n("install.installer.install", i18n("install.installer.quilt-api") + " " + stageValue); break; case "hmcl.install.legacyfabric-api" -> i18n("install.installer.install", i18n("install.installer.legacyfabric-api") + " " + stageValue);
default: message = i18n(stageKey); break; case "hmcl.install.quilt" -> i18n("install.installer.install", i18n("install.installer.quilt") + " " + stageValue);
} case "hmcl.install.quilt-api" -> i18n("install.installer.install", i18n("install.installer.quilt-api") + " " + stageValue);
default -> i18n(stageKey);
};
// @formatter:on // @formatter:on
// CHECKSTYLE:ON // CHECKSTYLE:ON

View File

@@ -60,7 +60,8 @@ public abstract class AbstractInstallersPage extends Control implements WizardPa
library.setOnInstall(() -> { library.setOnInstall(() -> {
if (!Boolean.TRUE.equals(config().getShownTips().get(FABRIC_QUILT_API_TIP)) if (!Boolean.TRUE.equals(config().getShownTips().get(FABRIC_QUILT_API_TIP))
&& (LibraryAnalyzer.LibraryType.FABRIC_API.getPatchId().equals(libraryId) && (LibraryAnalyzer.LibraryType.FABRIC_API.getPatchId().equals(libraryId)
|| LibraryAnalyzer.LibraryType.QUILT_API.getPatchId().equals(libraryId))) { || LibraryAnalyzer.LibraryType.QUILT_API.getPatchId().equals(libraryId)
|| LibraryAnalyzer.LibraryType.LEGACY_FABRIC_API.getPatchId().equals(libraryId))) {
Controllers.dialog(new MessageDialogPane.Builder( Controllers.dialog(new MessageDialogPane.Builder(
i18n("install.installer.fabric-quilt-api.warning", i18n("install.installer." + libraryId)), i18n("install.installer.fabric-quilt-api.warning", i18n("install.installer." + libraryId)),
i18n("message.warning"), i18n("message.warning"),

View File

@@ -121,32 +121,20 @@ public class InstallersPage extends AbstractInstallersPage {
LibraryAnalyzer.LibraryType libraryType = LibraryAnalyzer.LibraryType.fromPatchId(libraryId); LibraryAnalyzer.LibraryType libraryType = LibraryAnalyzer.LibraryType.fromPatchId(libraryId);
if (libraryType != null) { if (libraryType != null) {
String loaderName; String loaderName = switch (libraryType) {
switch (libraryType) { case FORGE -> i18n("install.installer.forge");
case FORGE: case NEO_FORGE -> i18n("install.installer.neoforge");
loaderName = i18n("install.installer.forge"); case CLEANROOM -> i18n("install.installer.cleanroom");
break; case LEGACY_FABRIC -> i18n("install.installer.legacyfabric").replace(" ", "_");
case NEO_FORGE: case FABRIC -> i18n("install.installer.fabric");
loaderName = i18n("install.installer.neoforge"); case LITELOADER -> i18n("install.installer.liteloader");
break; case QUILT -> i18n("install.installer.quilt");
case CLEANROOM: case OPTIFINE -> i18n("install.installer.optifine");
loaderName = i18n("install.installer.cleanroom"); default -> null;
break; };
case FABRIC:
loaderName = i18n("install.installer.fabric"); if (loaderName == null)
break; continue;
case LITELOADER:
loaderName = i18n("install.installer.liteloader");
break;
case QUILT:
loaderName = i18n("install.installer.quilt");
break;
case OPTIFINE:
loaderName = i18n("install.installer.optifine");
break;
default:
continue;
}
nameBuilder.append("-").append(loaderName); nameBuilder.append("-").append(loaderName);
} }

View File

@@ -38,6 +38,8 @@ import org.jackhuang.hmcl.download.fabric.FabricAPIRemoteVersion;
import org.jackhuang.hmcl.download.fabric.FabricRemoteVersion; import org.jackhuang.hmcl.download.fabric.FabricRemoteVersion;
import org.jackhuang.hmcl.download.forge.ForgeRemoteVersion; import org.jackhuang.hmcl.download.forge.ForgeRemoteVersion;
import org.jackhuang.hmcl.download.game.GameRemoteVersion; import org.jackhuang.hmcl.download.game.GameRemoteVersion;
import org.jackhuang.hmcl.download.legacyfabric.LegacyFabricAPIRemoteVersion;
import org.jackhuang.hmcl.download.legacyfabric.LegacyFabricRemoteVersion;
import org.jackhuang.hmcl.download.liteloader.LiteLoaderRemoteVersion; import org.jackhuang.hmcl.download.liteloader.LiteLoaderRemoteVersion;
import org.jackhuang.hmcl.download.neoforge.NeoForgeRemoteVersion; import org.jackhuang.hmcl.download.neoforge.NeoForgeRemoteVersion;
import org.jackhuang.hmcl.download.optifine.OptiFineRemoteVersion; import org.jackhuang.hmcl.download.optifine.OptiFineRemoteVersion;
@@ -270,6 +272,8 @@ public final class VersionsPage extends Control implements WizardPage, Refreshab
iconType = VersionIconType.CLEANROOM; iconType = VersionIconType.CLEANROOM;
else if (remoteVersion instanceof NeoForgeRemoteVersion) else if (remoteVersion instanceof NeoForgeRemoteVersion)
iconType = VersionIconType.NEO_FORGE; iconType = VersionIconType.NEO_FORGE;
else if (remoteVersion instanceof LegacyFabricRemoteVersion || remoteVersion instanceof LegacyFabricAPIRemoteVersion)
iconType = VersionIconType.LEGACY_FABRIC;
else if (remoteVersion instanceof FabricRemoteVersion || remoteVersion instanceof FabricAPIRemoteVersion) else if (remoteVersion instanceof FabricRemoteVersion || remoteVersion instanceof FabricAPIRemoteVersion)
iconType = VersionIconType.FABRIC; iconType = VersionIconType.FABRIC;
else if (remoteVersion instanceof QuiltRemoteVersion || remoteVersion instanceof QuiltAPIRemoteVersion) else if (remoteVersion instanceof QuiltRemoteVersion || remoteVersion instanceof QuiltAPIRemoteVersion)

View File

@@ -76,12 +76,12 @@ public class InstallerListPage extends ListPageBase<InstallerItem> implements Ve
InstallerItem.InstallerItemGroup group = new InstallerItem.InstallerItemGroup(gameVersion, InstallerItem.Style.LIST_ITEM); InstallerItem.InstallerItemGroup group = new InstallerItem.InstallerItemGroup(gameVersion, InstallerItem.Style.LIST_ITEM);
// Conventional libraries: game, fabric, forge, cleanroom, neoforge, liteloader, optifine // Conventional libraries: game, fabric, legacyfabric, forge, cleanroom, neoforge, liteloader, optifine
for (InstallerItem item : group.getLibraries()) { for (InstallerItem item : group.getLibraries()) {
String libraryId = item.getLibraryId(); String libraryId = item.getLibraryId();
// Skip fabric-api and quilt-api // Skip fabric-api and quilt-api and legacyfabric-api
if (libraryId.contains("fabric-api") || libraryId.contains("quilt-api")) { if (libraryId.endsWith("-api")) {
continue; continue;
} }

View File

@@ -152,6 +152,10 @@ public final class ModListPage extends ListPageBase<ModListPageSkin.ModInfoObjec
supportedLoaders.add(ModLoaderType.FABRIC); supportedLoaders.add(ModLoaderType.FABRIC);
} }
if (analyzer.has(LibraryAnalyzer.LibraryType.LEGACY_FABRIC)) {
supportedLoaders.add(ModLoaderType.FABRIC);
}
if (analyzer.has(LibraryAnalyzer.LibraryType.FABRIC) && modManager.hasMod("kilt", ModLoaderType.FABRIC)) { if (analyzer.has(LibraryAnalyzer.LibraryType.FABRIC) && modManager.hasMod("kilt", ModLoaderType.FABRIC)) {
supportedLoaders.add(ModLoaderType.FORGE); supportedLoaders.add(ModLoaderType.FORGE);
supportedLoaders.add(ModLoaderType.NEO_FORGED); supportedLoaders.add(ModLoaderType.NEO_FORGED);

View File

@@ -470,29 +470,18 @@ final class ModListPageSkin extends SkinBase<ModListPage> {
RemoteMod remoteMod = repository.getModById(versionOptional.get().getModid()); RemoteMod remoteMod = repository.getModById(versionOptional.get().getModid());
FXUtils.runInFX(() -> { FXUtils.runInFX(() -> {
for (ModLoaderType modLoaderType : versionOptional.get().getLoaders()) { for (ModLoaderType modLoaderType : versionOptional.get().getLoaders()) {
String loaderName; String loaderName = switch (modLoaderType) {
switch (modLoaderType) { case FORGE -> i18n("install.installer.forge");
case FORGE: case CLEANROOM -> i18n("install.installer.cleanroom");
loaderName = i18n("install.installer.forge"); case LEGACY_FABRIC -> i18n("install.installer.legacyfabric");
break; case NEO_FORGED -> i18n("install.installer.neoforge");
case CLEANROOM: case FABRIC -> i18n("install.installer.fabric");
loaderName = i18n("install.installer.cleanroom"); case LITE_LOADER -> i18n("install.installer.liteloader");
break; case QUILT -> i18n("install.installer.quilt");
case NEO_FORGED: default -> null;
loaderName = i18n("install.installer.neoforge"); };
break; if (loaderName == null)
case FABRIC: continue;
loaderName = i18n("install.installer.fabric");
break;
case LITE_LOADER:
loaderName = i18n("install.installer.liteloader");
break;
case QUILT:
loaderName = i18n("install.installer.quilt");
break;
default:
continue;
}
if (title.getTags() if (title.getTags()
.stream() .stream()
.noneMatch(it -> it.getText().equals(loaderName))) { .noneMatch(it -> it.getText().equals(loaderName))) {
@@ -664,24 +653,13 @@ final class ModListPageSkin extends SkinBase<ModListPage> {
} else if (!ModListPageSkin.this.getSkinnable().supportedLoaders.contains(modLoaderType)) { } else if (!ModListPageSkin.this.getSkinnable().supportedLoaders.contains(modLoaderType)) {
warning.add(i18n("mods.warning.loader_mismatch")); warning.add(i18n("mods.warning.loader_mismatch"));
switch (dataItem.getModInfo().getModLoaderType()) { switch (dataItem.getModInfo().getModLoaderType()) {
case FORGE: case FORGE -> content.addTagWarning(i18n("install.installer.forge"));
content.addTagWarning(i18n("install.installer.forge")); case LEGACY_FABRIC -> content.addTagWarning(i18n("install.installer.legacyfabric"));
break; case CLEANROOM -> content.addTagWarning(i18n("install.installer.cleanroom"));
case CLEANROOM: case NEO_FORGED -> content.addTagWarning(i18n("install.installer.neoforge"));
content.addTagWarning(i18n("install.installer.cleanroom")); case FABRIC -> content.addTagWarning(i18n("install.installer.fabric"));
break; case LITE_LOADER -> content.addTagWarning(i18n("install.installer.liteloader"));
case NEO_FORGED: case QUILT -> content.addTagWarning(i18n("install.installer.quilt"));
content.addTagWarning(i18n("install.installer.neoforge"));
break;
case FABRIC:
content.addTagWarning(i18n("install.installer.fabric"));
break;
case LITE_LOADER:
content.addTagWarning(i18n("install.installer.liteloader"));
break;
case QUILT:
content.addTagWarning(i18n("install.installer.quilt"));
break;
} }
} }

View File

@@ -64,6 +64,7 @@ public class VersionIconDialog extends DialogPane {
createIcon(VersionIconType.OPTIFINE), createIcon(VersionIconType.OPTIFINE),
createIcon(VersionIconType.CRAFT_TABLE), createIcon(VersionIconType.CRAFT_TABLE),
createIcon(VersionIconType.FABRIC), createIcon(VersionIconType.FABRIC),
createIcon(VersionIconType.LEGACY_FABRIC),
createIcon(VersionIconType.FORGE), createIcon(VersionIconType.FORGE),
createIcon(VersionIconType.CLEANROOM), createIcon(VersionIconType.CLEANROOM),
createIcon(VersionIconType.NEO_FORGE), createIcon(VersionIconType.NEO_FORGE),

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@@ -719,6 +719,8 @@ install.installer.depend=Requires %s
install.installer.do_not_install=Do not install install.installer.do_not_install=Do not install
install.installer.fabric=Fabric install.installer.fabric=Fabric
install.installer.fabric-api=Fabric API install.installer.fabric-api=Fabric API
install.installer.legacyfabric=Legacy Fabric
install.installer.legacyfabric-api=Legacy Fabric API
install.installer.fabric-quilt-api.warning=%1$s is a mod and will be installed into the mod directory of the game instance. Please do not change the working directory of the game, or the %1$s will not function. If you do want to change the directory, you should reinstall it. install.installer.fabric-quilt-api.warning=%1$s is a mod and will be installed into the mod directory of the game instance. Please do not change the working directory of the game, or the %1$s will not function. If you do want to change the directory, you should reinstall it.
install.installer.forge=Forge install.installer.forge=Forge
install.installer.neoforge=NeoForge install.installer.neoforge=NeoForge
@@ -1296,6 +1298,7 @@ settings.advanced.custom_commands.hint=The following environment variables are p
\ · $INST_LITELOADER: set if LiteLoader is installed.\n\ \ · $INST_LITELOADER: set if LiteLoader is installed.\n\
\ · $INST_OPTIFINE: set if OptiFine is installed.\n\ \ · $INST_OPTIFINE: set if OptiFine is installed.\n\
\ · $INST_FABRIC: set if Fabric is installed.\n\ \ · $INST_FABRIC: set if Fabric is installed.\n\
\ · $INST_LEGACYFABRIC: set if Legacy Fabric is installed.\n\
\ · $INST_QUILT: set if Quilt is installed. \ · $INST_QUILT: set if Quilt is installed.
settings.advanced.dont_check_game_completeness=Do not check game integrity settings.advanced.dont_check_game_completeness=Do not check game integrity
settings.advanced.dont_check_jvm_validity=Do not check JVM compatibility settings.advanced.dont_check_jvm_validity=Do not check JVM compatibility

View File

@@ -518,6 +518,8 @@ install.installer.depend=需要先安裝 %s
install.installer.do_not_install=不安裝 install.installer.do_not_install=不安裝
install.installer.fabric=Fabric install.installer.fabric=Fabric
install.installer.fabric-api=Fabric API install.installer.fabric-api=Fabric API
install.installer.legacyfabric=Legacy Fabric
install.installer.legacyfabric-api=Legacy Fabric API
install.installer.fabric-quilt-api.warning=%1$s 是一個模組,將會被安裝到新遊戲的模組目錄。請你在安裝遊戲後不要修改目前遊戲的「執行路徑」設定。如果你在之後修改了相關設定,則需要重新安裝 %1$s。 install.installer.fabric-quilt-api.warning=%1$s 是一個模組,將會被安裝到新遊戲的模組目錄。請你在安裝遊戲後不要修改目前遊戲的「執行路徑」設定。如果你在之後修改了相關設定,則需要重新安裝 %1$s。
install.installer.forge=Forge install.installer.forge=Forge
install.installer.neoforge=NeoForge install.installer.neoforge=NeoForge
@@ -1080,6 +1082,7 @@ settings.advanced.custom_commands.hint=自訂指令被呼叫時將包含如下
\ · $INST_LITELOADER: 若安裝了 LiteLoader將會存在本環境變數\n\ \ · $INST_LITELOADER: 若安裝了 LiteLoader將會存在本環境變數\n\
\ · $INST_OPTIFINE: 若安裝了 OptiFine將會存在本環境變數\n\ \ · $INST_OPTIFINE: 若安裝了 OptiFine將會存在本環境變數\n\
\ · $INST_FABRIC: 若安裝了 Fabric將會存在本環境變數\n\ \ · $INST_FABRIC: 若安裝了 Fabric將會存在本環境變數\n\
\ · $INST_LEGACYFABRIC: 若安裝了 Legacy Fabric將會存在本環境變數\n\
\ · $INST_QUILT: 若安裝了 Quilt將會存在本環境變數。 \ · $INST_QUILT: 若安裝了 Quilt將會存在本環境變數。
settings.advanced.dont_check_game_completeness=不檢查遊戲完整性 settings.advanced.dont_check_game_completeness=不檢查遊戲完整性
settings.advanced.dont_check_jvm_validity=不檢查 Java 虛擬機與遊戲的相容性 settings.advanced.dont_check_jvm_validity=不檢查 Java 虛擬機與遊戲的相容性

View File

@@ -521,6 +521,8 @@ install.installer.cleanroom=Cleanroom
install.installer.depend=需要先安装 %s install.installer.depend=需要先安装 %s
install.installer.do_not_install=不安装 install.installer.do_not_install=不安装
install.installer.fabric=Fabric install.installer.fabric=Fabric
install.installer.legacyfabric=Legacy Fabric
install.installer.legacyfabric-api=Legacy Fabric API
install.installer.fabric-api=Fabric API install.installer.fabric-api=Fabric API
install.installer.fabric-quilt-api.warning=%1$s 是一个模组,将会被安装到新游戏的模组文件夹。请你在安装游戏后不要修改当前游戏的“版本隔离”设置。如果你在之后修改了相关设置,则需要重新安装 %1$s。 install.installer.fabric-quilt-api.warning=%1$s 是一个模组,将会被安装到新游戏的模组文件夹。请你在安装游戏后不要修改当前游戏的“版本隔离”设置。如果你在之后修改了相关设置,则需要重新安装 %1$s。
install.installer.forge=Forge install.installer.forge=Forge
@@ -1084,6 +1086,7 @@ settings.advanced.custom_commands.hint=自定义命令被调用时将包含如
\ · $INST_LITELOADER: 若安装了 LiteLoader将会存在本环境变量\n\ \ · $INST_LITELOADER: 若安装了 LiteLoader将会存在本环境变量\n\
\ · $INST_OPTIFINE: 若安装了 OptiFine将会存在本环境变量\n\ \ · $INST_OPTIFINE: 若安装了 OptiFine将会存在本环境变量\n\
\ · $INST_FABRIC: 若安装了 Fabric将会存在本环境变量\n\ \ · $INST_FABRIC: 若安装了 Fabric将会存在本环境变量\n\
\ · $INST_LEGACYFABRIC: 若安装了 Legacy Fabric将会存在本环境变量\n\
\ · $INST_QUILT: 若安装了 Quilt将会存在本环境变量。 \ · $INST_QUILT: 若安装了 Quilt将会存在本环境变量。
settings.advanced.dont_check_game_completeness=不检查游戏完整性 settings.advanced.dont_check_game_completeness=不检查游戏完整性
settings.advanced.dont_check_jvm_validity=不检查 Java 虚拟机与游戏的兼容性 settings.advanced.dont_check_jvm_validity=不检查 Java 虚拟机与游戏的兼容性

View File

@@ -22,6 +22,8 @@ import org.jackhuang.hmcl.download.fabric.FabricAPIVersionList;
import org.jackhuang.hmcl.download.fabric.FabricVersionList; import org.jackhuang.hmcl.download.fabric.FabricVersionList;
import org.jackhuang.hmcl.download.forge.ForgeBMCLVersionList; import org.jackhuang.hmcl.download.forge.ForgeBMCLVersionList;
import org.jackhuang.hmcl.download.game.GameVersionList; import org.jackhuang.hmcl.download.game.GameVersionList;
import org.jackhuang.hmcl.download.legacyfabric.LegacyFabricAPIVersionList;
import org.jackhuang.hmcl.download.legacyfabric.LegacyFabricVersionList;
import org.jackhuang.hmcl.download.liteloader.LiteLoaderBMCLVersionList; import org.jackhuang.hmcl.download.liteloader.LiteLoaderBMCLVersionList;
import org.jackhuang.hmcl.download.neoforge.NeoForgeBMCLVersionList; import org.jackhuang.hmcl.download.neoforge.NeoForgeBMCLVersionList;
import org.jackhuang.hmcl.download.optifine.OptiFineBMCLVersionList; import org.jackhuang.hmcl.download.optifine.OptiFineBMCLVersionList;
@@ -47,6 +49,8 @@ public final class BMCLAPIDownloadProvider implements DownloadProvider {
private final FabricAPIVersionList fabricApi; private final FabricAPIVersionList fabricApi;
private final ForgeBMCLVersionList forge; private final ForgeBMCLVersionList forge;
private final CleanroomVersionList cleanroom; private final CleanroomVersionList cleanroom;
private final LegacyFabricVersionList legacyFabric;
private final LegacyFabricAPIVersionList legacyFabricApi;
private final NeoForgeBMCLVersionList neoforge; private final NeoForgeBMCLVersionList neoforge;
private final LiteLoaderBMCLVersionList liteLoader; private final LiteLoaderBMCLVersionList liteLoader;
private final OptiFineBMCLVersionList optifine; private final OptiFineBMCLVersionList optifine;
@@ -66,6 +70,9 @@ public final class BMCLAPIDownloadProvider implements DownloadProvider {
this.optifine = new OptiFineBMCLVersionList(apiRoot); this.optifine = new OptiFineBMCLVersionList(apiRoot);
this.quilt = new QuiltVersionList(this); this.quilt = new QuiltVersionList(this);
this.quiltApi = new QuiltAPIVersionList(this); this.quiltApi = new QuiltAPIVersionList(this);
this.legacyFabric = new LegacyFabricVersionList(this);
this.legacyFabricApi = new LegacyFabricAPIVersionList(this);
this.replacement = Arrays.asList( this.replacement = Arrays.asList(
pair("https://bmclapi2.bangbang93.com", apiRoot), pair("https://bmclapi2.bangbang93.com", apiRoot),
pair("https://launchermeta.mojang.com", apiRoot), pair("https://launchermeta.mojang.com", apiRoot),
@@ -112,30 +119,21 @@ public final class BMCLAPIDownloadProvider implements DownloadProvider {
@Override @Override
public VersionList<?> getVersionListById(String id) { public VersionList<?> getVersionListById(String id) {
switch (id) { return switch (id) {
case "game": case "game" -> game;
return game; case "fabric" -> fabric;
case "fabric": case "fabric-api" -> fabricApi;
return fabric; case "forge" -> forge;
case "fabric-api": case "cleanroom" -> cleanroom;
return fabricApi; case "neoforge" -> neoforge;
case "forge": case "liteloader" -> liteLoader;
return forge; case "optifine" -> optifine;
case "cleanroom": case "quilt" -> quilt;
return cleanroom; case "quilt-api" -> quiltApi;
case "neoforge": case "legacyfabric" -> legacyFabric;
return neoforge; case "legacyfabric-api" -> legacyFabricApi;
case "liteloader": default -> throw new IllegalArgumentException("Unrecognized version list id: " + id);
return liteLoader; };
case "optifine":
return optifine;
case "quilt":
return quilt;
case "quilt-api":
return quiltApi;
default:
throw new IllegalArgumentException("Unrecognized version list id: " + id);
}
} }
@Override @Override

View File

@@ -189,7 +189,35 @@ public final class LibraryAnalyzer implements Iterable<LibraryAnalyzer.LibraryMa
public enum LibraryType { public enum LibraryType {
MINECRAFT(true, "game", "^$", "^$", null), MINECRAFT(true, "game", "^$", "^$", null),
FABRIC(true, "fabric", "net\\.fabricmc", "fabric-loader", ModLoaderType.FABRIC), LEGACY_FABRIC(true, "legacyfabric", "net\\.fabricmc", "fabric-loader", ModLoaderType.LEGACY_FABRIC) {
@Override
protected boolean matchLibrary(Library library, List<Library> libraries) {
if (!super.matchLibrary(library, libraries)) {
return false;
}
for (Library l : libraries) {
if ("net.legacyfabric".equals(l.getGroupId())) {
return true;
}
}
return false;
}
},
LEGACY_FABRIC_API(false, "legacyfabric-api", "net\\.legacyfabric", "legacyfabric-api", null),
FABRIC(true, "fabric", "net\\.fabricmc", "fabric-loader", ModLoaderType.FABRIC) {
@Override
protected boolean matchLibrary(Library library, List<Library> libraries) {
if (!super.matchLibrary(library, libraries)) {
return false;
}
for (Library l : libraries) {
if ("net.legacyfabric".equals(l.getGroupId())) {
return false;
}
}
return true;
}
},
FABRIC_API(true, "fabric-api", "net\\.fabricmc", "fabric-api", null), FABRIC_API(true, "fabric-api", "net\\.fabricmc", "fabric-api", null),
FORGE(true, "forge", "net\\.minecraftforge", "(forge|fmlloader)", ModLoaderType.FORGE) { FORGE(true, "forge", "net\\.minecraftforge", "(forge|fmlloader)", ModLoaderType.FORGE) {
private final Pattern FORGE_VERSION_MATCHER = Pattern.compile("^([0-9.]+)-(?<forge>[0-9.]+)(-([0-9.]+))?$"); private final Pattern FORGE_VERSION_MATCHER = Pattern.compile("^([0-9.]+)-(?<forge>[0-9.]+)(-([0-9.]+))?$");
@@ -278,6 +306,7 @@ public final class LibraryAnalyzer implements Iterable<LibraryAnalyzer.LibraryMa
private final ModLoaderType modLoaderType; private final ModLoaderType modLoaderType;
private static final Map<String, LibraryType> PATCH_ID_MAP = new HashMap<>(); private static final Map<String, LibraryType> PATCH_ID_MAP = new HashMap<>();
static { static {
for (LibraryType type : values()) { for (LibraryType type : values()) {
PATCH_ID_MAP.put(type.getPatchId(), type); PATCH_ID_MAP.put(type.getPatchId(), type);

View File

@@ -22,6 +22,8 @@ import org.jackhuang.hmcl.download.fabric.FabricAPIVersionList;
import org.jackhuang.hmcl.download.fabric.FabricVersionList; import org.jackhuang.hmcl.download.fabric.FabricVersionList;
import org.jackhuang.hmcl.download.forge.ForgeVersionList; import org.jackhuang.hmcl.download.forge.ForgeVersionList;
import org.jackhuang.hmcl.download.game.GameVersionList; import org.jackhuang.hmcl.download.game.GameVersionList;
import org.jackhuang.hmcl.download.legacyfabric.LegacyFabricAPIVersionList;
import org.jackhuang.hmcl.download.legacyfabric.LegacyFabricVersionList;
import org.jackhuang.hmcl.download.liteloader.LiteLoaderVersionList; import org.jackhuang.hmcl.download.liteloader.LiteLoaderVersionList;
import org.jackhuang.hmcl.download.neoforge.NeoForgeOfficialVersionList; import org.jackhuang.hmcl.download.neoforge.NeoForgeOfficialVersionList;
import org.jackhuang.hmcl.download.optifine.OptiFineBMCLVersionList; import org.jackhuang.hmcl.download.optifine.OptiFineBMCLVersionList;
@@ -47,6 +49,8 @@ public class MojangDownloadProvider implements DownloadProvider {
private final OptiFineBMCLVersionList optifine; private final OptiFineBMCLVersionList optifine;
private final QuiltVersionList quilt; private final QuiltVersionList quilt;
private final QuiltAPIVersionList quiltApi; private final QuiltAPIVersionList quiltApi;
private final LegacyFabricVersionList legacyFabric;
private final LegacyFabricAPIVersionList legacyFabricApi;
public MojangDownloadProvider() { public MojangDownloadProvider() {
// If there is no official download channel available, fallback to BMCLAPI. // If there is no official download channel available, fallback to BMCLAPI.
@@ -62,6 +66,8 @@ public class MojangDownloadProvider implements DownloadProvider {
this.optifine = new OptiFineBMCLVersionList(apiRoot); this.optifine = new OptiFineBMCLVersionList(apiRoot);
this.quilt = new QuiltVersionList(this); this.quilt = new QuiltVersionList(this);
this.quiltApi = new QuiltAPIVersionList(this); this.quiltApi = new QuiltAPIVersionList(this);
this.legacyFabric = new LegacyFabricVersionList(this);
this.legacyFabricApi = new LegacyFabricAPIVersionList(this);
} }
@Override @Override
@@ -76,30 +82,21 @@ public class MojangDownloadProvider implements DownloadProvider {
@Override @Override
public VersionList<?> getVersionListById(String id) { public VersionList<?> getVersionListById(String id) {
switch (id) { return switch (id) {
case "game": case "game" -> game;
return game; case "fabric" -> fabric;
case "fabric": case "fabric-api" -> fabricApi;
return fabric; case "forge" -> forge;
case "fabric-api": case "cleanroom" -> cleanroom;
return fabricApi; case "neoforge" -> neoforge;
case "forge": case "liteloader" -> liteLoader;
return forge; case "optifine" -> optifine;
case "cleanroom": case "quilt" -> quilt;
return cleanroom; case "quilt-api" -> quiltApi;
case "neoforge": case "legacyfabric" -> legacyFabric;
return neoforge; case "legacyfabric-api" -> legacyFabricApi;
case "liteloader": default -> throw new IllegalArgumentException("Unrecognized version list id: " + id);
return liteLoader; };
case "optifine":
return optifine;
case "quilt":
return quilt;
case "quilt-api":
return quiltApi;
default:
throw new IllegalArgumentException("Unrecognized version list id: " + id);
}
} }
@Override @Override

View File

@@ -59,7 +59,7 @@ public final class FabricAPIInstallTask extends Task<Version> {
public void execute() throws IOException { public void execute() throws IOException {
dependencies.add(new FileDownloadTask( dependencies.add(new FileDownloadTask(
remote.getVersion().getFile().getUrl(), remote.getVersion().getFile().getUrl(),
dependencyManager.getGameRepository().getRunDirectory(version.getId()).resolve("mods").resolve("fabric-api-" + remote.getVersion().getVersion() + ".jar"), dependencyManager.getGameRepository().getModsDirectory(version.getId()).resolve("fabric-api-" + remote.getVersion().getVersion() + ".jar"),
remote.getVersion().getFile().getIntegrityCheck()) remote.getVersion().getFile().getIntegrityCheck())
); );
} }

View File

@@ -28,6 +28,7 @@ import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.game.Version; import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.task.GetTask; import org.jackhuang.hmcl.task.GetTask;
import org.jackhuang.hmcl.task.Task; import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.gson.JsonSerializable;
import org.jackhuang.hmcl.util.gson.JsonUtils; import org.jackhuang.hmcl.util.gson.JsonUtils;
import java.io.IOException; import java.io.IOException;
@@ -127,6 +128,7 @@ public final class FabricInstallTask extends Task<Version> {
return new Version(LibraryAnalyzer.LibraryType.FABRIC.getPatchId(), loaderVersion, Version.PRIORITY_LOADER, arguments, mainClass, libraries); return new Version(LibraryAnalyzer.LibraryType.FABRIC.getPatchId(), loaderVersion, Version.PRIORITY_LOADER, arguments, mainClass, libraries);
} }
@JsonSerializable
public static class FabricInfo { public static class FabricInfo {
private final LoaderInfo loader; private final LoaderInfo loader;
private final IntermediaryInfo intermediary; private final IntermediaryInfo intermediary;
@@ -151,6 +153,7 @@ public final class FabricInstallTask extends Task<Version> {
} }
} }
@JsonSerializable
public static class LoaderInfo { public static class LoaderInfo {
private final String separator; private final String separator;
private final int build; private final int build;
@@ -187,6 +190,7 @@ public final class FabricInstallTask extends Task<Version> {
} }
} }
@JsonSerializable
public static class IntermediaryInfo { public static class IntermediaryInfo {
private final String maven; private final String maven;
private final String version; private final String version;

View File

@@ -0,0 +1,61 @@
/*
* Hello Minecraft! Launcher
* Copyright (C) 2021 huangyuhui <huanghongxun2008@126.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.jackhuang.hmcl.download.legacyfabric;
import org.jackhuang.hmcl.download.DefaultDependencyManager;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.task.FileDownloadTask;
import org.jackhuang.hmcl.task.Task;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public final class LegacyFabricAPIInstallTask extends Task<Version> {
private final DefaultDependencyManager dependencyManager;
private final Version version;
private final LegacyFabricAPIRemoteVersion remote;
private final List<Task<?>> dependencies = new ArrayList<>(1);
public LegacyFabricAPIInstallTask(DefaultDependencyManager dependencyManager, Version version, LegacyFabricAPIRemoteVersion remoteVersion) {
this.dependencyManager = dependencyManager;
this.version = version;
this.remote = remoteVersion;
}
@Override
public Collection<Task<?>> getDependencies() {
return dependencies;
}
@Override
public boolean isRelyingOnDependencies() {
return false;
}
@Override
public void execute() throws IOException {
dependencies.add(new FileDownloadTask(
remote.getVersion().getFile().getUrl(),
dependencyManager.getGameRepository().getModsDirectory(version.getId()).resolve("legacy-fabric-api-" + remote.getVersion().getVersion() + ".jar"),
remote.getVersion().getFile().getIntegrityCheck())
);
}
}

View File

@@ -0,0 +1,67 @@
/*
* Hello Minecraft! Launcher
* Copyright (C) 2022 huangyuhui <huanghongxun2008@126.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.jackhuang.hmcl.download.legacyfabric;
import org.jackhuang.hmcl.download.DefaultDependencyManager;
import org.jackhuang.hmcl.download.LibraryAnalyzer;
import org.jackhuang.hmcl.download.RemoteVersion;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.mod.RemoteMod;
import org.jackhuang.hmcl.task.Task;
import java.time.Instant;
import java.util.List;
public class LegacyFabricAPIRemoteVersion extends RemoteVersion {
private final String fullVersion;
private final RemoteMod.Version version;
/**
* Constructor.
*
* @param gameVersion the Minecraft version that this remote version suits.
* @param selfVersion the version string of the remote version.
* @param urls the installer or universal jar original URL.
*/
LegacyFabricAPIRemoteVersion(String gameVersion, String selfVersion, String fullVersion, Instant datePublished, RemoteMod.Version version, List<String> urls) {
super(LibraryAnalyzer.LibraryType.LEGACY_FABRIC_API.getPatchId(), gameVersion, selfVersion, datePublished, urls);
this.fullVersion = fullVersion;
this.version = version;
}
@Override
public String getFullVersion() {
return fullVersion;
}
public RemoteMod.Version getVersion() {
return version;
}
@Override
public Task<Version> getInstallTask(DefaultDependencyManager dependencyManager, Version baseVersion) {
return new LegacyFabricAPIInstallTask(dependencyManager, baseVersion, this);
}
@Override
public int compareTo(RemoteVersion o) {
if (!(o instanceof LegacyFabricAPIRemoteVersion)) return 0;
return -this.getReleaseDate().compareTo(o.getReleaseDate());
}
}

View File

@@ -0,0 +1,53 @@
/*
* Hello Minecraft! Launcher
* Copyright (C) 2022 huangyuhui <huanghongxun2008@126.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.jackhuang.hmcl.download.legacyfabric;
import org.jackhuang.hmcl.download.DownloadProvider;
import org.jackhuang.hmcl.download.VersionList;
import org.jackhuang.hmcl.mod.RemoteMod;
import org.jackhuang.hmcl.mod.modrinth.ModrinthRemoteModRepository;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.Lang;
import java.util.Collections;
public class LegacyFabricAPIVersionList extends VersionList<LegacyFabricAPIRemoteVersion> {
private final DownloadProvider downloadProvider;
public LegacyFabricAPIVersionList(DownloadProvider downloadProvider) {
this.downloadProvider = downloadProvider;
}
@Override
public boolean hasType() {
return false;
}
@Override
public Task<?> refreshAsync() {
return Task.runAsync(() -> {
for (RemoteMod.Version modVersion : Lang.toIterable(ModrinthRemoteModRepository.MODS.getRemoteVersionsById("legacy-fabric-api"))) {
for (String gameVersion : modVersion.getGameVersions()) {
versions.put(gameVersion, new LegacyFabricAPIRemoteVersion(gameVersion, modVersion.getVersion(), modVersion.getName(), modVersion.getDatePublished(), modVersion,
Collections.singletonList(modVersion.getFile().getUrl())));
}
}
});
}
}

View File

@@ -0,0 +1,130 @@
/*
* Hello Minecraft! Launcher
* Copyright (C) 2022 huangyuhui <huanghongxun2008@126.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.jackhuang.hmcl.download.legacyfabric;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import org.jackhuang.hmcl.download.DefaultDependencyManager;
import org.jackhuang.hmcl.download.LibraryAnalyzer;
import org.jackhuang.hmcl.download.UnsupportedInstallationException;
import org.jackhuang.hmcl.download.fabric.FabricInstallTask;
import org.jackhuang.hmcl.game.Arguments;
import org.jackhuang.hmcl.game.Artifact;
import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.task.GetTask;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.gson.JsonUtils;
import java.util.*;
import static org.jackhuang.hmcl.download.UnsupportedInstallationException.FABRIC_NOT_COMPATIBLE_WITH_FORGE;
public final class LegacyFabricInstallTask extends Task<Version> {
private final DefaultDependencyManager dependencyManager;
private final Version version;
private final LegacyFabricRemoteVersion remote;
private final GetTask launchMetaTask;
private final List<Task<?>> dependencies = new ArrayList<>(1);
public LegacyFabricInstallTask(DefaultDependencyManager dependencyManager, Version version, LegacyFabricRemoteVersion remoteVersion) {
this.dependencyManager = dependencyManager;
this.version = version;
this.remote = remoteVersion;
launchMetaTask = new GetTask(dependencyManager.getDownloadProvider().injectURLsWithCandidates(remoteVersion.getUrls()));
launchMetaTask.setCacheRepository(dependencyManager.getCacheRepository());
}
@Override
public boolean doPreExecute() {
return true;
}
@Override
public void preExecute() throws Exception {
if (!Objects.equals("net.minecraft.client.main.Main", version.resolve(dependencyManager.getGameRepository()).getMainClass()))
throw new UnsupportedInstallationException(FABRIC_NOT_COMPATIBLE_WITH_FORGE);
}
@Override
public Collection<Task<?>> getDependents() {
return Collections.singleton(launchMetaTask);
}
@Override
public Collection<Task<?>> getDependencies() {
return dependencies;
}
@Override
public boolean isRelyingOnDependencies() {
return false;
}
@Override
public void execute() {
setResult(getPatch(JsonUtils.GSON.fromJson(launchMetaTask.getResult(), FabricInstallTask.FabricInfo.class), remote.getGameVersion(), remote.getSelfVersion()));
dependencies.add(dependencyManager.checkLibraryCompletionAsync(getResult(), true));
}
private Version getPatch(FabricInstallTask.FabricInfo legacyFabricInfo, String gameVersion, String loaderVersion) {
JsonObject launcherMeta = legacyFabricInfo.getLauncherMeta();
Arguments arguments = new Arguments();
String mainClass;
if (!launcherMeta.get("mainClass").isJsonObject()) {
mainClass = launcherMeta.get("mainClass").getAsString();
} else {
mainClass = launcherMeta.get("mainClass").getAsJsonObject().get("client").getAsString();
}
if (launcherMeta.has("launchwrapper")) {
String clientTweaker = launcherMeta.get("launchwrapper").getAsJsonObject().get("tweakers").getAsJsonObject().get("client").getAsJsonArray().get(0).getAsString();
arguments = arguments.addGameArguments("--tweakClass", clientTweaker);
}
JsonObject librariesObject = launcherMeta.getAsJsonObject("libraries");
List<Library> libraries = new ArrayList<>();
// "common, server" is hard coded in fabric installer.
// Don't know the purpose of ignoring client libraries.
for (String side : new String[]{"common", "server"}) {
for (JsonElement element : librariesObject.getAsJsonArray(side)) {
libraries.add(JsonUtils.GSON.fromJson(element, Library.class));
}
}
// libraries.add(new Library(Artifact.fromDescriptor(legacyFabricInfo.hashed.maven), getMavenRepositoryByGroup(legacyFabricInfo.hashed.maven), null));
libraries.add(new Library(Artifact.fromDescriptor(legacyFabricInfo.getIntermediary().getMaven()), getMavenRepositoryByGroup(legacyFabricInfo.getIntermediary().getMaven()), null));
libraries.add(new Library(Artifact.fromDescriptor(legacyFabricInfo.getLoader().getMaven()), getMavenRepositoryByGroup(legacyFabricInfo.getLoader().getMaven()), null));
return new Version(LibraryAnalyzer.LibraryType.LEGACY_FABRIC.getPatchId(), loaderVersion, Version.PRIORITY_LOADER, arguments, mainClass, libraries);
}
private static String getMavenRepositoryByGroup(String maven) {
Artifact artifact = Artifact.fromDescriptor(maven);
return switch (artifact.getGroup()) {
case "net.fabricmc" -> "https://maven.fabricmc.net/";
case "net.legacyfabric" -> "https://maven.legacyfabric.net/";
default -> "https://maven.fabricmc.net/";
};
}
}

View File

@@ -0,0 +1,44 @@
/*
* Hello Minecraft! Launcher
* Copyright (C) 2022 huangyuhui <huanghongxun2008@126.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.jackhuang.hmcl.download.legacyfabric;
import org.jackhuang.hmcl.download.DefaultDependencyManager;
import org.jackhuang.hmcl.download.LibraryAnalyzer;
import org.jackhuang.hmcl.download.RemoteVersion;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.task.Task;
import java.util.List;
public class LegacyFabricRemoteVersion extends RemoteVersion {
/**
* Constructor.
*
* @param gameVersion the Minecraft version that this remote version suits.
* @param selfVersion the version string of the remote version.
* @param urls the installer or universal jar original URL.
*/
LegacyFabricRemoteVersion(String gameVersion, String selfVersion, List<String> urls) {
super(LibraryAnalyzer.LibraryType.LEGACY_FABRIC.getPatchId(), gameVersion, selfVersion, null, urls);
}
@Override
public Task<Version> getInstallTask(DefaultDependencyManager dependencyManager, Version baseVersion) {
return new LegacyFabricInstallTask(dependencyManager, baseVersion, this);
}
}

View File

@@ -0,0 +1,106 @@
/*
* Hello Minecraft! Launcher
* Copyright (C) 2022 huangyuhui <huanghongxun2008@126.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.jackhuang.hmcl.download.legacyfabric;
import org.jackhuang.hmcl.download.DownloadProvider;
import org.jackhuang.hmcl.download.VersionList;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.gson.JsonUtils;
import org.jackhuang.hmcl.util.io.NetworkUtils;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import static org.jackhuang.hmcl.util.gson.JsonUtils.listTypeOf;
public final class LegacyFabricVersionList extends VersionList<LegacyFabricRemoteVersion> {
private final DownloadProvider downloadProvider;
public LegacyFabricVersionList(DownloadProvider downloadProvider) {
this.downloadProvider = downloadProvider;
}
@Override
public boolean hasType() {
return false;
}
@Override
public Task<?> refreshAsync() {
return Task.runAsync(() -> {
List<String> gameVersions = getGameVersions(GAME_META_URL);
List<String> loaderVersions = getGameVersions(LOADER_META_URL);
lock.writeLock().lock();
try {
for (String gameVersion : gameVersions)
for (String loaderVersion : loaderVersions)
versions.put(gameVersion, new LegacyFabricRemoteVersion(gameVersion, loaderVersion,
Collections.singletonList(getLaunchMetaUrl(gameVersion, loaderVersion))));
} finally {
lock.writeLock().unlock();
}
});
}
private static final String LOADER_META_URL = "https://meta.legacyfabric.net/v2/versions/loader";
private static final String GAME_META_URL = "https://meta.legacyfabric.net/v2/versions/game";
private List<String> getGameVersions(String metaUrl) throws IOException {
String json = NetworkUtils.doGet(downloadProvider.injectURLWithCandidates(metaUrl));
return JsonUtils.GSON.fromJson(json, listTypeOf(GameVersion.class))
.stream().map(GameVersion::getVersion).collect(Collectors.toList());
}
private static String getLaunchMetaUrl(String gameVersion, String loaderVersion) {
return String.format("https://meta.legacyfabric.net/v2/versions/loader/%s/%s", gameVersion, loaderVersion);
}
private static class GameVersion {
private final String version;
private final String maven;
private final boolean stable;
public GameVersion() {
this("", null, false);
}
public GameVersion(String version, String maven, boolean stable) {
this.version = version;
this.maven = maven;
this.stable = stable;
}
public String getVersion() {
return version;
}
@Nullable
public String getMaven() {
return maven;
}
public boolean isStable() {
return stable;
}
}
}

View File

@@ -59,7 +59,7 @@ public final class QuiltAPIInstallTask extends Task<Version> {
public void execute() throws IOException { public void execute() throws IOException {
dependencies.add(new FileDownloadTask( dependencies.add(new FileDownloadTask(
remote.getVersion().getFile().getUrl(), remote.getVersion().getFile().getUrl(),
dependencyManager.getGameRepository().getRunDirectory(version.getId()).resolve("mods").resolve("quilt-api-" + remote.getVersion().getVersion() + ".jar"), dependencyManager.getGameRepository().getModsDirectory(version.getId()).resolve("quilt-api-" + remote.getVersion().getVersion() + ".jar"),
remote.getVersion().getFile().getIntegrityCheck()) remote.getVersion().getFile().getIntegrityCheck())
); );
} }

View File

@@ -28,6 +28,7 @@ import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.game.Version; import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.task.GetTask; import org.jackhuang.hmcl.task.GetTask;
import org.jackhuang.hmcl.task.Task; import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.gson.JsonSerializable;
import org.jackhuang.hmcl.util.gson.JsonUtils; import org.jackhuang.hmcl.util.gson.JsonUtils;
import java.util.*; import java.util.*;
@@ -135,6 +136,7 @@ public final class QuiltInstallTask extends Task<Version> {
} }
} }
@JsonSerializable
public static class QuiltInfo { public static class QuiltInfo {
private final LoaderInfo loader; private final LoaderInfo loader;
private final IntermediaryInfo hashed; private final IntermediaryInfo hashed;
@@ -165,6 +167,7 @@ public final class QuiltInstallTask extends Task<Version> {
} }
} }
@JsonSerializable
public static class LoaderInfo { public static class LoaderInfo {
private final String separator; private final String separator;
private final int build; private final int build;
@@ -201,6 +204,7 @@ public final class QuiltInstallTask extends Task<Version> {
} }
} }
@JsonSerializable
public static class IntermediaryInfo { public static class IntermediaryInfo {
private final String maven; private final String maven;
private final String version; private final String version;

View File

@@ -600,6 +600,9 @@ public class DefaultLauncher extends Launcher {
if (analyzer.has(LibraryAnalyzer.LibraryType.QUILT)) { if (analyzer.has(LibraryAnalyzer.LibraryType.QUILT)) {
env.put("INST_QUILT", "1"); env.put("INST_QUILT", "1");
} }
if (analyzer.has(LibraryAnalyzer.LibraryType.LEGACY_FABRIC)) {
env.put("INST_LEGACYFABRIC", "1");
}
env.putAll(options.getEnvironmentVariables()); env.putAll(options.getEnvironmentVariables());

View File

@@ -25,5 +25,6 @@ public enum ModLoaderType {
FABRIC, FABRIC,
QUILT, QUILT,
LITE_LOADER, LITE_LOADER,
PACK; LEGACY_FABRIC,
PACK
} }

View File

@@ -109,6 +109,8 @@ public class McbbsModpackExportTask extends Task<Void> {
addons.add(new McbbsModpackManifest.Addon(FABRIC.getPatchId(), fabricVersion))); addons.add(new McbbsModpackManifest.Addon(FABRIC.getPatchId(), fabricVersion)));
analyzer.getVersion(QUILT).ifPresent(quiltVersion -> analyzer.getVersion(QUILT).ifPresent(quiltVersion ->
addons.add(new McbbsModpackManifest.Addon(QUILT.getPatchId(), quiltVersion))); addons.add(new McbbsModpackManifest.Addon(QUILT.getPatchId(), quiltVersion)));
analyzer.getVersion(LEGACY_FABRIC).ifPresent(legacyfabricVersion ->
addons.add(new McbbsModpackManifest.Addon(LEGACY_FABRIC.getPatchId(), legacyfabricVersion)));
List<Library> libraries = new ArrayList<>(); List<Library> libraries = new ArrayList<>();
// TODO libraries // TODO libraries