Class ClassProcessor.TransformationContext

java.lang.Object
net.neoforged.neoforgespi.transformation.ClassProcessor.TransformationContext
All Implemented Interfaces:
SimpleTransformationContext
Enclosing interface:
ClassProcessor

public static final class ClassProcessor.TransformationContext extends Object implements SimpleTransformationContext
Context available when processing a class
  • Field Details

    • type

      private final Type type
    • node

      private final org.objectweb.asm.tree.ClassNode node
    • empty

      private final boolean empty
    • auditTrail

      private final BiConsumer<String,String[]> auditTrail
    • initialSha256

      private final Supplier<byte[]> initialSha256
  • Constructor Details

    • TransformationContext

      @Internal public TransformationContext(Type type, org.objectweb.asm.tree.ClassNode node, boolean empty, BiConsumer<String,String[]> auditTrail, Supplier<byte[]> initialSha256)
  • Method Details

    • type

      public Type type()
      Returns . the type of the class being transformed
      Specified by:
      type in interface SimpleTransformationContext
      Returns:
    • node

      public org.objectweb.asm.tree.ClassNode node()
      Returns the class being transformed. Modifications will be reflected in the output bytecode (and the loaded class).
      Returns:
      the class being transformed
    • empty

      public boolean empty()
      Returns whether the class was empty when provided to this transformer. Note that a class might not exist on disk but still return false here, if an earlier transformer provided it.
      Specified by:
      empty in interface SimpleTransformationContext
      Returns:
      whether the class was empty when provided to this transformer
    • audit

      public void audit(String activity, String... context)
      Add audit activity for this transformation.
      Parameters:
      activity - what was done to the class
      context - any additional information to include
    • initialSha256

      public byte[] initialSha256()
      Returns the SHA-256 hash of the original class bytecode.
      Specified by:
      initialSha256 in interface SimpleTransformationContext
      Returns:
      the SHA-256 hash of the original class bytecode