Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Commit

Permalink
Added class export option
Browse files Browse the repository at this point in the history
  • Loading branch information
modmuss50 committed May 30, 2019
1 parent 842703d commit 6206ab3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ __Note:__ This project does not contain Optifine, you must download it separatel

## Installing

After installing fabric for 1.14, you will need to place the OptiFabric mod jar as well as the optifine installer in the mods folder.
After installing fabric for 1.14.2, you will need to place the OptiFabric mod jar as well as the optifine installer in the mods folder.

Fabric Loader should be the latest version from the [Fabric Website](https://fabricmc.net/use/)

If you are using Fabric API version 0.2.7 is recommended, you can download it from [here](https://minecraft.curseforge.com/projects/fabric/files/2702281). Newer (0.3.0+) versions may have issues with shaders, a fix is being worked on.
There are some known issues with FabricAPI such as shaders not working, and issues with water. These issues are being looked into.

## Links

### [OptiFabric Downloads](https://minecraft.curseforge.com/projects/optifabric)

### [Optifine Download](https://optifine.net/downloads) (current 1.14 builds are under the preview section)
### [Optifine Download](https://optifine.net/downloads) (current 1.14.2 builds are under the preview section)

## Issues

Expand All @@ -27,6 +27,14 @@ If you happen to find an issue and you believe it is to do with OptiFabric and n

Note Fabric, Optifine and OptiFabric are still all in beta, so things will be broken.

## For Mod Devs

Optifabric 0.2 and up will work in a mod dev environment. Just install OptiFabric and Optifine in the mods folder.

Class export can be enabled using the following VM Option, this will extract the overwritten classes to the .optifine folder, useful for debugging.

`-Doptifabric.extract=true`

## Screenshots

Feel free to open a PR with more screenshots.
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/me/modmuss50/optifabric/patcher/PatchSplitter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.modmuss50.optifabric.patcher;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.zeroturnaround.zip.ZipUtil;

Expand All @@ -14,6 +15,11 @@
public class PatchSplitter {

public static ClassCache generateClassCache(File inputFile, File classCacheOutput, byte[] inputHash) throws IOException {
boolean extractClasses = Boolean.parseBoolean(System.getProperty("optifabric.extract", "false"));
File classesDir = new File(classCacheOutput.getParent(), "classes");
if(extractClasses){
classesDir.mkdir();
}
ClassCache classCache = new ClassCache(inputHash);
try (JarFile jarFile = new JarFile(inputFile)) {
Enumeration<JarEntry> entrys = jarFile.entries();
Expand All @@ -24,6 +30,10 @@ public static ClassCache generateClassCache(File inputFile, File classCacheOutpu
String name = entry.getName();
byte[] bytes = IOUtils.toByteArray(inputStream);
classCache.addClass(name, bytes);
if(extractClasses){
File classFile = new File(classesDir, entry.getName());
FileUtils.writeByteArrayToFile(classFile, bytes);
}
}
}
}
Expand Down

0 comments on commit 6206ab3

Please sign in to comment.