Package com.llamalad7.mixinextras.sugar
Annotation 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,indexorname. - 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.
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanWhether only the method's parameters should be included.intThe LVT index of the local variable.String[]Names of the local variable.intThe index of the local variable by type.booleanWhether to print a table of the available variables so you can determine the right discriminators to use.
-
Element Details
-
print
boolean printWhether 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 ordinalThe index of the local variable by type. E.g. if there are 3Stringvariables, an ordinal of 2 would target the 3rd one.- Default:
- -1
-
index
int indexThe LVT index of the local variable. Get this from the bytecode or usingprint(). This is generally more brittle thanordinal.- Default:
- -1
-
name
String[] nameNames 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 argsOnlyWhether only the method's parameters should be included. This makes the capture more efficient.- Default:
- false
-