Skip to content

Commit 7c0a406

Browse files
committed
Workarounds for 1.16.4 and for mojmaps
1 parent e2879bb commit 7c0a406

3 files changed

Lines changed: 36 additions & 3 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ buildscript {
1212
apply plugin: 'com.github.johnrengelman.shadow'
1313
apply plugin: 'java'
1414

15-
version = "2.2"
15+
version = "2.3"
1616
group = "ofdev" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
1717
archivesBaseName = "aa_do_not_rename_OptiFineDevTweaker"
1818

src/main/java/ofdev/modlauncher/OFDevTransformationService.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,13 @@ private static Path findObfMcJar(IEnvironment env) {
132132

133133
Class<?> newClass = makeNewOptiFineTransformer(oldTransformer.getClass().getClassLoader());
134134
Constructor<?> constr = newClass.getConstructor(ZipFile.class);
135-
Object newTransformer = constr.newInstance(ofZipFile);
136-
135+
Object newTransformer;
136+
try {
137+
newTransformer = constr.newInstance(ofZipFile);
138+
} catch (InvocationTargetException e) {
139+
constr = newClass.getConstructor(ZipFile.class, IEnvironment.class);
140+
newTransformer = constr.newInstance(ofZipFile, envIn);
141+
}
137142
transformerField.set(null, newTransformer);
138143

139144
LOGGER.info("Finding OptiFine AccessFixer");
@@ -236,6 +241,28 @@ public Test(ZipFile ofZipFile) {
236241

237242
cw.visitSource("OFDevTransformationService.java", null);
238243

244+
{
245+
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(Ljava/util/zip/ZipFile;Lcpw/mods/modlauncher/api/IEnvironment;)V", null, null);
246+
mv.visitCode();
247+
Label l0 = new Label();
248+
mv.visitLabel(l0);
249+
mv.visitLineNumber(10, l0);
250+
mv.visitVarInsn(ALOAD, 0);
251+
mv.visitVarInsn(ALOAD, 1);
252+
mv.visitVarInsn(ALOAD, 2);
253+
mv.visitMethodInsn(INVOKESPECIAL, "optifine/OptiFineTransformer", "<init>", "(Ljava/util/zip/ZipFile;Lcpw/mods/modlauncher/api/IEnvironment;)V", false);
254+
Label l1 = new Label();
255+
mv.visitLabel(l1);
256+
mv.visitLineNumber(11, l1);
257+
mv.visitInsn(RETURN);
258+
Label l2 = new Label();
259+
mv.visitLabel(l2);
260+
mv.visitLocalVariable("this", "L" + name + ";", null, l0, l2, 0);
261+
mv.visitLocalVariable("ofZipFile", "Ljava/util/zip/ZipFile;", null, l0, l2, 1);
262+
mv.visitLocalVariable("env", "Lcpw/mods/modlauncher/api/IEnvironment;", null, l0, l2, 2);
263+
mv.visitMaxs(3, 3);
264+
mv.visitEnd();
265+
}
239266
{
240267
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(Ljava/util/zip/ZipFile;)V", null, null);
241268
mv.visitCode();

src/main/java/ofdev/modlauncher/OfDevRemapper.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ public class OfDevRemapper extends Remapper {
1414
}
1515

1616
@Override public String mapMethodName(final String owner, final String name, final String descriptor) {
17+
if (owner.equals("net/minecraft/client/world/ClientWorld") && name.equals("onEntityRemoved")) {
18+
return "onEntityRemoved_OF";
19+
}
20+
if (owner.equals("net/minecraft/client/renderer/model/BakedQuad") && name.equals("getSprite")) {
21+
return "getSprite_OF";
22+
}
1723
return srg2mcp.apply(INameMappingService.Domain.METHOD, name);
1824
}
1925

0 commit comments

Comments
 (0)