Interface IMixinConfigPlugin
A companion plugin for a mixin configuration object. Objects implementing this interface get some limited power of veto over the mixin load process as well as an opportunity to apply their own transformations to the target class pre- and post-transform. Since all methods in this class are called indirectly from the transformer, the same precautions as for writing class transformers should be taken. Implementors should take care to not reference any game classes, and avoid referencing other classes in their own mod except those specificially designed to be available at early startup, such as coremod classes or other standalone bootstrap objects.
Instances of plugins are created by specifying the "plugin" key in the mixin config JSON as the fully-qualified class name of a class implementing this interface.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
acceptTargets
(Set<String> myTargets, Set<String> otherTargets) Called after all configurations are initialised, this allows this plugin to observe classes targetted by other mixin configs and optionally remove targets from its own set.After mixins specified in the configuration have been processed, this method is called to allow the plugin to add any additional mixins to load.Called only if the "referenceMap" key in the config is not set.void
Called after the plugin is instantiated, do any setup here.void
postApply
(String targetClassName, org.objectweb.asm.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) Called immediately after a mixin is applied to a target class, allows any post-application transformations to be applied.void
preApply
(String targetClassName, org.objectweb.asm.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) Called immediately before a mixin is applied to a target class, allows any pre-application transformations to be applied.boolean
shouldApplyMixin
(String targetClassName, String mixinClassName) Called during mixin intialisation, allows this plugin to control whether a specific will be applied to the specified target.
-
Method Details
-
onLoad
Called after the plugin is instantiated, do any setup here.- Parameters:
mixinPackage
- The mixin root package from the config
-
getRefMapperConfig
String getRefMapperConfig()Called only if the "referenceMap" key in the config is not set. This allows the refmap file name to be supplied by the plugin programatically if desired. Returningnull
will revert to the default behaviour of using the default refmap json file.- Returns:
- Path to the refmap resource or null to revert to the default
-
shouldApplyMixin
Called during mixin intialisation, allows this plugin to control whether a specific will be applied to the specified target. Returning false will remove the target from the mixin's target set, and if all targets are removed then the mixin will not be applied at all.- Parameters:
targetClassName
- Fully qualified class name of the target classmixinClassName
- Fully qualified class name of the mixin- Returns:
- True to allow the mixin to be applied, or false to remove it from target's mixin set
-
acceptTargets
Called after all configurations are initialised, this allows this plugin to observe classes targetted by other mixin configs and optionally remove targets from its own set. The set myTargets is a direct view of the targets collection in this companion config and keys may be removed from this set to suppress mixins in this config which target the specified class. Adding keys to the set will have no effect.- Parameters:
myTargets
- Target class set from the companion configotherTargets
- Target class set incorporating targets from all other configs, read-only
-
getMixins
After mixins specified in the configuration have been processed, this method is called to allow the plugin to add any additional mixins to load. It should return a list of mixin class names or return null if the plugin does not wish to append any mixins of its own.- Returns:
- additional mixins to apply
-
preApply
void preApply(String targetClassName, org.objectweb.asm.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) Called immediately before a mixin is applied to a target class, allows any pre-application transformations to be applied.- Parameters:
targetClassName
- Transformed name of the target classtargetClass
- Target class treemixinClassName
- Name of the mixin classmixinInfo
- Information about this mixin
-
postApply
void postApply(String targetClassName, org.objectweb.asm.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) Called immediately after a mixin is applied to a target class, allows any post-application transformations to be applied.- Parameters:
targetClassName
- Transformed name of the target classtargetClass
- Target class treemixinClassName
- Name of the mixin classmixinInfo
- Information about this mixin
-