Interface ITransformer<T>

All Known Implementing Classes:
MethodRedirector, ReplaceFieldComparisonWithInstanceOf, ReplaceFieldWithGetterAccess, TransformerHolder

public interface ITransformer<T>
A transformer is injected into the modding ClassLoader. It can manipulate any item it is designated to target.
  • Field Details

    • DEFAULT_LABEL

      static final String[] DEFAULT_LABEL
  • Method Details

    • transform

      T transform(T input, ITransformerVotingContext context)
      Transform the input to the ITransformer's desire. The context from the last vote is provided as well.
      Parameters:
      input - The ASM input node, which can be mutated directly
      context - The voting context
      Returns:
      An ASM node of the same type as that supplied. It will be used for subsequent rounds of voting.
    • castVote

      Return the TransformerVoteResult for this transformer. The transformer should evaluate whether or not is is a candidate to apply during the round of voting in progress, represented by the context parameter. How the vote works: After all votes from candidate transformers are collected, the NOs are removed from the current set of voters, one from the set of YES voters is selected and it's transform(Object, ITransformerVotingContext) method called. It is then removed from the set of transformers and another round is performed.
      Parameters:
      context - The context of the vote
      Returns:
      A TransformerVoteResult indicating the desire of this transformer
    • targets

      Return a set of ITransformer.Target identifying which elements this transformer wishes to try and apply to. The getTargetType() must match the T variable for the transformer as documented in TargetType, other combinations will be rejected.
      Returns:
      The set of targets this transformer wishes to apply to
    • getTargetType

      TargetType<T> getTargetType()
    • labels

      default String[] labels()
      Returns:
      A string array for uniquely identifying this transformer instance within the service.