Mixin
Mixin copied to clipboard
Mixin refmap for accessors only uses name as key, should use descriptor as well
For an accessor mixin like below: (mixin 0.8, forge 1.15.2-31.1.18, mcp 20200308-1.15.1, mixingradle 0.7-SNAPSHOT)
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.Items;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(Items.class)
public interface TestAccessor {
@Invoker
static Item callRegister(Block blockIn) {
throw new AssertionError("Mixin dummy");
}
@Invoker("register")
static Item callAnotherRegister(Block blockIn, ItemGroup itemGroupIn) {
throw new AssertionError("Mixin dummy");
}
}
The java compile will fail with message as such:
error: Mapping conflict for @Invoker target register: func_221542_a(Lnet/minecraft/block/Block;Lnet/minecraft/item/ItemGroup;)Lnet/minecraft/item/Item; for target net.minecraft.item.Items conflicts with existing mapping func_221545_a(Lnet/minecraft/block/Block;)Lnet/minecraft/item/Item;
@Invoker("register")
^
Because mixin invoker targets are registered only by their names and disregards descriptors, there cannot be two invokers targeting two method having the same but different descriptors in a target class.
This is a bug, but only a minor one and can be easily bypassed with using multiple accessor mixin interfaces. I personally suggest start respecting method descriptors for accessor processing.