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

Possibility to dynamically add imports in patterns #18

Open
MiranCZ opened this issue Jul 2, 2024 · 0 comments
Open

Possibility to dynamically add imports in patterns #18

MiranCZ opened this issue Jul 2, 2024 · 0 comments

Comments

@MiranCZ
Copy link

MiranCZ commented Jul 2, 2024

Sometimes you need to use a specific path in your pattern.
For example, when a method is private in other versions you need to import the accessor for it.

@Pattern
public int getPortalCooldown(Entity entity) {
    //#if MC >= 12001
    //$$ return entity.getPortalCooldown();
    //#else
    return ((EntityAccessor) entity).getPortalCooldown();
    //#endif
}

So either you have to go and manually add import for it in all classes that use the method or supply a full path in the pattern instead of relying on the classes to import it

return ((mod.example.mixins.EntityAccessor) entity).getPortalCooldown();

But I feel like that looks a bit ugly in preprocessed the code.

So I think adding a way to define dynamic imports for patterns that would be added to the preprocessed code would be a nice addition (although I don't understand how the preprocessor works under the hood, so what I am asking might be impossible).

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

No branches or pull requests

1 participant