From 29002341e166c7ff59e8a08c9386b732284edc9f Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Sat, 4 Apr 2026 22:19:49 +0200 Subject: [PATCH 1/9] Implement simple modrinth search #4 --- src/lib/saturn.ts | 59 ++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/src/lib/saturn.ts b/src/lib/saturn.ts index 58f28cb..47609dc 100644 --- a/src/lib/saturn.ts +++ b/src/lib/saturn.ts @@ -11,40 +11,35 @@ export async function toggleMod(modId: string): Promise { } export async function discoverMods(query: string): Promise { - const allDiscoverable: Mod[] = [ - { - id: "modmenu", - name: "Mod Menu", - version: "7.2.2", - author: "TerraformersMC", - description: "Adds a mod menu to view the list of installed mods.", - enabled: false, - supported_versions: ["1.20.1", "1.20.4", "1.21"], - }, - { - id: "starlight", - name: "Starlight", - version: "1.1.2", - author: "Spottedleaf", - description: "Rewrites the light engine to fix performance issues.", - enabled: false, - supported_versions: ["1.20.1"], - }, - { - id: "ferritecore", - name: "FerriteCore", - version: "6.0.1", - author: "malte0811", - description: "Memory usage optimizations.", - enabled: false, - supported_versions: ["1.20.1", "1.20.4", "1.21"], - }, - ]; + const url = new URL("https://api.modrinth.com/v2/search"); - if (!query) return allDiscoverable; + if (query) { + url.searchParams.set("query", query); + } - return allDiscoverable.filter((m) => - m.name.toLowerCase().includes(query.toLowerCase()), + // Optional but recommended filters + url.searchParams.set("facets", JSON.stringify([["project_type:mod"]])); + url.searchParams.set("limit", "20"); + + const res = await fetch(url.toString()); + + if (!res.ok) { + throw new Error("Failed to fetch mods from Modrinth"); + } + + const data = await res.json(); + + return data.hits.map( + (mod: any): Mod => ({ + id: mod.project_id, + name: mod.title, + version: "latest", + author: mod.author, + description: mod.description, + enabled: false, + icon: mod.icon_url, + supported_versions: mod.versions || [], + }), ); } From bd4897e3ff8899d397ee5cbd3706c20ef91d6994 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Sat, 4 Apr 2026 22:22:15 +0200 Subject: [PATCH 2/9] Search fix --- src/components/ModsSection.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/ModsSection.tsx b/src/components/ModsSection.tsx index 1431e79..b301a12 100644 --- a/src/components/ModsSection.tsx +++ b/src/components/ModsSection.tsx @@ -48,7 +48,10 @@ const ModsSection: React.FC = ({ version }) => { setMods(m); } else { const m = await discoverMods(searchQuery); - setMods(m); + if (activeTab === "discover") { + // Fix: If discover mods takes too long and the user switches tabs it glitches + setMods(m); + } } }; loadMods(); From 67d8b9e36571cf2be8fccad2371ed53ffa1e96b6 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Sat, 4 Apr 2026 22:23:34 +0200 Subject: [PATCH 3/9] Search delay --- src/components/ModsSection.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/ModsSection.tsx b/src/components/ModsSection.tsx index b301a12..f323cce 100644 --- a/src/components/ModsSection.tsx +++ b/src/components/ModsSection.tsx @@ -54,7 +54,10 @@ const ModsSection: React.FC = ({ version }) => { } } }; - loadMods(); + + const id = setTimeout(loadMods, 800); + + return () => clearTimeout(id); }, [activeTab, version.id, searchQuery]); const handleToggleMod = async (modId: string) => { From 0fe65f51a797afad323e70c27e04f263a726bd37 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Sat, 4 Apr 2026 22:34:39 +0200 Subject: [PATCH 4/9] Removed JVM args --- src-tauri/src/launcher/mod.rs | 8 +++-- src-tauri/src/lib.rs | 7 +--- src/components/SettingsSection.tsx | 53 +----------------------------- src/lib/types.ts | 1 - 4 files changed, 8 insertions(+), 61 deletions(-) diff --git a/src-tauri/src/launcher/mod.rs b/src-tauri/src/launcher/mod.rs index 4b424b4..4b27879 100644 --- a/src-tauri/src/launcher/mod.rs +++ b/src-tauri/src/launcher/mod.rs @@ -13,9 +13,9 @@ use lyceris::{ }, }; use once_cell::sync::Lazy; -use tauri::Emitter as _; +use tauri::{Emitter as _, State}; -use crate::GameVersion; +use crate::{GameVersion, SharedState}; pub static LAUNCHER_DIR: Lazy = Lazy::new(|| { ProjectDirs::from("org", "SaturnLauncher", "SaturnLauncher") @@ -25,6 +25,7 @@ pub static LAUNCHER_DIR: Lazy = Lazy::new(|| { #[tauri::command] pub async fn launch_game( app: tauri::AppHandle, + state: State<'_, SharedState>, version: GameVersion, account: MinecraftAccount, ) -> Result<(), String> { @@ -83,6 +84,9 @@ pub async fn launch_game( }, ) .loader(Fabric(version.loader_version).into()) + .memory(lyceris::minecraft::config::Memory::Megabyte( + state.lock().unwrap().settings.max_memory as u64, + )) .build(); println!("Starting installation"); diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index ff5c48e..fc60075 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -30,7 +30,6 @@ pub struct GameVersion { #[derive(Clone, Serialize, Deserialize)] pub struct LauncherSettings { - pub jvm_arguments: String, pub max_memory: u32, } @@ -44,11 +43,7 @@ pub struct AppState { impl Default for AppState { fn default() -> Self { Self { - settings: LauncherSettings { - jvm_arguments: "-XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200" - .into(), - max_memory: 4096, - }, + settings: LauncherSettings { max_memory: 4096 }, version: String::from("1.21.6"), } } diff --git a/src/components/SettingsSection.tsx b/src/components/SettingsSection.tsx index ba690f3..a43eb65 100644 --- a/src/components/SettingsSection.tsx +++ b/src/components/SettingsSection.tsx @@ -1,12 +1,5 @@ import React, { useState, useEffect } from "react"; -import { - Cpu, - MemoryStick, - Save, - RefreshCcw, - Info, - AlertTriangle, -} from "lucide-react"; +import { MemoryStick, Save, RefreshCcw, Info } from "lucide-react"; import { getSettings, updateSettings } from "../lib/saturn"; import { motion } from "framer-motion"; import { LauncherSettings } from "@/lib/types"; @@ -41,8 +34,6 @@ const SettingsSection: React.FC = () => { const handleReset = async () => { // In a real app, this would reset to defaults in the service const defaultSettings: LauncherSettings = { - jvm_arguments: - "-XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200", max_memory: 4096, }; setSettings(defaultSettings); @@ -142,48 +133,6 @@ const SettingsSection: React.FC = () => { - - {/* JVM Arguments */} - -
-
- -
-

Custom JVM Arguments

-
- -
-

- Advanced flags for the Java Virtual Machine. Saturn Client - includes optimized defaults, but you can override them here. -

- -