Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

A slim launcher for Minecraft in the development environment.

## Requirements (Delete on Release)

- The ability to launch Minecraft paired with ForgeGradle 7.
- Down the road, we will want to be able to launch versions of Minecraft that use Java 8, old Bootstrap, and old FML.

## Purpose

SlimeLauncher is a standalone tool that allows users to launch Minecraft without needing to interface with the standard
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/net/minecraftforge/launcher/FG2Hacks.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

import org.jetbrains.annotations.Nullable;

class FG2Hacks {
final class FG2Hacks {
private FG2Hacks() {}

/* ----------- COREMOD AND AT HACK --------- */
// coremod hack
private static final String COREMOD_VAR = "fml.coreMods.load";
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/net/minecraftforge/launcher/LegacyDev.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@

/// This is the SlimeLauncher replacement for [LegacyDev](https://github.com/MinecraftForge/LegacyDev/).
/// Which was written to Bridge 1.12.2 to FG3+
class LegacyDev {
final class LegacyDev {
private LegacyDev() {}

static final Logger LOGGER = Main.LOGGER;
static final String LEGACYDEV = "net.minecraftforge.legacydev.";
static final String LEGACYDEV_CLIENT = LEGACYDEV + "MainClient";
Expand Down
46 changes: 6 additions & 40 deletions src/main/java/net/minecraftforge/launcher/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,14 @@

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Locale;
import java.util.function.Supplier;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public final class Main {
static final Logger LOGGER = Logger.create();
Expand Down Expand Up @@ -82,8 +78,8 @@ private static Launcher run(String[] rawArgs) throws Throwable {
.withRequiredArg().ofType(String.class).defaultsTo(Constants.RESOURCES_URL);

// metadata
ArgumentAcceptingOptionSpec<File> metadataZip0 = parser
.accepts("metadata", "The metadata.zip to use for runs")
ArgumentAcceptingOptionSpec<File> metadataO = parser
.accepts("metadata", "The metadata directory to use for runs")
.withRequiredArg().ofType(File.class);

// main
Expand Down Expand Up @@ -121,8 +117,7 @@ private static Launcher run(String[] rawArgs) throws Throwable {
File cache = options.valueOf(cache0);
File assets = options.valueOf(assetsO);
String assetsRepo = options.valueOf(assetsRepo0);
// TODO [SlimeLauncher][Jonathing] CHANGE THIS TO DIR! It is already extracted by FG7!
File metadataZip = options.valueOf(metadataZip0);
File metadata = options.valueOf(metadataO);
String mainClass = options.valueOf(mainClassO);
File toObf = options.valueOf(toObfO);
File toSrg = options.valueOf(toSrgO);
Expand All @@ -143,11 +138,9 @@ else if (isUserDev) { // This is only used for 1.14->1.16, and only ever targete
}

MinecraftVersion versionJson;
try (ZipFile zip = new ZipFile(metadataZip)) {
versionJson = JsonData.minecraftVersion(
extract(zip, "minecraft/version.json", cache)
);
}
File versionJsonFile = new File(metadata, "minecraft/version.json");
if (versionJsonFile.isFile()) versionJson = JsonData.minecraftVersion(versionJsonFile);
else throw new FileNotFoundException("Missing minecraft/version.json in " + metadata.getAbsolutePath());

if (isClient) {
DownloadAssets.checkAssets(assetsRepo, assets, versionJson, DISABLE_ASSETS);
Expand Down Expand Up @@ -302,31 +295,4 @@ private SplitArgs(String[] args) {
}
}
}

private static File extract(ZipFile zip, String name, File cache) throws IOException {
File metadataDir = new File(cache, "metadata");
if (!metadataDir.exists() && !metadataDir.mkdirs())
throw new IllegalStateException("Failed to create directory: " + metadataDir.getAbsolutePath());

ZipEntry entry = zip.getEntry(name);
if (entry == null)
throw new FileNotFoundException("Missing " + name + " in " + zip.getName());

File output = new File(metadataDir, name);
File outputDir = output.getParentFile();
if (!outputDir.exists() && !outputDir.mkdirs())
throw new IllegalStateException("Failed to create directory: " + outputDir.getAbsolutePath());

// InputStream#transferTo(OutputStream)
try (FileOutputStream out = new FileOutputStream(output)) {
InputStream stream = zip.getInputStream(entry);
byte[] buf = new byte[8192];
int length;
while ((length = stream.read(buf)) != -1) {
out.write(buf, 0, length);
}
}

return output;
}
}