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

Access Widener suggestion fails on inner classes #2249

Open
thdaele opened this issue Mar 1, 2024 · 0 comments
Open

Access Widener suggestion fails on inner classes #2249

thdaele opened this issue Mar 1, 2024 · 0 comments

Comments

@thdaele
Copy link

thdaele commented Mar 1, 2024

Minecraft Development for IntelliJ plugin version

2023.3-1.7.3

IntelliJ version

IntelliJ IDEA 2023.3.4 (Ultimate Edition) Build #IU-233.14475.28

Operating System

Linux

Target platform

Mixins

Description of the bug

After applying the suggested access widener (AW) by MC-dev on members of outer class it stops suggesting to apply the AW. When I apply an AW to an inner class or the members of the inner class, MC-dev will keep suggesting to apply the AW.
Somewhat minimal code example to make clear what I mean:

// MC-dev suggests to AW ItemStatsListWidget, specifying the internal name results in mixin saying I can use the class Ref instead bc it is already public
@Mixin(StatsScreen.ItemStatsListWidget.class)
class ItemStatsListWidgetMixin {
    @Shadow @Final
    StatsScreen f_2839217;

    @Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/stat/PlayerStats;get(Lnet/minecraft/stat/Stat;)I")
    )
    public int init1(PlayerStats instance, Stat stat) {
       // Stats is a member on the outer class that is accessed through a synthetic field inside the inner class and this works fine and MC-dev doesn't keep suggesting to apply the AW after you applied it.
        return ((IPlayerStats) f_2839217.stats).bismuthServer$getLongStat(stat) > 0L ? 1 : 0;
    }
}

@Mixin(targets = "net/minecraft/client/gui/screen/StatsScreen$ItemStatsListWidget$1")
class StatComparator {
    @Final @Shadow
    // Outer class
    StatsScreen f_5153485;

    @Final @Shadow
    // Inner class
    // synthetic field, MC-dev suggests to AW ItemStatsListWidget
    StatsScreen.ItemStatsListWidget f_7207520;

    @Inject(method = "compare(Lnet/minecraft/stat/ItemStat;Lnet/minecraft/stat/ItemStat;)I", at = @At(value = "INVOKE", target = "Lnet/minecraft/stat/PlayerStats;get(Lnet/minecraft/stat/Stat;)I"), cancellable = true)
    public void compare(ItemStat itemStat, ItemStat itemStat2, CallbackInfoReturnable<Integer> cir, @Local(ordinal = 0) Stat stat, @Local(ordinal = 1) Stat stat2, @Local(ordinal = 0) int i, @Local(ordinal = 1) int j) {
       // Access of member on outerclass is fine (and MC-dev only suggests AW till you apply it) : 
       f_5153485.stats;
       // Access of member on inner class MC-dev keeps suggesting to apply the AW
       f_7207520.f_2401102;
    }
}

My access widener file:

accessWidener v2 named
accessible field net/minecraft/client/gui/screen/StatsScreen stats Lnet/minecraft/stat/PlayerStats;
accessible class net/minecraft/client/gui/screen/StatsScreen$ItemStatsListWidget
accessible class net/minecraft/client/gui/screen/StatsScreen$AbstractStatsListWidget
accessible field net/minecraft/client/gui/screen/StatsScreen$AbstractStatsListWidget f_2401102 I
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant