Class MethodRedirector

java.lang.Object
net.neoforged.neoforge.coremods.MethodRedirector
All Implemented Interfaces:
ITransformer<org.objectweb.asm.tree.ClassNode>

public class MethodRedirector extends Object implements ITransformer<org.objectweb.asm.tree.ClassNode>
Redirect calls to one method to another.
  • Field Details

  • Constructor Details

    • MethodRedirector

      public MethodRedirector()
  • Method Details

    • getTargetType

      public TargetType<org.objectweb.asm.tree.ClassNode> getTargetType()
      Specified by:
      getTargetType in interface ITransformer<org.objectweb.asm.tree.ClassNode>
    • targets

      public Set<ITransformer.Target<org.objectweb.asm.tree.ClassNode>> targets()
      Description copied from interface: ITransformer
      Return a set of ITransformer.Target identifying which elements this transformer wishes to try and apply to. The ITransformer.getTargetType() must match the T variable for the transformer as documented in TargetType, other combinations will be rejected.
      Specified by:
      targets in interface ITransformer<org.objectweb.asm.tree.ClassNode>
      Returns:
      The set of targets this transformer wishes to apply to
    • transform

      public org.objectweb.asm.tree.ClassNode transform(org.objectweb.asm.tree.ClassNode classNode, ITransformerVotingContext votingContext)
      Description copied from interface: ITransformer
      Transform the input to the ITransformer's desire. The context from the last vote is provided as well.
      Specified by:
      transform in interface ITransformer<org.objectweb.asm.tree.ClassNode>
      Parameters:
      classNode - The ASM input node, which can be mutated directly
      votingContext - The voting context
      Returns:
      An ASM node of the same type as that supplied. It will be used for subsequent rounds of voting.
    • castVote

      Description copied from interface: ITransformer
      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 ITransformer.transform(Object, ITransformerVotingContext) method called. It is then removed from the set of transformers and another round is performed.
      Specified by:
      castVote in interface ITransformer<org.objectweb.asm.tree.ClassNode>
      Parameters:
      context - The context of the vote
      Returns:
      A TransformerVoteResult indicating the desire of this transformer