com.llamalad7.mixinextras.injector.WrapWithCondition Maven / Gradle / Ivy
package com.llamalad7.mixinextras.injector;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Slice;
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
* {@link org.spongepowered.asm.mixin.injection.points.BeforeInvoke void method call} or
* {@link org.spongepowered.asm.mixin.injection.points.BeforeFieldAccess field write}
* with a conditional check.
*
* Your handler method receives the targeted instruction's arguments (optionally followed by the enclosing method's
* parameters), and should return a boolean indicating whether the operation should go ahead:
*
*
* Targeted operation
* Handler signature
*
*
* Non-static method call
* private (static) boolean handler(ReceiverType instance, <params of the original
* call>)
*
*
* Static method call
* private (static) boolean handler(<params of the original call>)
*
*
* Non-static field write
* private (static) boolean handler(ReceiverType instance, FieldType newValue)
*
*
* Static field write
* private (static) boolean handler(FieldType newValue)
*
*
* This chains when used by multiple people, unlike
* {@link org.spongepowered.asm.mixin.injection.Redirect @Redirect}.
*
* If you always return false then you risk other people's code being silently ignored.
*
* See the wiki article for more info.
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface WrapWithCondition {
String[] method();
At[] at();
Slice[] slice() default {};
boolean remap() default true;
int require() default -1;
int expect() default 1;
int allow() default -1;
}