Annotation Interface Local


@Target(PARAMETER) @Retention(CLASS) public @interface Local
Allows you to capture local variables wherever you need them. The annotated parameter's type must either match the target variable's type, or be the corresponding LocalRef type. In the latter case you can both read from and write to the target variable.

Targeting the variables can be done in 2 ways:

  • Explicit Mode: The variable to target is determined by ordinal, index or name.
  • Implicit Mode: You don't specify any of the above. If there is exactly one variable of the targeted type available, that will be targeted. If not, an error is thrown.
See the wiki article for more info.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Whether only the method's parameters should be included.
    int
    The LVT index of the local variable.
    Names of the local variable.
    int
    The index of the local variable by type.
    boolean
    Whether to print a table of the available variables so you can determine the right discriminators to use.
  • Element Details

    • print

      boolean print
      Whether to print a table of the available variables so you can determine the right discriminators to use. This will abort the injection.
      Default:
      false
    • ordinal

      int ordinal
      The index of the local variable by type. E.g. if there are 3 String variables, an ordinal of 2 would target the 3rd one.
      Default:
      -1
    • index

      int index
      The LVT index of the local variable. Get this from the bytecode or using print(). This is generally more brittle than ordinal.
      Default:
      -1
    • name

      String[] name
      Names of the local variable. This will not work on obfuscated code like Minecraft. For targeting unobfuscated code this is normally the least brittle option.
      Default:
      {}
    • argsOnly

      boolean argsOnly
      Whether only the method's parameters should be included. This makes the capture more efficient.
      Default:
      false