Class CompoundEventResult<T>

java.lang.Object
dev.architectury.event.CompoundEventResult<T>
Type Parameters:
T - the type of the extra result

public class CompoundEventResult<T> extends Object
A result from an event, determines if the event should continue to other listeners, determines the outcome of the event, and provides extra result for the outcome.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.InteractionResultHolder<T>
    Returns the Minecraft-facing result, however ignores interruptsFurtherEvaluation().
    static <T> CompoundEventResult<T>
    interrupt(Boolean value, T object)
    Interrupts the event and stops it from being passed on to other listeners, may or may not set an outcome and extra data of the event.
    static <T> CompoundEventResult<T>
    interruptDefault(T object)
    Interrupts the event and stops it from being passed on to other listeners, does not set an outcome and may or may not set an extra data of the event.
    static <T> CompoundEventResult<T>
    interruptFalse(T object)
    Interrupts the event and stops it from being passed on to other listeners, denotes the false outcome and may or may not set an extra data of the event.
    boolean
    Returns whether this result interrupts the evaluation of other listeners.
    static <T> CompoundEventResult<T>
    interruptTrue(T object)
    Interrupts the event and stops it from being passed on to other listeners, denotes the true outcome and may or may not set an extra data of the event.
    boolean
    Returns whether the result does not contain an outcome, may be false only if the event is deterministic.
    boolean
    Returns whether the result contains a false outcome
    boolean
    Returns whether the result contains an outcome, may be true only if the event is deterministic.
    boolean
    Returns whether the result contains a true outcome
    Returns the extra data of the result, an passing result will never contain any extra data.
    static <T> CompoundEventResult<T>
    Passes the event to other listeners, and does not set an outcome of the event.
    Returns the EventResult view of the result, this returns the same values as interruptsFurtherEvaluation() and value().
    Returns the outcome of the result, an passing result will never have an outcome.

    Methods inherited from class java.lang.Object

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

    • pass

      public static <T> CompoundEventResult<T> pass()
      Passes the event to other listeners, and does not set an outcome of the event.
      Type Parameters:
      T - the type of the extra result
      Returns:
      an event that passes the event to other listeners
    • interrupt

      public static <T> CompoundEventResult<T> interrupt(Boolean value, T object)
      Interrupts the event and stops it from being passed on to other listeners, may or may not set an outcome and extra data of the event.
      Parameters:
      value - the outcome of the event, passing null here means the default outcome, which often means falling back to vanilla logic
      object - the extra data of the result, this usually is the returning value of the event
      Returns:
      an event that interrupts the event
    • interruptTrue

      public static <T> CompoundEventResult<T> interruptTrue(T object)
      Interrupts the event and stops it from being passed on to other listeners, denotes the true outcome and may or may not set an extra data of the event.
      Parameters:
      object - the extra data of the result, this usually is the returning value of the event
      Returns:
      an event that interrupts the event
    • interruptDefault

      public static <T> CompoundEventResult<T> interruptDefault(T object)
      Interrupts the event and stops it from being passed on to other listeners, does not set an outcome and may or may not set an extra data of the event.
      Parameters:
      object - the extra data of the result, this usually is the returning value of the event
      Returns:
      an event that interrupts the event
    • interruptFalse

      public static <T> CompoundEventResult<T> interruptFalse(T object)
      Interrupts the event and stops it from being passed on to other listeners, denotes the false outcome and may or may not set an extra data of the event.
      Parameters:
      object - the extra data of the result, this usually is the returning value of the event
      Returns:
      an event that interrupts the event
    • interruptsFurtherEvaluation

      public boolean interruptsFurtherEvaluation()
      Returns whether this result interrupts the evaluation of other listeners.
      Returns:
      whether this result interrupts the evaluation of other listeners
    • value

      public Boolean value()
      Returns the outcome of the result, an passing result will never have an outcome.
      Returns:
      the outcome of the result, returns null if fallback
    • isEmpty

      public boolean isEmpty()
      Returns whether the result does not contain an outcome, may be false only if the event is deterministic.
      Returns:
      whether the result does not contain an outcome
    • isPresent

      public boolean isPresent()
      Returns whether the result contains an outcome, may be true only if the event is deterministic.
      Returns:
      whether the result contains an outcome
    • isTrue

      public boolean isTrue()
      Returns whether the result contains a true outcome
      Returns:
      whether the result contains a true outcome
    • isFalse

      public boolean isFalse()
      Returns whether the result contains a false outcome
      Returns:
      whether the result contains a false outcome
    • result

      public EventResult result()
      Returns the EventResult view of the result, this returns the same values as interruptsFurtherEvaluation() and value().
      Returns:
      the EventResult view of the result.
    • object

      public T object()
      Returns the extra data of the result, an passing result will never contain any extra data.
      Returns:
      the extra data of the result, returns null if passing
    • asMinecraft

      public net.minecraft.world.InteractionResultHolder<T> asMinecraft()
      Returns the Minecraft-facing result, however ignores interruptsFurtherEvaluation().
      Returns:
      the Minecraft-facing result