com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod Maven / Gradle / Ivy
package com.llamalad7.mixinextras.injector.wrapmethod;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Allows you to wrap a whole method. To wrap individual operations within a method, including method calls, see
* {@link com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation @WrapOperation}.
*
* Your handler method receives the target method's arguments and an {@link Operation} representing the method
* being wrapped.
* You should return the same type as the wrapped method does:
*
* {@code private (static) ReturnType handler(<params of the original method>,Operation<ReturnType> original)}
*
* When {@code call}ing the {@code original}, you must pass everything before the {@code original} in your handler's
* parameters. You can optionally pass different values to change what the {@code original} uses.
*
* This chains when used by multiple people, unlike
* {@link org.spongepowered.asm.mixin.Overwrite @Overwrite}.
*
* If you never use the {@code original} then you risk other people's changes being silently ignored.
*
* NOTE: While this injector in general does not support Sugar, it does have special support for using
* {@link com.llamalad7.mixinextras.sugar.Share @Share} to share values between wrappers and the target method.
*
* See the wiki article for more info.
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface WrapMethod {
String[] method();
boolean remap() default true;
int require() default -1;
int expect() default 1;
int allow() default -1;
}