Skip to content

API Documentation v5 Events

Exopandora edited this page Jun 10, 2026 · 3 revisions

Events

Events handlers can be used to extend the functionality of Shoulder Surfing Reloaded or implement compatibility features. They can be registered to the event bus in the register method of a Shoulder Surfing plugin (see Plugins).

The following example registers a new ComputePlayerAimStateEventHandler that sets the aiming state to true when the camera entity is holding a stick:

import com.github.exopandora.shouldersurfing.api.client.event.ComputePlayerAimStateEvent;
import com.github.exopandora.shouldersurfing.api.event.IEventBus;
import com.github.exopandora.shouldersurfing.api.plugin.IShoulderSurfingPlugin;

public class ExamplePlugin implements IShoulderSurfingPlugin {
    @Override
    public void register(IEventBus eventBus) {
        eventBus.register((ComputePlayerAimStateEvent event) -> {
            if (!event.getResult()) {
                event.setResult(event.getEntity().getMainHandItem().is(Items.STICK));
            }
        });
    }
}

A list of available event types can be found here.

Examples

Shoulder Surfing Reloaded internally uses the plugin system to implement core functionality. The implementation can be found here.

Clone this wiki locally