MinecraftDev icon indicating copy to clipboard operation
MinecraftDev copied to clipboard

`RightClick->Get Mixin target reference` doesn't work on abstract classes

Open LeafHacker opened this issue 4 years ago • 4 comments

Please include the following information in all bug reports:

  • Minecraft Development for IntelliJ plugin version: 2019.2-1.2.23.1 → 2019.2-1.3.1
  • IntelliJ version: 2019.2.3
  • Operating System Linux (Arch)
  • Target platforms
    • Mixin

When targeting a method (possibly only methods with a default implementation) on an abstract class, the abstract class is used in the method, rather than the implementing class.

This may only be fixable if you assume the class that is currently open in intellij is the implementing/target class. Alternatively it may make sense to display a warning if the implementing class cannot be determined.


Example: targeting net.minecraft.client.gui.screen.MainMenuScreen#render's use of net.minecraft.client.gui.AbstractGui#blit

If I write the following mixin and then auto complete the target, I get Lnet/minecraft/client/gui/screen/MainMenuScreen;blit(IIIIFFIIII)V, as expected.

@Mixin(MainMenuScreen.class)
public abstract class MixinMainMenuScreen extends Screen {
    @Inject(
            method = "render",
            at = @At(
                    value = "INVOKE",
                    target = "",
                    shift = AFTER,
                    ordinal = 0
            )
    )
    private void afterDrawOverlay(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) {
        
    }
}

However, if I navigate to net.minecraft.client.gui.screen.MainMenuScreen#render, right click on blit and select Copy Mixin Target Reference, it gives me Lnet/minecraft/client/gui/AbstractGui;blit(IIIIFFIIII)V.

Since net.minecraft.client.gui.AbstractGui is abstract, that doesn't exist.

LeafHacker avatar Sep 29 '19 21:09 LeafHacker

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 29 '19 00:11 stale[bot]

I've encountered this as well. Copy Mixin Target Reference on a call to this.remove() inside FallingBlockEntity::tick generates Lnet/minecraft/entity/Entity;remove()V instead of the correct Lnet/minecraft/entity/FallingBlockEntity;remove()V for my @Redirect target.

This also results in a cryptic mixin error that only says it "failed injection check" which requires enabling mixin debugging to see what targets are considered.

This plugin could help prevent this from occurring, but there also could be a better error message output if you try to target a method implemented in a superclass.

magneticflux- avatar Jan 13 '20 05:01 magneticflux-

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 13 '20 06:03 stale[bot]

Since #1221 was merged, completion of mixin target references is now correct for abstract classes, as well as the inspection for it. However, Copy Mixin target reference is still broken.

Earthcomputer avatar Sep 01 '21 22:09 Earthcomputer