Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/QuestCraft' into QuestCraft
Browse files Browse the repository at this point in the history
  • Loading branch information
The Judge committed Dec 9, 2023
2 parents 8b1d8ae + 7e7e050 commit 08861fe
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 35 deletions.
24 changes: 12 additions & 12 deletions devmods.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"1.20.2": [
{
"slug": "Vivecraft",
"version": "1.0",
"download_link": "https://github.com/QuestCraftPlusPlus/VivecraftMod/releases/download/v1.0-1.20.2-LTS/vivecraft.jar"
"version": "1.1",
"download_link": "https://github.com/QuestCraftPlusPlus/VivecraftBuilder/releases/download/1.20.2/vivecraft.jar"
},
{
"slug": "Fabric-API",
Expand Down Expand Up @@ -79,13 +79,13 @@
"1.20.1": [
{
"slug": "Vivecraft",
"version": "1.0.2",
"download_link": "https://github.com/QuestCraftPlusPlus/VivecraftMod/releases/download/v1.0-1.20.1-LTS/vivecraft.jar"
"version": "1.1",
"download_link": "https://github.com/QuestCraftPlusPlus/VivecraftBuilder/releases/download/1.20.1/vivecraft.jar"
},
{
"slug": "Fabric-API",
"version": "0.87.0",
"download_link": "https://cdn.modrinth.com/data/P7dR8mSH/versions/lcnQpW9C/fabric-api-0.87.0%2B1.20.1.jar"
"version": "0.89.0",
"download_link": "https://cdn.modrinth.com/data/P7dR8mSH/versions/1sf8i9fy/fabric-api-0.89.0%2B1.20.1.jar"
},
{
"slug": "Lithium",
Expand Down Expand Up @@ -161,8 +161,8 @@
"1.19.4": [
{
"slug": "Vivecraft",
"version": "1.0.2",
"download_link": "https://github.com/QuestCraftPlusPlus/VivecraftMod/releases/download/v1.0-1.19.4-LTS/vivecraft.jar"
"version": "1.1",
"download_link": "https://github.com/QuestCraftPlusPlus/VivecraftBuilder/releases/download/1.19.4/vivecraft.jar"
},
{
"slug": "Fabric-API",
Expand Down Expand Up @@ -263,8 +263,8 @@
"1.19.2": [
{
"slug": "Vivecraft",
"version": "1.0.1",
"download_link": "https://github.com/QuestCraftPlusPlus/VivecraftMod/releases/download/v1.0-1.19-LTS/vivecraft.jar"
"version": "1.1.2",
"download_link": "https://github.com/QuestCraftPlusPlus/VivecraftBuilder/releases/download/1.19.2/vivecraft.jar"
},
{
"slug": "Fabric-API",
Expand Down Expand Up @@ -355,8 +355,8 @@
"1.18.2": [
{
"slug": "Vivecraft",
"version": "1.0.1",
"download_link": "https://github.com/QuestCraftPlusPlus/VivecraftMod/releases/download/v1.0-1.18.2-LTS/vivecraft.jar"
"version": "1.1.2",
"download_link": "https://github.com/QuestCraftPlusPlus/VivecraftBuilder/releases/download/1.18.2/vivecraft.jar"
},
{
"slug": "Fabric-API",
Expand Down
24 changes: 5 additions & 19 deletions lib/src/main/java/pojlib/api/API_V1.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class API_V1 {
public static String currentDownload;
public static String profileImage;
public static String profileName;
public static String memoryValue = "3072";
public static String memoryValue;
public static boolean developerMods;
public static MinecraftAccount currentAcc;
public static boolean advancedDebugger;
Expand Down Expand Up @@ -86,21 +86,6 @@ public static String getQCSupportedVersionName(MinecraftMeta.MinecraftVersion ve
return APIHandler.getQCSupportedVersionName(version);
}

/**
* A collection of loader types
*/
public enum ModLoader {
Vanilla(0),
Fabric(1),
Quilt(2);

public final int index;

ModLoader(int i) {
this.index = i;
}
}

/**
* Loads an instance from the filesystem.
*
Expand All @@ -119,17 +104,18 @@ public static MinecraftInstance load(String instanceName, String gameDir) {
* @param instanceName The name of the instance being created - can be anything, used for identification
* @param home The base directory where minecraft should be setup
* @param minecraftVersion The version of minecraft to install
* @param modLoader The mod loader to install
* @return A minecraft instance object
* @throws IOException Throws if download of library or asset fails
*/
public static MinecraftInstance createNewInstance(Activity activity, String instanceName, String home, MinecraftMeta.MinecraftVersion minecraftVersion) throws IOException {
public static MinecraftInstance createNewInstance(Activity activity, String instanceName, String home, MinecraftMeta.MinecraftVersion minecraftVersion, MinecraftInstance.ModLoader modLoader) throws IOException {

if(ignoreInstanceName) {
return MinecraftInstance.create(activity, instanceName, home, minecraftVersion);
return MinecraftInstance.create(activity, instanceName, home, minecraftVersion, modLoader);
} else if (instanceName.contains("/") || instanceName.contains("!")) {
throw new IOException("You cannot use special characters (!, /, ., etc) when creating instances.");
} else {
return MinecraftInstance.create(activity, instanceName, home, minecraftVersion);
return MinecraftInstance.create(activity, instanceName, home, minecraftVersion, modLoader);
}
}

Expand Down
36 changes: 32 additions & 4 deletions lib/src/main/java/pojlib/instance/MinecraftInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,54 @@ public class MinecraftInstance {
public String assetsDir;
public String mainClass;

public enum ModLoader {
Fabric(0),
Quilt(1),
Forge(2),
NeoForge(3);

public final int index;

ModLoader(int i) {
this.index = i;
}
}

//creates a new instance of a minecraft version, install game + mod loader, stores non login related launch info to json
public static MinecraftInstance create(Activity activity, String instanceName, String gameDir, MinecraftMeta.MinecraftVersion minecraftVersion) throws IOException {
public static MinecraftInstance create(Activity activity, String instanceName, String gameDir, MinecraftMeta.MinecraftVersion minecraftVersion, ModLoader modLoader) throws IOException {
Logger.getInstance().appendToLog("Creating new instance: " + instanceName);

MinecraftInstance instance = new MinecraftInstance();
instance.versionName = minecraftVersion.id;
instance.gameDir = new File(gameDir).getAbsolutePath();

VersionInfo modLoaderVersionInfo = null;
switch (modLoader) {
case Fabric: {
FabricMeta.FabricVersion fabricVersion = FabricMeta.getLatestStableVersion();
modLoaderVersionInfo = FabricMeta.getVersionInfo(fabricVersion, minecraftVersion);
}
case Quilt: {
QuiltMeta.QuiltVersion quiltVersion = QuiltMeta.getLatestVersion();
modLoaderVersionInfo = QuiltMeta.getVersionInfo(quiltVersion, minecraftVersion);
}
default: {
FabricMeta.FabricVersion fabricVersion = FabricMeta.getLatestStableVersion();
modLoaderVersionInfo = FabricMeta.getVersionInfo(fabricVersion, minecraftVersion);
}
}

VersionInfo minecraftVersionInfo = MinecraftMeta.getVersionInfo(minecraftVersion);
instance.versionType = minecraftVersionInfo.type;
FabricMeta.FabricVersion fabricVersion = FabricMeta.getLatestStableVersion();
VersionInfo modLoaderVersionInfo = FabricMeta.getVersionInfo(fabricVersion, minecraftVersion);
instance.mainClass = modLoaderVersionInfo.mainClass;

// Install minecraft
VersionInfo finalModLoaderVersionInfo = modLoaderVersionInfo;
new Thread(() -> {
try {
String clientClasspath = Installer.installClient(minecraftVersionInfo, gameDir);
String minecraftClasspath = Installer.installLibraries(minecraftVersionInfo, gameDir);
String modLoaderClasspath = Installer.installLibraries(modLoaderVersionInfo, gameDir);
String modLoaderClasspath = Installer.installLibraries(finalModLoaderVersionInfo, gameDir);
String lwjgl = Installer.installLwjgl(activity);

instance.classpath = clientClasspath + File.pathSeparator + minecraftClasspath + File.pathSeparator + modLoaderClasspath + File.pathSeparator + lwjgl;
Expand Down

0 comments on commit 08861fe

Please sign in to comment.