Skip to content

Instantly share code, notes, and snippets.

@andrewathalye
Last active April 14, 2020 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewathalye/3a6b755ce3b16dc808d2f423fd79cdf4 to your computer and use it in GitHub Desktop.
Save andrewathalye/3a6b755ce3b16dc808d2f423fd79cdf4 to your computer and use it in GitHub Desktop.
In order to create this mod, first use the 1.15.2 version of yarn
$ git clone https://github.com/FabricMC/yarn/tree/1.15.2 && cd yarn-1.15.2
$ ./gradlew build
Next, use yarn-reverse to deobfuscate the client jar using the generated tiny mapping (official to named). The libraries necessary were taken from .gradle/minecraft in the yarn folder.
$ git clone https://github.com/andrewathalye/yarn-reverse
(note, this is just a small tool I put together myself. If you would like to use the included code from build.gradle in yarn yourself, it should also work, but it might take some extra configuration)
Next, decompile Minecraft using CFR (JD-GUI may work, but Minecraft recently has begun to target Java 1.8, so please be careful with lambdas etc.)
https://www.benf.org/other/cfr/
$ java -jar *CFR JAR* *DEOBFUSCATED MINECRAFT JAR* --outputdir src
Next, edit net/minecraft/client/render/GameRenderer.java
First remove all Nullable annotations if desired, or include findbugs in the libraries folder
Duplicate the call to this.renderWorld.
Add a 0 to the arguments for the first call
and a 1 to the arguments for the second.
Prepend the first call with
RenderSystem.colorMask(true, true, false, false);
Prepend the second with
RenderSystem.colorMask(false, false, true, false);
Add the following at the end of the calls
RenderSystem.colorMask(true, true, true, false);
The colour masks can be changed based upon the desired anaglyph.
Next, edit renderWorld():
Add an int "pass" to the end of the method arguments.
Next, after the call to camera.update, add
float angle=camera.getYaw();
angle-=360*((int)(angle/360));
if(angle > 0)
angle=360-angle;
else
angle=Math.abs(angle);
if(pass==0)
camera.setPos(Math.cos(Math.toRadians(angle))*0.07+camera.getPos().x,camera.getPos().y,Math.sin(Math.toRadians(angle))*-0.07+camera.getPos().z);
else
camera.setPos(Math.cos(Math.toRadians(angle))*-0.07+camera.getPos().x,camera.getPos().y,Math.sin(Math.toRadians(angle))*0.07+camera.getPos().z);
To convert to a jar mod:
Compile with javac (include in the classpath *only* the deobfuscated minecraft jar and the jars in the libraries folder)
$ mkdir tmp && cd tmp
$ jar xf *PATH TO DEOBFUSCATED MINECRAFT JAR*
$ cp *PATH TO COMPILED GameRenderer.class FILE*
$ jar cf mod-named.jar *
Run yarn-reverse to convert the named jar to an intermediary jar.
Run yarn-reverse to convert the intermediary jar to an official jar.
Note: Leave the tmp directory and copy / move the official jar out of it before continuing
$ rm -r tmp
$ mkdir tmp && cd tmp
$ jar xf *PATH TO OBFUSCATED (OFFICIAL) JAR FILE*
$ cat *PATH TO TINY MAPPING FILE* | grep GameRenderer
The last command should provide the obfuscated name for GameRenderer.
The final step:
$ jar cf anaglyph-mod.jar *OBFUSCATED NAME*.class
Hopefully these steps work for you :)
After creating the jar, this mod can be installed like an ordinary jar mod, or used in MultiMC for convenience.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment