-
-
Notifications
You must be signed in to change notification settings - Fork 210
Open
Description
In the development environment, @ModifyVariable doesn't check that the arguments of the target method matches. (The return value may also not be checked, I haven't tested that.) For example:
@Mixin(ClickSlotC2SPacket.class)
public class ClickSlotC2SPacketMixin {
@ModifyVariable(method = "<init>(IIIILnet/minecraft/screen/slot/SlotActionType;Lnet/minecraft/item/ItemStack;Lit/unimi/dsi/fastutil/ints/Int2ObjectMap;)V", at = @At("HEAD"), ordinal = 3)
@Group(name = "<init>", min = 1)
private static int init_new(int button) {
System.out.println("New called");
return button;
}
// Note III instead of IIII
@ModifyVariable(method = "<init>(IIILnet/minecraft/class_1713;Lnet/minecraft/class_1799;Lit/unimi/dsi/fastutil/ints/Int2ObjectMap;)V", at = @At("HEAD"), ordinal = 2, remap = false)
@Group(name = "<init>", min = 1)
@SuppressWarnings("target")
private static int init_old(int button) {
System.out.println("Old called");
return button;
}
}
When running in Minecraft 1.20.6 with Fabric and Mixin version 0.8.5, both print statements are called, even though there isn't a constructor with 3 int arguments. This doesn't happen when running in either 1.17 or 1.20.6 outside of the development environment.
Since I haven't encountered any similar issues before, I assume that the fact that both named and intermediary yarn mappings use the same method name is what allows this to happen (or more specifically, both are <init>). Otherwise, the second @ModifyVariable would fail to find a target method.
Metadata
Metadata
Assignees
Labels
No labels