Skip to content

Conversation

@Raik176
Copy link
Contributor

@Raik176 Raik176 commented May 22, 2025

Adds support for access wideners to other games by adding a new isAccessWidenable method to GameProvider and using that to determine if access wideners should be applied instead of hardcoding it for minecraft only classes in FabricTransformer.

Copy link
Contributor

@Gamebuster19901 Gamebuster19901 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the idea seems sound to me. I'd change the name of the method though.

It's worth noting that downstream projects will need something like Loom to fully utilize the access changes at compile time.

That said, these changes aren't useless to projects without a loom equivalent. Access wideners can still be useful to expose members using reflection without relying on --add-opens or other workarounds.

return LoaderUtil.hasAwtSupport();
}

default boolean isAccessWidenable(String className) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably rename to something like canWidenAccess

Copy link
Contributor

@Gamebuster19901 Gamebuster19901 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation also needs to be updated to reflect the method name change.

}

@Override
public boolean isAccessWidenable(String className) {
Copy link
Contributor

@Gamebuster19901 Gamebuster19901 Jun 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not compile because canWidenAccess() is not implemented. This method needs to be renamed.

boolean transformAccess = isMinecraftClass && FabricLauncherBase.getLauncher().getMappingConfiguration().requiresPackageAccessHack();
boolean environmentStrip = !isMinecraftClass || isDevelopment;
boolean applyAccessWidener = isMinecraftClass && FabricLoaderImpl.INSTANCE.getAccessWidener().getTargets().contains(name);
boolean applyAccessWidener = FabricLoaderImpl.INSTANCE.getGameProvider().isAccessWidenable(name)
Copy link
Contributor

@Gamebuster19901 Gamebuster19901 Jun 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not compile because isAccessWidenable() is not a method in GameProvider. You should be calling canWidenAccess().

Renamed the method in GameProvider but forgot to update the default minecraft implementation and usages. This caused build errors, and is now corrected.
@Player3324
Copy link
Contributor

I adjusted your approach to be more configurable by the game provider at #1056 as those properties really depend on more than whether it's a game class.

In Minecraft's example we (currently still) have the "widen all" hack and the way Mojang packages it combined with how loom may present the game in-dev as a combined requires env stripping there. Other games likely don't even need these.

@Player3324
Copy link
Contributor

Implemented by #1056

@Player3324 Player3324 closed this Jul 26, 2025
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

Successfully merging this pull request may close these issues.

3 participants