additionaladditions icon indicating copy to clipboard operation
additionaladditions copied to clipboard

Suggestion: Mixin compatibility

Open donmor opened this issue 1 year ago • 2 comments

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

donmor avatar Dec 10 '24 07:12 donmor

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

donmor avatar Dec 10 '24 07:12 donmor

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.

donmor avatar Dec 11 '24 09:12 donmor