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

add a system property to enable fixing package access regardless of target namespace #895

Merged
merged 2 commits into from
Jul 9, 2024

Conversation

SpaceWalkerRS
Copy link
Contributor

  • independent of game provider
  • the launch arg is parsed after the game provider is initialized (so that the mapping configuration is loaded)

@sfPlayer1
Copy link
Contributor

We usually use system properties for these smaller tweaks. Can you say more about the application/purpose?

@SpaceWalkerRS
Copy link
Contributor Author

Obfuscation can be quite inconsistent in older versions of Minecraft, sometimes obfuscated classes are placed in the same package as the main classes and classes can actually move package between versions. For this reason I'd like to loosen the restrictions on which classes are given intermediary names to make sure all these classes are placed in the intermediary target package. For that to work in production Loader will need to fix illegal access errors this causes.

I'm sure it's possible to implement this as a system property too. The reason I went with a launch arg is that it's easy to add that to the launcher profile json. I'm not sure how to do that for system properties though.

@sfPlayer1
Copy link
Contributor

System properties are part of the jvm arguments, like -Dname=value, before the jar file or main class name. The vanilla launcher supports them.

If you really need the argument, make sure to declare it in the Arguments class and keep the usage consistent with ADD_MODS. I'd however prefer the system property approach.

I btw intend to replace the naive "make everything public" with Tiny Remapper's dynamic access fixing at some point - once that's fully working.

@modmuss50
Copy link
Member

Using a launch arg like this, will likely cause the game to crash on startup due an unknown argument, or at best log an error. A system prop the way to go.

@SpaceWalkerRS
Copy link
Contributor Author

alrighty, I'll change it up to a system property 👍

@SpaceWalkerRS SpaceWalkerRS changed the title add a launch argument to enable fixing package access regardless of target namespace add a system property to enable fixing package access regardless of target namespace Feb 19, 2024
@modmuss50 modmuss50 added this to the 0.16.0 milestone Jul 9, 2024
public static byte[] transform(boolean isDevelopment, EnvType envType, String name, byte[] bytes) {
boolean isMinecraftClass = name.startsWith("net.minecraft.") || name.startsWith("com.mojang.blaze3d.") || name.indexOf('.') < 0;
boolean transformAccess = isMinecraftClass && FabricLauncherBase.getLauncher().getMappingConfiguration().requiresPackageAccessHack();
boolean transformAccess = isMinecraftClass && (FIX_PACKAGE_ACCESS || FabricLauncherBase.getLauncher().getMappingConfiguration().requiresPackageAccessHack());
Copy link
Member

Choose a reason for hiding this comment

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

I would move the system property into MappingConfiguration, and make requiresPackageAccessHack() return true when the system prop is set.

If requiresPackageAccessHack() had multiple places it was being called they would all need changing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@modmuss50 modmuss50 merged commit 4dbcb72 into FabricMC:master Jul 9, 2024
3 checks passed
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