Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.sinytra.adapter.patch.resolver.special;

import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.*;
import org.sinytra.adapter.patch.config.Configurations;
import org.sinytra.adapter.env.ctx.MixinContext;
Expand Down Expand Up @@ -58,6 +59,15 @@ public ResolutionResult resolve(MixinContext context, Recipe recipe) {
if (cleanMatcher.test(dirtyMatcher)) {
// ModifyExpressionValue doesn't include the original instanceof call, so we can skip comparing instructions
if (this.skipInsnComparison) {
// Only convert to @ModifyInstanceofValue if the handler returns boolean.
// If it returns a non-boolean type (e.g. Block), the mixin is modifying the
// value fed into the instanceof check, not the boolean result of it.
// Converting in that case produces an invalid (Block)Block handler where (Z)Z is expected.
Type handlerReturnType = Type.getReturnType(context.methodNode().desc);
if (!handlerReturnType.equals(Type.BOOLEAN_TYPE)) {
return ResolutionResult.pass();
}

TypeInsnNode instanceOfInsn = (TypeInsnNode) findLabelInsns(insn).stream().filter(i -> i.getOpcode() == Opcodes.INSTANCEOF).findFirst().orElse(null);
if (instanceOfInsn == null) {
return ResolutionResult.pass();
Expand Down