Data and events

Events

Addons can react to things happening inside the HUD through EymistakenHudEventBus, which your plugin is handed in registerEvents(). That is called once at client init, right after registerHudModules().

Subscribing

MyPluginInit.java
import com.eymistaken.simplecps.HudModuleManager;
import com.eymistaken.simplecps.api.EymistakenHudEventBus;
import com.eymistaken.simplecps.api.EymistakenHudPlugin;
import com.eymistaken.simplecps.api.event.ComboStreakEvent;

public class MyPluginInit implements EymistakenHudPlugin {

    @Override
    public void registerHudModules(HudModuleManager manager) {
        manager.registerModule(new MyCustomModule());
    }

    @Override
    public void registerEvents(EymistakenHudEventBus bus) {
        bus.subscribe(ComboStreakEvent.class, event -> {
            if (event.level() >= 2) {
                playHitSound(event.target());
            }
        });
    }
}

Handlers run on the client thread, inline with whatever caused the event. Keep them short, because anything slow stutters the game. A handler that throws is logged and skipped; it never takes the rest of the mod down with it.

Dispatch is by exact class. Subscribing to a supertype does not receive its subclasses. Subscribing is safe at any point after client init, not just from registerEvents().

Available events

Events live in com.eymistaken.simplecps.api.event.

ComboStreakEventFired when a counted hit pushes the combo into a higher heatmap tier, so once per tier rather than once per hit. See its reference.

Levels and tiers

Levels come from ComboHeatmap and follow the player's Heatmap Difficulty, so level() means the same to you as it does to the on-screen color. The event fires whether or not heatmap coloring is on: that setting decides how the counter looks, not whether the streak happened.

MyPluginInit.java
import com.eymistaken.simplecps.api.ComboHeatmap;

// The thresholds behind the levels, if you want to show them yourself
ComboHeatmap heat = ComboHeatmap.of(SimpleCPSConfig.instance.comboHeatmapMode);
int tier1 = heat.tier1();       // EASY 3, MEDIUM 5, HARD 10
int tier2 = heat.tier2();       // EASY 5, MEDIUM 8, HARD 40
int tier3 = heat.tier3();       // EASY 7, MEDIUM 12, HARD 60
int level = heat.levelFor(17);  // 0 (cold) through 3 (top tier)

With Custom difficulty, the three tiers are the player's own, read from the config on every call.