本帖最后由 tdiant 于 2023-2-9 00:32 编辑
突发奇想让一个普通苹果也有金苹果的效果,代码如下:
@Mixin(FoodComponents.class)
public class FoodComponentsMixin {
@Redirect(at = @At(value = "FIELD",
target = "Lnet/minecraft/item/FoodComponents;APPLE:Lnet/minecraft/item/FoodComponent;", opcode = Opcodes.GETFIELD),
method = {"<clinit>"})
private static FoodComponent newApple() {
return (new FoodComponent.Builder()).hunger(4).saturationModifier(1.2F).statusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 100, 1), 1.0F).statusEffect(new StatusEffectInstance(StatusEffects.ABSORPTION, 2400, 0), 1.0F).alwaysEdible().build();
}
}
运行报错:failed injection check, (0/1) succeeded. Scanned 1 target(s). No refMap loaded.
mod新手,查了好多资料才有了上面的代码,结果报错,有没有大佬指点下该怎么解决
突发奇想让一个普通苹果也有金苹果的效果,代码如下:
@Mixin(FoodComponents.class)
public class FoodComponentsMixin {
@Redirect(at = @At(value = "FIELD",
target = "Lnet/minecraft/item/FoodComponents;APPLE:Lnet/minecraft/item/FoodComponent;", opcode = Opcodes.GETFIELD),
method = {"<clinit>"})
private static FoodComponent newApple() {
return (new FoodComponent.Builder()).hunger(4).saturationModifier(1.2F).statusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 100, 1), 1.0F).statusEffect(new StatusEffectInstance(StatusEffects.ABSORPTION, 2400, 0), 1.0F).alwaysEdible().build();
}
}
运行报错:failed injection check, (0/1) succeeded. Scanned 1 target(s). No refMap loaded.
mod新手,查了好多资料才有了上面的代码,结果报错,有没有大佬指点下该怎么解决
正常(如果你的功能生效的话)