Class Event

java.lang.Object
net.neoforged.bus.api.Event
Direct Known Subclasses:
GenericEvent

public abstract class Event extends Object
Base Event class that all other events are derived from.
Note on abstract events
Listeners cannot be registered to an abstract event class.

This is useful for classes that extend Event with more data and methods, but should never be listened to directly.

For example, an event with Pre and Post subclasses might want to be declared as abstract to prevent user accidentally listening to both.

All the parents of abstract event classes until Event must also be abstract.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static @interface 
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use a custom type and custom methods appropriate for your event, instead of the overly general Event.Result enum.
    static enum 
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value set as the result of this event
    final boolean
    Determines if this event expects a significant result value.
    void
    Sets the result value for this event, not all events can have a result set, and any attempt to set a result for a event that isn't expecting it will result in a IllegalArgumentException.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Event

      protected Event()
  • Method Details

    • hasResult

      public final boolean hasResult()
      Determines if this event expects a significant result value.
    • getResult

      public final Event.Result getResult()
      Returns the value set as the result of this event
    • setResult

      public void setResult(Event.Result value)
      Sets the result value for this event, not all events can have a result set, and any attempt to set a result for a event that isn't expecting it will result in a IllegalArgumentException. The functionality of setting the result is defined on a per-event bases.
      Parameters:
      value - The new result