-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
53 additions
and
6 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
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
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
28 changes: 28 additions & 0 deletions
28
definition/src/main/java/org/sinytra/adapter/patch/transformer/SplitMixinTransform.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,28 @@ | ||
package org.sinytra.adapter.patch.transformer; | ||
|
||
import org.objectweb.asm.Type; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.objectweb.asm.tree.MethodNode; | ||
import org.sinytra.adapter.patch.api.*; | ||
|
||
import java.util.Collection; | ||
import java.util.Set; | ||
|
||
public record SplitMixinTransform(String targetClass) implements MethodTransform { | ||
|
||
@Override | ||
public Collection<String> getAcceptedAnnotations() { | ||
return Set.of(MixinConstants.WRAP_WITH_CONDITION, MixinConstants.WRAP_OPERATION, MixinConstants.MODIFY_CONST, MixinConstants.MODIFY_ARG, MixinConstants.INJECT, MixinConstants.REDIRECT, MixinConstants.MODIFY_VAR, MixinConstants.MODIFY_EXPR_VAL); | ||
} | ||
|
||
@Override | ||
public Patch.Result apply(ClassNode classNode, MethodNode methodNode, MethodContext methodContext, PatchContext context) { | ||
MethodTransform transform = new ExtractMixin(this.targetClass, false); | ||
Patch.Result result = transform.apply(classNode, methodNode, methodContext, context); | ||
if (methodContext.targetTypes().size() > 1) { | ||
MethodTransform removeTarget = new ModifyTargetClasses(l -> l.remove(Type.getObjectType(this.targetClass))); | ||
removeTarget.apply(classNode, methodNode, methodContext, context); | ||
} | ||
return result; | ||
} | ||
} |