Skip to content

Commit

Permalink
Remove mixin type filter in constant target
Browse files Browse the repository at this point in the history
  • Loading branch information
Su5eD committed Jun 4, 2024
1 parent bc5d2af commit d329749
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions definition/src/main/java/org/sinytra/adapter/patch/api/Patch.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.sinytra.adapter.patch.transformer.param.TransformParameters;

import java.util.List;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Predicate;
Expand Down Expand Up @@ -107,17 +106,15 @@ default ClassPatchBuilder targetInjectionPoint(String target) {
ClassPatchBuilder targetInjectionPoint(String value, String target);

default ClassPatchBuilder targetConstant(double doubleValue) {
return targetMixinType(MixinConstants.MODIFY_CONST, MixinConstants.MODIFY_EXPR_VAL)
.targetAnnotationValues(handle -> handle.getNested("constant")
.flatMap(cst -> cst.<Double>getValue("doubleValue")
.map(val -> val.get() == doubleValue))
.orElseGet(() -> handle.getNested("at")
.flatMap(at -> {
Optional<String> value = at.<String>getValue("value").map(AnnotationValueHandle::get);
Optional<List<String>> target = at.<List<String>>getValue("args").map(AnnotationValueHandle::get);
return value.map(s -> s.equals("CONSTANT") && target.map(t -> t.size() == 1 && t.get(0).equals("doubleValue=" + doubleValue + "D")).orElse(false));
})
.orElse(false)));
return targetAnnotationValues(handle -> handle.getNested("constant")
.flatMap(cst -> cst.<Double>getValue("doubleValue")
.map(val -> val.get() == doubleValue))
.orElseGet(() -> handle.getNested("at")
.flatMap(at -> at.<String>getValue("value").map(s -> s.get().equals("CONSTANT") &&
at.<List<String>>getValue("args").map(AnnotationValueHandle::get).map(t -> t.size() == 1
&& (t.get(0).equals("doubleValue=" + doubleValue + "D") || t.get(0).equals("doubleValue=" + doubleValue)))
.orElse(false)))
.orElse(false)));
}

default ClassPatchBuilder modifyInjectionPoint(String value, String target) {
Expand All @@ -131,11 +128,11 @@ default ClassPatchBuilder modifyInjectionPoint(String value, String target) {
default ClassPatchBuilder modifyInjectionPoint(String target) {
return modifyInjectionPoint(null, target);
}

ClassPatchBuilder redirectShadowMethod(String original, String target, BiConsumer<MethodInsnNode, InsnList> callFixer);

ClassPatchBuilder divertRedirector(Consumer<InstructionAdapter> patcher);

ClassPatchBuilder updateRedirectTarget(String originalTarget, String newTarget);

ClassPatchBuilder disable();
Expand Down

0 comments on commit d329749

Please sign in to comment.