Merge remote-tracking branch 'upstream/develop' into develop

Signed-off-by: sneedium <sneed@sneedmc.org>
This commit is contained in:
sneedium 2024-09-03 20:25:51 -04:00
commit f30cfcd6a5
Signed by: sneedium
GPG Key ID: 906F66490FBE722F
18 changed files with 248 additions and 13 deletions

View File

@ -34,11 +34,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1712129508,
"narHash": "sha256-FBVpEX0eLiqX3jnSL3rmJHqHhbuCikJZyDyV3Cl3qAY=",
"lastModified": 1722141560,
"narHash": "sha256-Ul3rIdesWaiW56PS/Ak3UlJdkwBrD4UcagCmXZR9Z7Y=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "d03a4482228d4d6dbd2d4b425b6dfcd49ebe765f",
"rev": "038fb464fcfa79b4f08131b07f2d8c9a6bcc4160",
"type": "github"
},
"original": {
@ -59,11 +59,11 @@
"tomlplusplus": {
"flake": false,
"locked": {
"lastModified": 1710824845,
"narHash": "sha256-A9XuCfVcLle/tMNaH7aqb1leM+t3wwC9ER5RIbMMovo=",
"lastModified": 1720775063,
"narHash": "sha256-9j8qNCITFPvKECY5Sjb2Ri5KcPzRrF0e7G2CUemIhBw=",
"owner": "marzer",
"repo": "tomlplusplus",
"rev": "1f7884e59165e517462f922e7b6de131bd9844f3",
"rev": "e2bae9d559b4956a831fcef10ac8f01c88cb0d13",
"type": "github"
},
"original": {

View File

@ -60,6 +60,7 @@
static const QMap<QString, ModAPI::ModLoaderType> modloaderMapping{
{"net.minecraftforge", ModAPI::Forge},
{"net.neoforged.neoforge", ModAPI::NeoForge},
{"net.fabricmc.fabric-loader", ModAPI::Fabric},
{"org.quiltmc.quilt-loader", ModAPI::Quilt}
};

View File

@ -297,7 +297,7 @@ void LocalModParseTask::processAsZip()
QuaZipFile file(&zip);
if (zip.setCurrentFile("META-INF/mods.toml")) {
if (zip.setCurrentFile("META-INF/neoforge.mods.toml") || zip.setCurrentFile("META-INF/mods.toml")) {
if (!file.open(QIODevice::ReadOnly)) {
zip.close();
return;

View File

@ -60,7 +60,8 @@ class ModAPI {
Cauldron = 1 << 1,
LiteLoader = 1 << 2,
Fabric = 1 << 3,
Quilt = 1 << 4
Quilt = 1 << 4,
NeoForge = 1 << 5
};
Q_DECLARE_FLAGS(ModLoaderTypes, ModLoaderType)
@ -93,6 +94,8 @@ class ModAPI {
break;
case Forge:
return "forge";
case NeoForge:
return "neoforge";
case Cauldron:
return "cauldron";
case LiteLoader:

View File

@ -79,6 +79,8 @@ class FlameAPI : public NetworkModAPI {
// TODO: remove this once Quilt drops official Fabric support
if (loaders & Quilt) // NOTE: Most if not all Fabric mods should work *currently*
return 4; // Quilt would probably be 5
if (loaders & NeoForge)
return 6;
return 0;
}
};

View File

@ -257,6 +257,7 @@ bool FlameCreationTask::createInstance()
QString forgeVersion;
QString fabricVersion;
QString neoforgeVersion;
// TODO: is Quilt relevant here?
for (auto& loader : m_pack.minecraft.modLoaders) {
auto id = loader.id;
@ -270,6 +271,11 @@ bool FlameCreationTask::createInstance()
fabricVersion = id;
continue;
}
if (id.startsWith("neoforge-")) {
id.remove("neoforge-");
neoforgeVersion = id;
continue;
}
logWarning(tr("Unknown mod loader in manifest: %1").arg(id));
}
@ -300,6 +306,8 @@ bool FlameCreationTask::createInstance()
}
if (!fabricVersion.isEmpty())
components->setComponentVersion("net.fabricmc.fabric-loader", fabricVersion);
if (!neoforgeVersion.isEmpty())
components->setComponentVersion("net.neoforged.neoforge", neoforgeVersion);
if (m_instIcon != "default") {
instance.setIconKey(m_instIcon);

View File

@ -313,6 +313,8 @@ void PackInstallTask::install()
components->setComponentVersion("net.minecraftforge", target.version);
} else if (target.name == "fabric") {
components->setComponentVersion("net.fabricmc.fabric-loader", target.version);
} else if (target.name == "neoforge") {
components->setComponentVersion("net.neoforged.neoforge", target.version);
}
}

View File

@ -55,7 +55,7 @@ class ModrinthAPI : public NetworkModAPI {
static auto getModLoaderStrings(const ModLoaderTypes types) -> const QStringList
{
QStringList l;
for (auto loader : {Forge, Fabric, Quilt})
for (auto loader : {Forge, NeoForge, Fabric, Quilt})
{
if ((types & loader) || types == Unspecified)
{
@ -81,7 +81,7 @@ class ModrinthAPI : public NetworkModAPI {
inline auto getModSearchURL(SearchArgs& args) const -> QString override
{
if (!validateModLoaders(args.loaders)) {
qWarning() << "Modrinth only have Forge and Fabric-compatible mods!";
qWarning() << "Modrinth only have Forge, NeoForge and Fabric-compatible mods!";
return "";
}
@ -132,7 +132,7 @@ class ModrinthAPI : public NetworkModAPI {
inline auto validateModLoaders(ModLoaderTypes loaders) const -> bool
{
return (loaders == Unspecified) || (loaders & (Forge | Fabric | Quilt));
return (loaders == Unspecified) || (loaders & (Forge | NeoForge | Fabric | Quilt));
}
};

View File

@ -108,7 +108,7 @@ void ModrinthCheckUpdate::executeTask()
// Sometimes a version may have multiple files, one with "forge" and one with "fabric",
// so we may want to filter it
QString loader_filter;
static auto flags = { ModAPI::ModLoaderType::Forge, ModAPI::ModLoaderType::Fabric, ModAPI::ModLoaderType::Quilt };
static auto flags = { ModAPI::ModLoaderType::Forge, ModAPI::ModLoaderType::NeoForge, ModAPI::ModLoaderType::Fabric, ModAPI::ModLoaderType::Quilt };
for (auto flag : flags) {
if (m_loaders.testFlag(flag)) {
loader_filter = api.getModLoaderString(flag);

View File

@ -215,6 +215,8 @@ bool ModrinthCreationTask::createInstance()
components->setComponentVersion("org.quiltmc.quilt-loader", quiltVersion);
if (!forgeVersion.isEmpty())
components->setComponentVersion("net.minecraftforge", forgeVersion);
if (!neoforgeVersion.isEmpty())
components->setComponentVersion("net.neoforged.neoforge", neoforgeVersion);
if (m_instIcon != "default") {
instance.setIconKey(m_instIcon);
@ -385,6 +387,8 @@ bool ModrinthCreationTask::parseManifest(const QString& index_path, std::vector<
quiltVersion = Json::requireString(*it, "Quilt Loader version");
} else if (name == "forge") {
forgeVersion = Json::requireString(*it, "Forge version");
} else if (name == "neoforge") {
neoforgeVersion = Json::requireString(*it, "NeoForge version");
} else {
throw JSONValidationError("Unknown dependency type: " + name);
}

View File

@ -33,7 +33,7 @@ class ModrinthCreationTask final : public InstanceCreationTask {
private:
QWidget* m_parent = nullptr;
QString minecraftVersion, fabricVersion, quiltVersion, forgeVersion;
QString minecraftVersion, fabricVersion, quiltVersion, forgeVersion, neoforgeVersion;
QString m_managed_id, m_managed_version_id, m_managed_name;
QString m_source_url;

View File

@ -240,6 +240,9 @@ void VersionPage::updateVersionControls()
ui->actionInstall_Forge->setEnabled(controlsEnabled);
bool supportsNeoForge = minecraftVersion >= Version("1.20.1");
ui->actionInstall_NeoForge->setEnabled(controlsEnabled && supportsNeoForge);
bool supportsFabric = minecraftVersion >= Version("1.14");
ui->actionInstall_Fabric->setEnabled(controlsEnabled && supportsFabric);
@ -464,6 +467,35 @@ void VersionPage::on_actionInstall_Forge_triggered()
}
}
void VersionPage::on_actionInstall_NeoForge_triggered()
{
auto vlist = APPLICATION->metadataIndex()->get("net.neoforged.neoforge");
if(!vlist)
{
return;
}
VersionSelectDialog vselect(vlist.get(), tr("Select NeoForge version"), this);
vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft"));
vselect.setEmptyString(tr("No NeoForge versions are currently available for Minecraft ") + m_profile->getComponentVersion("net.minecraft"));
vselect.setEmptyErrorString(tr("Couldn't load or download the NeoForge version lists!"));
auto currentVersion = m_profile->getComponentVersion("net.neoforged.neoforge");
if(!currentVersion.isEmpty())
{
vselect.setCurrentVersion(currentVersion);
}
if (vselect.exec() && vselect.selectedVersion())
{
auto vsn = vselect.selectedVersion();
m_profile->setComponentVersion("net.neoforged.neoforge", vsn->descriptor());
m_profile->resolve(Net::Mode::Online);
// m_profile->installVersion();
preselect(m_profile->rowCount(QModelIndex())-1);
m_container->refreshContainer();
}
}
void VersionPage::on_actionInstall_Fabric_triggered()
{
auto vlist = APPLICATION->metadataIndex()->get("net.fabricmc.fabric-loader");

View File

@ -72,6 +72,7 @@ public:
private slots:
void on_actionChange_version_triggered();
void on_actionInstall_Forge_triggered();
void on_actionInstall_NeoForge_triggered();
void on_actionInstall_Fabric_triggered();
void on_actionInstall_Quilt_triggered();
void on_actionAdd_Empty_triggered();

View File

@ -106,6 +106,7 @@
<addaction name="actionRevert"/>
<addaction name="separator"/>
<addaction name="actionInstall_Forge"/>
<addaction name="actionInstall_NeoForge"/>
<addaction name="actionInstall_Fabric"/>
<addaction name="actionInstall_Quilt"/>
<addaction name="actionInstall_LiteLoader"/>
@ -185,6 +186,14 @@
<string>Install the Minecraft Forge package.</string>
</property>
</action>
<action name="actionInstall_NeoForge">
<property name="text">
<string>Install NeoForge</string>
</property>
<property name="toolTip">
<string>Install the NeoForge package.</string>
</property>
</action>
<action name="actionInstall_Fabric">
<property name="text">
<string>Install Fabric</string>

View File

@ -64,6 +64,7 @@ VanillaPage::VanillaPage(NewInstanceDialog *dialog, QWidget *parent)
connect(ui->loaderVersionList, &VersionSelectWidget::selectedVersionChanged, this, &VanillaPage::setSelectedLoaderVersion);
connect(ui->noneFilter, &QRadioButton::toggled, this, &VanillaPage::loaderFilterChanged);
connect(ui->forgeFilter, &QRadioButton::toggled, this, &VanillaPage::loaderFilterChanged);
connect(ui->neoForgeFilter, &QRadioButton::toggled, this, &VanillaPage::loaderFilterChanged);
connect(ui->fabricFilter, &QRadioButton::toggled, this, &VanillaPage::loaderFilterChanged);
connect(ui->quiltFilter, &QRadioButton::toggled, this, &VanillaPage::loaderFilterChanged);
connect(ui->liteLoaderFilter, &QRadioButton::toggled, this, &VanillaPage::loaderFilterChanged);
@ -142,6 +143,11 @@ void VanillaPage::loaderFilterChanged()
ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, minecraftVersion);
m_selectedLoader = "net.minecraftforge";
}
else if(ui->neoForgeFilter->isChecked())
{
ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, minecraftVersion);
m_selectedLoader = "net.neoforged.neoforge";
}
else if(ui->fabricFilter->isChecked())
{
// FIXME: dirty hack because the launcher is unaware of Fabric's dependencies

View File

@ -204,6 +204,16 @@
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="neoForgeFilter">
<property name="text">
<string>NeoForge</string>
</property>
<attribute name="buttonGroup">
<string notr="true">loaderBtnGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="fabricFilter">
<property name="text">

84
nix/default.nix Normal file
View File

@ -0,0 +1,84 @@
{ stdenv
, lib
, symlinkJoin
, addOpenGLRunpath
, polymc-unwrapped
, wrapQtAppsHook
, jdk8
, jdk17
, jdk21
, xorg
, gamemode
, glxinfo
, libpulseaudio
, qtbase
, libGL
, glfw
, openal
, udev
, wayland
, qtwayland
, msaClientID ? ""
, jdks ? [ jdk21 jdk17 jdk8 ]
, enableLTO ? false
, gamemodeSupport ? stdenv.isLinux
, additionalLibs ? [ ]
, additionalBins ? [ ]
, self
, version
# flake
}:
let
polymcInner = polymc-unwrapped.override { inherit msaClientID enableLTO gamemodeSupport; };
in
symlinkJoin {
name = "polymc";
inherit version;
paths = [ polymcInner ];
nativeBuildInputs = [ wrapQtAppsHook ];
buildInputs = [ qtbase qtwayland ];
postBuild = ''
wrapQtAppsHook
'';
qtWrapperArgs =
let
runtimeLibs = (with xorg; [
libX11
libXext
libXcursor
libXrandr
libXxf86vm
]) ++
# lwjgl
[
libpulseaudio
libGL
glfw
openal
stdenv.cc.cc.lib
udev # OSHI
wayland
]
++ lib.optional gamemodeSupport gamemode.lib
++ additionalLibs;
runtimeBins = [
# Required by old LWJGL versions
xorg.xrandr
glxinfo
] ++ additionalBins;
in
[
"--prefix POLYMC_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}"
"--set LD_LIBRARY_PATH ${addOpenGLRunpath.driverLink}/lib:${lib.makeLibraryPath runtimeLibs}"
"--prefix PATH : ${lib.makeBinPath runtimeBins}"
];
inherit (polymcInner) meta;
}

73
nix/unwrapped.nix Normal file
View File

@ -0,0 +1,73 @@
{ stdenv
, lib
, cmake
, ninja
, jdk8
, gamemode
, ghc_filesystem
, zlib
, file
, qtbase
, quazip
, extra-cmake-modules
, qtcharts
, qtwayland
# flake
, self
, version
, libnbtplusplus
, tomlplusplus
, msaClientID ? ""
, gamemodeSupport ? stdenv.isLinux
, enableLTO ? false
}:
stdenv.mkDerivation {
pname = "polymc-unwrapped";
inherit version;
src = lib.cleanSource self;
nativeBuildInputs = [ cmake extra-cmake-modules ninja jdk8 ghc_filesystem file ];
buildInputs = [ qtbase quazip zlib qtcharts ]
++ lib.optional (lib.versionAtLeast qtbase.version "6") qtwayland
++ lib.optional gamemodeSupport gamemode;
postUnpack = ''
# Copy libnbtplusplus
rm -rf source/libraries/libnbtplusplus
mkdir source/libraries/libnbtplusplus
cp -a ${libnbtplusplus}/* source/libraries/libnbtplusplus
chmod a+r+w source/libraries/libnbtplusplus/*
# Copy tomlplusplus
rm -rf source/libraries/tomlplusplus
mkdir source/libraries/tomlplusplus
cp -a ${tomlplusplus}/* source/libraries/tomlplusplus
chmod a+r+w source/libraries/tomlplusplus/*
'';
dontWrapQtApps = true;
cmakeFlags = [
"-GNinja"
"-DLauncher_QT_VERSION_MAJOR=${lib.versions.major qtbase.version}"
"-DLauncher_BUILD_PLATFORM=nix"
]
++ lib.optionals enableLTO [ "-DENABLE_LTO=on" ]
++ lib.optionals (msaClientID != "") [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ];
meta = with lib; {
homepage = "https://polymc.org/";
downloadPage = "https://polymc.org/download/";
changelog = "https://github.com/PolyMC/PolyMC/releases";
description = "A free, open source launcher for Minecraft";
longDescription = ''
Allows you to have multiple, separate instances of Minecraft (each with
their own mods, texture packs, saves, etc) and helps you manage them and
their associated options with a simple interface.
'';
platforms = platforms.unix;
license = licenses.gpl3Only;
maintainers = with maintainers; [ starcraft66 kloenk ];
};
}