MinecraftDev icon indicating copy to clipboard operation
MinecraftDev copied to clipboard

@ModifyConstant wrong autocomplete method parameters

Open thdaele opened this issue 1 year ago • 0 comments

Minecraft Development for IntelliJ plugin version

2023.3-1.7.2

IntelliJ version

IntelliJ IDEA 2023.3.3 (Ultimate Edition) Build #IU-233.14015.106

Operating System

Linux

Target platform

Mixins

Description of the bug

I get the following autocomplete method parameters with mcdev for this modifyConstant mixin.

@Mixin(MinecartEntity.class)
public class MinecartEntityMixin {
	@ModifyConstant(method = "moveOnRail", constant = @Constant(classValue = LivingEntity.class, ordinal = 0))
	private Class<? extends LivingEntity> mc64836(Class constant) {
		return PlayerEntity.class;
	}
}

When running the project I get the following error:

Mixin apply for mod bismuthserver failed mixins.bismuthserver.json:MinecartEntityMixin from mod bismuthserver -> net.minecraft.entity.vehicle.MinecartEntity: org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException @ModifyConstant instanceof handler method net/minecraft/entity/vehicle/MinecartEntity::mc64836 from mixins.bismuthserver.json:MinecartEntityMixin from mod bismuthserver has an invalid signature. Found unexpected argument type java.lang.Class at index 0, expected java.lang.Object. Handler signature: (Ljava/lang/Class;)Ljava/lang/Class; Expected signature: (Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Class; [ -> Inject -> mixins.bismuthserver.json:MinecartEntityMixin from mod bismuthserver->@ModifyConstant::mc64836(Ljava/lang/Class;)Ljava/lang/Class;]

The correct method parameters for this mixin are the following and mcdev suggest that they are wrong, but running with these method parameters doesn't result in a runtime error.

@Mixin(MinecartEntity.class)
public class MinecartEntityMixin {
	@ModifyConstant(method = "moveOnRail", constant = @Constant(classValue = LivingEntity.class, ordinal = 0))
	private Class<? extends LivingEntity> mc64836(Object object, Class constant) {
		return PlayerEntity.class;
	}
}

Let me know if I should supply more information.

Extra note: The target (ornithe is not in the list) in short it is basically fabric loader but for older versions (don't think it should be really relevant for this case). If required I can supply a minimal repo with only this mixin running on the target.

thdaele avatar Feb 11 '24 23:02 thdaele