Class ReplaceFieldWithGetterAccess

java.lang.Object
net.neoforged.neoforge.coremods.ReplaceFieldWithGetterAccess
All Implemented Interfaces:
cpw.mods.modlauncher.api.ITransformer<org.objectweb.asm.tree.ClassNode>

public class ReplaceFieldWithGetterAccess extends Object implements cpw.mods.modlauncher.api.ITransformer<org.objectweb.asm.tree.ClassNode>
Replaces direct field access in a class with access to the getter.

The field specified by fieldName must be private and non-static. The method-call the field-access is redirected to does not take any parameters and returns an object of the same type as the field. If no methodName is passed, any method matching the described signature will be used as callable method.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface cpw.mods.modlauncher.api.ITransformer

    cpw.mods.modlauncher.api.ITransformer.Target<T>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Map<String,String>
     
    private final Set<cpw.mods.modlauncher.api.ITransformer.Target<org.objectweb.asm.tree.ClassNode>>
     

    Fields inherited from interface cpw.mods.modlauncher.api.ITransformer

    DEFAULT_LABEL
  • Constructor Summary

    Constructors
    Constructor
    Description
    ReplaceFieldWithGetterAccess(String className, Map<String,String> fieldToMethod)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    cpw.mods.modlauncher.api.TransformerVoteResult
    castVote(cpw.mods.modlauncher.api.ITransformerVotingContext context)
     
    cpw.mods.modlauncher.api.TargetType<org.objectweb.asm.tree.ClassNode>
     
    private static void
    redirectFieldToMethod(org.objectweb.asm.tree.ClassNode classNode, String fieldName, @Nullable String methodName)
     
    Set<cpw.mods.modlauncher.api.ITransformer.Target<org.objectweb.asm.tree.ClassNode>>
     
    org.objectweb.asm.tree.ClassNode
    transform(org.objectweb.asm.tree.ClassNode input, cpw.mods.modlauncher.api.ITransformerVotingContext context)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface cpw.mods.modlauncher.api.ITransformer

    labels
  • Field Details

    • fieldToMethod

      private final Map<String,String> fieldToMethod
    • targets

      private final Set<cpw.mods.modlauncher.api.ITransformer.Target<org.objectweb.asm.tree.ClassNode>> targets
  • Constructor Details

    • ReplaceFieldWithGetterAccess

      public ReplaceFieldWithGetterAccess(String className, Map<String,String> fieldToMethod)
  • Method Details

    • getTargetType

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

      public Set<cpw.mods.modlauncher.api.ITransformer.Target<org.objectweb.asm.tree.ClassNode>> targets()
      Specified by:
      targets in interface cpw.mods.modlauncher.api.ITransformer<org.objectweb.asm.tree.ClassNode>
    • transform

      public org.objectweb.asm.tree.ClassNode transform(org.objectweb.asm.tree.ClassNode input, cpw.mods.modlauncher.api.ITransformerVotingContext context)
      Specified by:
      transform in interface cpw.mods.modlauncher.api.ITransformer<org.objectweb.asm.tree.ClassNode>
    • castVote

      public cpw.mods.modlauncher.api.TransformerVoteResult castVote(cpw.mods.modlauncher.api.ITransformerVotingContext context)
      Specified by:
      castVote in interface cpw.mods.modlauncher.api.ITransformer<org.objectweb.asm.tree.ClassNode>
    • redirectFieldToMethod

      private static void redirectFieldToMethod(org.objectweb.asm.tree.ClassNode classNode, String fieldName, @Nullable @Nullable String methodName)