MixinContext

class MixinContext(val target: String, val method: String, val self: Any?, val args: Array<Any?>)

The object handed to a Mixin injection callback. It is the live link between the running Minecraft method and the script: read the receiver and arguments, cancel the call, or substitute its return value.

import { Mixin } from 'ratph6.tessera.api';

// Stop the player from ever taking fall damage.
Mixin.inject("net.minecraft.world.entity.LivingEntity", "causeFallDamage", "HEAD", (ctx) => {
ctx.cancel(); // skip the original method body
});

// Force a method that returns a boolean to always return true.
Mixin.inject("net.minecraft.client.player.LocalPlayer", "isSprinting", "RETURN", (ctx) => {
ctx.setReturnValue(true);
});

The self receiver and the boxed args mirror the target method's signature (primitive arguments arrive boxed, e.g. an int becomes a java.lang.Integer). args is read-only — mutating elements does not change the values the original method sees.

The field-access surface (cancelled, returnValue, hasReturnOverride) is read directly by the bytecode Tessera injects into the target method, so the names and descriptors here are an ABI — keep them in sync with MixinTransformer.

Constructors

Link copied to clipboard
constructor(target: String, method: String, self: Any?, args: Array<Any?>)

Properties

Link copied to clipboard

The target method's arguments, boxed. Read-only.

Link copied to clipboard

Set by cancel/setReturnValue; read by the injected bytecode to short-circuit the method.

Link copied to clipboard

True once setReturnValue has been called — tells the injected bytecode to use returnValue.

Link copied to clipboard

Name of the injected method.

Link copied to clipboard

At a RETURN injection this starts as the method's actual return value; setReturnValue replaces it.

Link copied to clipboard

The receiver (this) of the call, or null for a static method.

Link copied to clipboard

Binary name of the injected class, e.g. net.minecraft.client.Minecraft.

Functions

Link copied to clipboard
fun argCount(): Int
Link copied to clipboard
fun cancel()

Skip the rest of the original method (a HEAD injection returns immediately).

Link copied to clipboard
fun getArg(i: Int): Any?

The i-th argument (boxed), or null if out of range.

Link copied to clipboard
Link copied to clipboard
fun setReturnValue(value: Any?)

Substitute the method's return value. At a HEAD injection this also cancels the original body; at a RETURN injection it replaces the value about to be returned. The value must be assignable to the method's declared return type (an unbox/checkcast happens in the injected bytecode).