-
Notifications
You must be signed in to change notification settings - Fork 35
API Documentation v4 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
}
}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
)- minecraft - The Minecraft instance
- entity - The current camera entity
- boolean -
trueif the dynamic crosshair should be displayed,falseif the static crosshair should be displayed
Since 2.3.0
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
)- minecraft - The Minecraft instance
- boolean -
trueif the camera should be coupled,falseif the camera can be decoupled
Since 4.11.0
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.
- instance - The IShoulderSurfing instance
- cameraEntity - The camera entity
- partialTick - The render partial tick
- float - The alpha value to use for camera entity rendering, ranging from
0.0F(invisible) to1.0F(opaque)
Since 4.14.0
This callback can be used to change the camera angle computation. Both methods provide a default NOP implementation.
void pre(
CameraRotationSetupContext context,
CameraRotationSetupResult result
)- context - The arguments of this callback
- result - The result of this callback
Since 4.17.0
void post(
CameraRotationSetupContext context,
CameraRotationSetupResult result
)- context - The arguments of this callback
- result - The result of this callback
Since 4.17.0
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
)- context - The context of this callback
- boolean -
truewhen modifications should be disabled
Since 4.17.0
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
)- context - The arguments of this callback
- Result - The result state. Either
TRUE,FALSEorPASS.
Since 4.15.0
Result isInteracting(
IsInteractingContext context
)- context - The arguments of this callback
- Result - The result state. Either
TRUE,FALSEorPASS.
Since 4.15.0
Result isPicking(
IsPickingContext context
)- context - The arguments of this callback
- Result - The result state. Either
TRUE,FALSEorPASS.
Since 4.15.0
Result isUsingItem(
IsUsingContext context
)- context - The arguments of this callback
- Result - The result state. Either
TRUE,FALSEorPASS.
Since 4.15.0
Result isRidingBoat(
IsRidingBoatContext context
)- context - The arguments of this callback
- Result - The result state. Either
TRUE,FALSEorPASS.
Since 4.17.0
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
)- instance - The IShoulderSurfing instance
- targetOffset - The target offset for the camera
- defaultOffset - The default offset for the camera, without any prior modifications
- Vec3 - The modified target offset for the camera
Since 4.1.0
Vec3 post(
IShoulderSurfing instance,
Vec3 targetOffset,
Vec3 defaultOffset
)- 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
- Vec3 - The modified target offset for the camera
Since 4.1.0