Additional Additions | Fabric

Additional Additions | Fabric

6M Downloads

Suggestion: Mixin compatibility

donmor opened this issue ยท 2 comments

commented

Recently I'm making my mod pack and found this mod conflicts with another mod because both of them redirect isScoping method, causing the game crash.

// MouseHandlerMixin.java
@Mixin(MouseHandler.class)
public class MouseHandlerMixin {
    @Redirect(method = "turnPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;isScoping()Z"))
    private boolean slowCamera(LocalPlayer clientPlayerEntity) {
        return clientPlayerEntity.isScoping() || AdditionalAdditions.zoom;
    }
}

Instead It can be injected to Player$isScoping directly:

// PlayerMixin.java
@Mixin(Player.class)
public class MouseHandlerMixin {
    @Inject(method = "isScoping", at = @At(value = "RETURN"), cancellable = true)
    private boolean slowCamera(CallbackInfo info) {
        if (AdditionalAdditions.zoom)
            info.selReturnValue(true);
    }
}

Not sure if there's any side effect though

commented

Minecraft version: 1.20.1
Forge version: 47.3.12
AA version: 6.0.1
Conflicted mod: Glasses 1.2.1

commented

I patched Glasses mod (Nova-Committee/Glasses#6), it'll be compatible with AA once it is merged and a new version is published. Keeping this open in case there's another problem related to the Redirect things.