forked from Chocohead/OptiFabric
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Fabric API 0.86.0+ (Chocohead#1179 port)
- Loading branch information
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/me/modmuss50/optifabric/compat/fix/ModelLoaderBakerImplFixer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package me.modmuss50.optifabric.compat.fix; | ||
|
||
import me.modmuss50.optifabric.util.RemappingUtils; | ||
import org.objectweb.asm.tree.AnnotationNode; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.objectweb.asm.tree.MethodNode; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo; | ||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo; | ||
import org.spongepowered.asm.util.Annotations; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import static me.modmuss50.optifabric.compat.fix.ModMixinFixer.addParams; | ||
|
||
public class ModelLoaderBakerImplFixer implements IMixinFixer { | ||
@Override | ||
public List<String> getTargets() { | ||
return Collections.singletonList("net/fabricmc/fabric/mixin/client/model/loading/ModelLoaderBakerImplMixin"); | ||
} | ||
|
||
@Override | ||
public void fix(IMixinInfo mixinInfo, ClassNode mixinNode) { | ||
for (MethodNode method : mixinNode.methods) { | ||
List<String> injectMethod = new ArrayList<>(); | ||
String bakeDesc = RemappingUtils.mapMethodDescriptor("(Lnet/minecraft/class_2960;Lnet/minecraft/class_3665;Ljava/util/function/Function;)Lnet/minecraft/class_1087;"); | ||
injectMethod.add('L' + RemappingUtils.getClassName("class_1088$class_7778") + ";bake" + bakeDesc); //optifine method | ||
AnnotationNode annotation; | ||
switch (method.name) { | ||
case "invokeModifyBeforeBake": | ||
addParams(method, mixinInfo, "Ljava/util/function/Function;"); | ||
//no break is intentional | ||
case "invokeModifyAfterBake": | ||
annotation = InjectionInfo.getInjectorAnnotation(mixinInfo, method); | ||
Annotations.setValue(annotation, "method", injectMethod); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public boolean shouldUpdateClassInfo() { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters