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

Output to hashed mappings #14

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

TibiNonEst
Copy link
Contributor

@TibiNonEst TibiNonEst commented May 11, 2022

This pr adds support for hashed mappings within loom. Mods will now, by default, output with hashed mappings instead of intermediary. Additionally, all dependencies will be able to be remapped from either hashed or intermediary to named when in a dev environment.

This probably shouldn't be merged until loader has hashed support. Also, QuiltMC/sponge-mixin-compile-extensions#1 has to be merged and published on the maven for mixins to get remapped correctly.

Includes merging intermediary and hashed into one main mappings tree so that dependencies can be remapped when required.

void setIntermediaryMinecraftProvider(IntermediaryMinecraftProvider<?> intermediaryMinecraftProvider);

+ void setHashedMinecraftProvider(HashedMinecraftProvider<?> hashedinecraftProvider);
Copy link
Member

Choose a reason for hiding this comment

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

There's a typo of Minecraft in the parameter name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thx lol

+ /**
+ * Hashed mappings are a hashed version of the raw official mappings.
+ *
+ * @see <a href="https://github.com/QuiltMC/mappings-hasher/">github.com/QuiltMC/mappings-hasher/</a>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
+ * @see <a href="https://github.com/QuiltMC/mappings-hasher/">github.com/QuiltMC/mappings-hasher/</a>
+ * @see <a href="https://github.com/QuiltMC/rfcs/blob/master/specification/0041-hashed-mappings-specification.md</a>

+ private TinyRemapper createTinyRemapper(MappingsNamespace intermediateMappings) {
try {
- TinyRemapper tinyRemapper = TinyRemapperHelper.getTinyRemapper(project, "intermediary", "named");
+ TinyRemapper tinyRemapper = TinyRemapperHelper.getTinyRemapper(project, "hashed", "named");
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the namespace depend on which intermediateMappings you provided in the argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, yes, I might have left that in from debugging

return false;
}

- if (!MappingsNamespace.INTERMEDIARY.toString().equals(mappings.getSrcNamespace())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this break depending on mods with transitive AWs in Intermediary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The mapping tree passed is just the normal loom mapping provider but with the source namespace switched to hashed, it's not the namespace of the transitive AW.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wait you might be right actually, I'll have to do a little more digging.

Comment on lines 369 to 370
- for (Path minecraftJar : extension.getMinecraftJars(MappingsNamespace.INTERMEDIARY)) {
- remapper.readClassPathAsync(minecraftJar);
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like you never fill the intermediary remapper's classpath?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, there was a reason I did this but I don't remember it, you're right it would probably make more sense to populate the remapper's classpath.

Comment on lines +586 to +587
+ // Hashed is always the base layer
+ builtLayers.add(new HashedMappingsSpec());
Copy link
Contributor

Choose a reason for hiding this comment

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

This is okay as long as we're able to layer Intermediary on top of Hashed, for e.g. Quilted Fabric API

Copy link
Contributor Author

@TibiNonEst TibiNonEst May 12, 2022

Choose a reason for hiding this comment

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

Why would intermediary get layered on top of hashed? All the dependencies get remapped to named for dev and hashed in loader and intermediary is merged into the mapping tree regardless

+import net.fabricmc.loom.util.SidedClassVisitor;
+import net.fabricmc.tinyremapper.TinyRemapper;
+
+public abstract sealed class HashedMinecraftProvider<M extends MinecraftProvider> extends AbstractMappedMinecraftProvider<M> permits HashedMinecraftProvider.MergedImpl, HashedMinecraftProvider.SingleJarImpl, HashedMinecraftProvider.SplitImpl {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think in this case what you should do instead is modify the Intermediary minecraft provider to be extendable by hashed, and then only override the methods you actually have to change, since i believe most of this class is duplicated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would be smarter yes lol, I'll do that now

Copy link
Contributor Author

@TibiNonEst TibiNonEst May 12, 2022

Choose a reason for hiding this comment

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

I honestly don't know if this is worth all the changes it would take, it would be hard to make this work with the mess of generics that is MinecraftJarConfiguration.

+
+ if (mappings.equals("net.fabricmc:intermediary")) return MappingsNamespace.INTERMEDIARY;
+
+ return MappingsNamespace.HASHED;
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic is unsound; it will assume any "intermediate_mappings" value besides fabric intermediary is hashed, but with loader plugins we can't promise that's the case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's true, I did this so it would fall back to hashed. I can instead have it explicitly check for hashed or an empty value (implicitly hashed) and have it throw an exception if the value's unknown if that's preferred.

@TibiNonEst TibiNonEst deleted the branch QuiltMC:main May 13, 2022 14:24
@TibiNonEst TibiNonEst closed this May 13, 2022
@TibiNonEst TibiNonEst deleted the main branch May 13, 2022 14:24
@TibiNonEst TibiNonEst restored the main branch May 13, 2022 14:25
@TibiNonEst
Copy link
Contributor Author

TibiNonEst commented May 13, 2022

This is what I get for messing with branch names lol.

@TibiNonEst TibiNonEst reopened this May 13, 2022
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