Skip to content

Commit

Permalink
Revert "optifine mod metadata (borrowed from optibabric)"
Browse files Browse the repository at this point in the history
This reverts commit 590b6c1.
  • Loading branch information
tildejustin committed Dec 16, 2023
1 parent 590b6c1 commit 4ed0fc4
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 336 deletions.

This file was deleted.

This file was deleted.

22 changes: 0 additions & 22 deletions src/main/java/me/modmuss50/optifabric/metadata/OptifineIcon.java

This file was deleted.

106 changes: 0 additions & 106 deletions src/main/java/me/modmuss50/optifabric/metadata/OptifineMetadata.java

This file was deleted.

20 changes: 0 additions & 20 deletions src/main/java/me/modmuss50/optifabric/metadata/OptifineOrigin.java

This file was deleted.

21 changes: 0 additions & 21 deletions src/main/java/me/modmuss50/optifabric/metadata/OptifinePerson.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import com.chocohead.mm.api.ClassTinkerers;
import me.modmuss50.optifabric.Pair;
import me.modmuss50.optifabric.metadata.OptifineContainer;
import me.modmuss50.optifabric.patcher.ClassCache;
import net.fabricmc.loader.api.*;
import net.fabricmc.loader.api.metadata.ModMetadata;
import net.fabricmc.loader.impl.FabricLoaderImpl;

import java.io.File;
import java.util.*;
Expand All @@ -31,13 +29,6 @@ public void run() {
injector.setup();

optifineRuntimeJar = runtime.left();

try {
//noinspection unchecked
((List<ModContainer>) (List<? extends ModContainer>) FabricLoaderImpl.InitHelper.get().getModsInternal()).add(new OptifineContainer(runtime.left().toPath(), Version.parse(OptifineVersion.version)));
} catch (VersionParsingException e) {
throw new RuntimeException(e);
}
} catch (Throwable e) {
if (!Optifabric.hasError()) {
OptifineVersion.jarType = OptifineVersion.JarType.INCOMPATIBLE;
Expand Down
69 changes: 7 additions & 62 deletions src/main/java/me/modmuss50/optifabric/mod/OptifineSetup.java
Original file line number Diff line number Diff line change
@@ -1,37 +1,18 @@
package me.modmuss50.optifabric.mod;

import me.modmuss50.optifabric.IOUtils;
import me.modmuss50.optifabric.Pair;
import me.modmuss50.optifabric.metadata.OptifineIcon;
import me.modmuss50.optifabric.patcher.ClassCache;
import me.modmuss50.optifabric.patcher.LambdaRebuilder;
import me.modmuss50.optifabric.patcher.PatchSplitter;
import me.modmuss50.optifabric.patcher.RemapUtils;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.fabricmc.loader.impl.launch.FabricLauncherBase;
import net.fabricmc.loader.impl.launch.MappingConfiguration;
import me.modmuss50.optifabric.*;
import me.modmuss50.optifabric.patcher.*;
import net.fabricmc.loader.api.*;
import net.fabricmc.loader.impl.launch.*;
import net.fabricmc.loader.impl.lib.tinyremapper.IMappingProvider;
import net.fabricmc.loader.impl.util.mappings.TinyRemapperMappingsHelper;
import org.zeroturnaround.zip.ZipUtil;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.List;
import java.net.*;
import java.nio.file.*;
import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;

@SuppressWarnings("ResultOfMethodCallIgnored")
public class OptifineSetup {
Expand Down Expand Up @@ -62,41 +43,6 @@ private static Path getLaunchMinecraftJar() {
}
}

private static void addIcon(File zipFile) {
File tempFile;
tempFile = new File(zipFile.getName().replace(".jar", ".tmp"));
tempFile.delete();

boolean renameOk = zipFile.renameTo(tempFile);
if (!renameOk)
throw new RuntimeException("Could not rename the file " + zipFile.getAbsolutePath() + " to " + tempFile.getAbsolutePath());
byte[] buf = new byte[1024];

try (ZipOutputStream out = new ZipOutputStream(Files.newOutputStream(zipFile.toPath()))) {
try (ZipInputStream zin = new ZipInputStream(Files.newInputStream(tempFile.toPath()))) {
ZipEntry entry = zin.getNextEntry();
while (entry != null) {
String name = entry.getName();
out.putNextEntry(new ZipEntry(name));
int len;
while ((len = zin.read(buf)) > 0)
out.write(buf, 0, len);
entry = zin.getNextEntry();
}
}
try (InputStream in = new ByteArrayInputStream(Base64.getDecoder().decode(OptifineIcon.DATA))) {
out.putNextEntry(new ZipEntry("assets/optifine/icon.png"));
int len;
while ((len = in.read(buf)) > 0)
out.write(buf, 0, len);
out.closeEntry();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
tempFile.delete();
}

public Pair<File, ClassCache> getRuntime() throws Throwable {
if (!workingDir.exists()) {
workingDir.mkdirs();
Expand Down Expand Up @@ -164,7 +110,6 @@ public Pair<File, ClassCache> getRuntime() throws Throwable {
RemapUtils.mapJar(lambdaFixJar.toPath(), jarOfTheFree.toPath(), rebuilder, this.getLibs());

this.remapOptifine(lambdaFixJar.toPath(), remappedJar.toPath());
OptifineSetup.addIcon(remappedJar);

classCache = PatchSplitter.generateClassCache(remappedJar, optifinePatches, modHash);

Expand Down
1 change: 0 additions & 1 deletion src/main/resources/assets/optifabric/optifine_icon

This file was deleted.

0 comments on commit 4ed0fc4

Please sign in to comment.