Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Multi-Target Redirect in Multi-Target Mixin] Targets seemingly ignore the owning class? #603

Open
Sollace opened this issue Sep 19, 2022 · 0 comments

Comments

@Sollace
Copy link

Sollace commented Sep 19, 2022

I don't know if this is maybe my fault for trying to be smart, but I'me trying to write a mixin that injects the same injection point into methods on two classes (code below), but no matter what I try I can't seem to get it to work outside of my IDE.

I've tried replacing target methods with equivalent @Desc annotations, which worked in dev, but causes a crash when trying to run it on a production version of minecraft (I assume because the names don't go through obfuscation ;-;)

Going back to string descriptors, I've tried both with or without the owner class (i.e.
processBlockBreakingAction(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/network/packet/c2s/play/PlayerActionC2SPacket$Action;Lnet/minecraft/util/math/Direction;II)V) and without parameters (i.e. processBlockBreakingAction ) and it always seems to fail to build with the error Multi-target reference conflict for @Redirect target.

For now I'm going to just copy the handler into two separate mixin classes, however it would be nice if this kind of thing could be supported better in the future.

@Mixin(value = {
        ServerPlayerInteractionManager.class,
        ServerPlayNetworkHandler.class
})
abstract class MixinReachDistanceFix {
    @Redirect(
            method = {
                    "net/minecraft/server/network/ServerPlayerInteractionManager.processBlockBreakingAction(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/network/packet/c2s/play/PlayerActionC2SPacket$Action;Lnet/minecraft/util/math/Direction;II)V",
                    "net/minecraft/server/network/ServerPlayNetworkHandler.onPlayerInteractBlock(Lnet/minecraft/network/packet/c2s/play/PlayerInteractBlockC2SPacket;)V",
                    "net/minecraft/server/network/ServerPlayNetworkHandler.onPlayerInteractEntity(Lnet/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket;)V"
            },
            at = @At(
                value = "FIELD",
                target = "net/minecraft/server/network/ServerPlayNetworkHandler.MAX_BREAK_SQUARED_DISTANCE:D",
                opcode = Opcodes.GETSTATIC
            ),
            require = 0
    )
    private double bgetMaxBreakSquaredDistance() {
        Object o = this;
        ServerPlayerEntity player = o instanceof ServerPlayNetworkHandler s ? s.getPlayer() : ((MixinServerPlayerInteractionManager)o).getPlayer();
        double reach = 6 + Pony.of(player).getExtendedReach();
        return reach * reach;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant