Most of this method (the parameters and return type) can be ignored safely due to the factor of the API we are using in this system.
But, to explain how the
@Optional.Method(modid = "OpenComputers") annotation is working, as you can see, we are passing the modid constant3 to the annotation, and what this does, when the class is loading, the method is stripped out via magic™4.
For this, we are combining the explanation of the two Interface bases annotations to explain them simply, since
InterfaceList is just an array of
@Optional.Interface it comes with the same caveats as
@Optional.Method but, in a slightly different way.
ClassCastExceptionat run time (if the class is in the class path) or even a
Yet again, this can be worked around with the
One example, of the annotation can be seen as follows2:
As you can see we are yet passing the modid of the mod that implements the interface we remove, though because of how Java annotations work (We cannot annotate a single implements) we have to specify the full canonical name of the class we want in the
iface parameter. Where this interface supplied (in this case, SimpleComponent) is removed by magic™4.
InterfaceList annotation is simple enough after understanding the
When Using the
InterfaceList we can simply wrap the
@Optional.Interface(...) with this annotation and an array declaration like2:
This can be useful when using external APIs, allowing you to exclude unneeded API files when possible, dropping them if the mod is not there. But due to time constraints on when I was writing this, if there is anything unclear comment below (the comments should work) and I shall clarify more for you.