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

Update for new mixin #468

Merged
merged 10 commits into from
Aug 27, 2021
Merged

Update for new mixin #468

merged 10 commits into from
Aug 27, 2021

Conversation

sfPlayer1
Copy link
Contributor

@sfPlayer1 sfPlayer1 commented Jul 4, 2021

This is still pending successful Mixin testing and gradle+installer dep updates

@liach liach requested a review from a team July 5, 2021 15:12
@sfPlayer1 sfPlayer1 changed the title Update for new mixin service api Update for new mixin Jul 12, 2021
dataMap.put(FabricData.KEY_COMPATIBILITY, getMixinCompat(mod));

for (String config : configs) {
addConfigurationFabric.invoke(null, config, dataMap);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is reusing this map not an issue given the Mixin PR doesn't seem to clone it either? It's also not cleared after use but I suppose it overwrites everything it contains so it doesn't matter

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 Mixin PR actually "deserializes" the map directly

Copy link
Contributor

Choose a reason for hiding this comment

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

So it does, thought FabricData#attach was keeping the map too but it's actually just the FabricData object

getMixinConfigs(loader, side).forEach(FabricMixinBootstrap::addConfiguration);

try {
Method addConfigurationFabric = Mixins.class.getMethod("addConfigurationFabric", String.class, Map.class);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could do this calling the method directly then catching NoSuchMethodError?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want to risk it, AFAIK the JVM spec doesn't guarantee that it'd be safe and this is good enough.

ctor.setAccessible(true);
mixinTransformer = ctor.newInstance();
} catch (ReflectiveOperationException e) {
throw new IllegalStateException("mixin transformer unavailable?");
Copy link
Contributor

Choose a reason for hiding this comment

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

Might as well pass the original exception along too

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 exception is meant for the original fault (regular mixin interop failing), exceptions from this legacy support hack aren't meaningful outside Mixin 0.8-0.8.2

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean if it does throw a ReflectiveOperationException and you're not using Mixin 0.8.3+ presumably you'd want to know why rather than just getting a IllegalStateException without a cause

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no better cause really, i updated the commit with a few more comments.


// default to old fabric-mixin

return FabricUtil.COMPATIBILITY_0_9_2;
Copy link
Member

Choose a reason for hiding this comment

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

In dev this should latest when a classpath mod, but fallback to to older version when loading mods from the mods dir.

Copy link
Member

Choose a reason for hiding this comment

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

This might cause issues with outdated deps though... not sure there is a way to handle all the cases here.

@sfPlayer1 sfPlayer1 force-pushed the mixinUpdate branch 4 times, most recently from 1363b8b to 912d062 Compare August 19, 2021 20:20
@sfPlayer1 sfPlayer1 marked this pull request as ready for review August 19, 2021 20:24

for (Config config : Mixins.getConfigs()) {
ModContainerImpl mod = configToModMap.get(config.getName());
if (mod == null) continue;
Copy link
Member

Choose a reason for hiding this comment

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

Whats the reason for this loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't patch config addition in Mixin anymore, instead I add the config files normally, then pull the config objects back out, reassociate them with mods and add fabric specific data to them.

import java.util.jar.Manifest;

public final class ManifestUtil {
public static final Name NAME_MAPPING_NAMESPACE = new Name("Fabric-Mapping-Namespace");
Copy link
Member

Choose a reason for hiding this comment

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

Are these constants used now?

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 the whole class is unused for now..

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 file is actually still used through a refactor (moved Knot's manifest reading to it too), but now without the constants.

This makes Mixin act as if it was the oldest version required by the mod
through its Loader dependency, to the extent implemented.

Mods need to declare and bump their loader dependency properly to
benefit from the latest enhancements in Mixin.

Also remove now unused constants from ManifestUtil
@sfPlayer1 sfPlayer1 merged commit a629c73 into FabricMC:master Aug 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants