Class ReplaceFieldWithGetterAccess

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

public class ReplaceFieldWithGetterAccess extends Object implements cpw.mods.modlauncher.api.ITransformer<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.

  • Field Details

    • fieldToMethod

      private final Map<String,String> fieldToMethod
    • targets

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

    • ReplaceFieldWithGetterAccess

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

    • getTargetType

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

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

      public ClassNode transform(ClassNode input, cpw.mods.modlauncher.api.ITransformerVotingContext context)
      Specified by:
      transform in interface cpw.mods.modlauncher.api.ITransformer<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<ClassNode>
    • redirectFieldToMethod

      private static void redirectFieldToMethod(ClassNode classNode, String fieldName, @Nullable @Nullable String methodName)