Skip to content

API Documentation v4 Callbacks

Exopandora edited this page Jun 10, 2026 · 1 revision

Callbacks

Callbacks can be used to implement custom behavior rules for Shoulder Surfing Reloaded. They can be registered in the register method of a Shoulder Surfing plugin (see Plugins). Optionally, a callback can implement the ITickableCallback interface to receive client ticks (since 4.14.0).

public class CustomCallback implements IAdaptiveItemCallback, ITickableCallback {
    @Override
    public boolean isHoldingAdaptiveItem(Minecraft minecraft, LivingEntity entity) {
        return false;
    }
    
    @Override
    public void tick() {
        // process tick here
    }
}

IAdaptiveItemCallback

This callback can be used to implement custom switching behaviour for the adaptive crosshair for any item held. The final result is calculated from all partial results using a logical OR.

boolean isHoldingAdaptiveItem(
    Minecraft minecraft,
    LivingEntity entity
)

Parameters

  • minecraft - The Minecraft instance
  • entity - The current camera entity

Returns

  • boolean - true if the dynamic crosshair should be displayed, false if the static crosshair should be displayed

Since 2.3.0

ICameraCouplingCallback

This callback can be used to implement custom camera coupling rules. The final result is calculated from all partial results using a logical OR.

boolean isForcingCameraCoupling(
    Minecraft minecraft
)

Parameters

  • minecraft - The Minecraft instance

Returns

  • boolean - true if the camera should be coupled, false if the camera can be decoupled

Since 4.11.0

ICameraEntityTransparencyCallback

float getCameraEntityAlpha(
    IShoulderSurfing instance,
    Entity cameraEntity,
    float partialTick
)

This callback can be used to implement custom camera entity transparency rules. The final result is the minimum value from all partial results.

Parameters

  • instance - The IShoulderSurfing instance
  • cameraEntity - The camera entity
  • partialTick - The render partial tick

Returns

  • float - The alpha value to use for camera entity rendering, ranging from 0.0F (invisible) to 1.0F (opaque)

Since 4.14.0

ICameraRotationSetupCallback

This callback can be used to change the camera angle computation. Both methods provide a default NOP implementation.

void pre(
    CameraRotationSetupContext context,
    CameraRotationSetupResult result
)

Parameters

  • context - The arguments of this callback
  • result - The result of this callback

Since 4.17.0


void post(
    CameraRotationSetupContext context,
    CameraRotationSetupResult result
)

Parameters

  • context - The arguments of this callback
  • result - The result of this callback

Since 4.17.0

IPlayerInputCallback

This callback can be used to force vanilla movement inputs. This can be useful when movement is computed server side via xxa, yya and zza fields. The final result is calculated from all partial results using a logical OR.

boolean isForcingVanillaMovementInput(
    IsForcingVanillaMovementInputContext context
)

Parameters

  • context - The context of this callback

Returns

  • boolean - true when modifications should be disabled

Since 4.17.0

IPlayerStateCallback

This callback allows providing the raw input state that Shoulder Surfing uses to determine whether the player is attacking, interacting with an item, or picking (mouse middle click). It does not define what should happen — Shoulder Surfing decides that based on its own logic. For example, a controller mod can report that the attack input is pressed using isAttacking, without caring what Shoulder Surfing does in response. Consider using a different API if you want to control the exact behavior. The exact behavior when any of these is true is handled entirely by Shoulder Surfing. The final result is calculated from all partial results using a logical OR. If no callback provides a definitive result, the default logic is used.

Result isAttacking(
	IsAttackingContext context
)

Parameters

  • context - The arguments of this callback

Returns

  • Result - The result state. Either TRUE, FALSE or PASS.

Since 4.15.0


Result isInteracting(
	IsInteractingContext context
)

Parameters

  • context - The arguments of this callback

Returns

  • Result - The result state. Either TRUE, FALSE or PASS.

Since 4.15.0


Result isPicking(
	IsPickingContext context
)

Parameters

  • context - The arguments of this callback

Returns

  • Result - The result state. Either TRUE, FALSE or PASS.

Since 4.15.0


Result isUsingItem(
	IsUsingContext context
)

Parameters

  • context - The arguments of this callback

Returns

  • Result - The result state. Either TRUE, FALSE or PASS.

Since 4.15.0


Result isRidingBoat(
	IsRidingBoatContext context
)

Parameters

  • context - The arguments of this callback

Returns

  • Result - The result state. Either TRUE, FALSE or PASS.

Since 4.17.0

ITargetCameraOffsetCallback

This callback can be used to implement custom target camera offsets. There are two distinct methods, invoked at different time steps of the camera offset calculation. Both methods provide a default NOP implementation.

Vec3 pre(
    IShoulderSurfing instance,
    Vec3 targetOffset,
    Vec3 defaultOffset
)

Parameters

  • instance - The IShoulderSurfing instance
  • targetOffset - The target offset for the camera
  • defaultOffset - The default offset for the camera, without any prior modifications

Returns

  • Vec3 - The modified target offset for the camera

Since 4.1.0


Vec3 post(
    IShoulderSurfing instance,
    Vec3 targetOffset,
    Vec3 defaultOffset
)

Parameters

  • instance - The IShoulderSurfing instance
  • targetOffset - The target offset for the camera, after offset multipliers have been applied
  • defaultOffset - The default offset for the camera, without any prior modifications

Returns

  • Vec3 - The modified target offset for the camera

Since 4.1.0

Clone this wiki locally