preprocessor
preprocessor copied to clipboard
Possibility to dynamically add imports in patterns
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).