Architectury allows you to subscribe to events in your common project, abstracting platform-specific event API's.
Subscriptions are performed in a callback style, similar to Fabric. These callbacks can be made right from your common project's init. Here is an example event that will prevent all damage to any LivingEntity:
EntityEvent.LIVING_HURT.register((LivingEntity entity, DamageSource source, float amount) -> { return EventResult.interruptFalse(); });
Given the above example, things should be pretty self-explanatory assuming you're handy in IDEA. If you jump to the EntityEvent
class you will find all Architectury events nearby. You could also browse the source if you don't have a workspace open - Architecty API Events package on 1.19.2 branch.
The returned EventResult
in the example will interrupt the event, preventing it from propagating - there are, of course, other possible results that you would expect. Check the JavaDoc for EventResult for details.