Enum Class EventResult
- All Implemented Interfaces:
Serializable, Comparable<EventResult>, Constable
A result that can be returned from an event, either allowing the event to continue processing or to cancel the
implementation resulting in vanilla behavior being disrupted.
Can be either used with a combination of PASS and INTERRUPT, or alternatively if three states are
required with PASS, ALLOW and DENY.
For both purposes INTERRUPT and ALLOW can be used interchangeably.
Very similar to vanilla's InteractionResult.
Implementation is also remotely similar to EventResult.java from Architectury API.
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic EventResultallow()static EventResultdeny()booleanstatic EventResultbooleanbooleanisPass()static EventResultpass()static EventResultReturns the enum constant of this class with the specified name.static EventResult[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
PASS
Allows the event to continue processing. It will be passed to both other event implementations and will not prevent vanilla behavior from running. -
INTERRUPT
Prevents the event from processing any further and disrupts vanilla behavior, similar to cancelling an event on Forge.Unprocessed callbacks will be skipped if cancelled.
-
ALLOW
Interrupts the event just likeINTERRUPT. Useful for event implementations that require three states for their cancellation result. -
DENY
Interrupts the event just likeINTERRUPT. Useful for event implementations that require three states for their cancellation result.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getAsBoolean
-
isInterrupt
public boolean isInterrupt()- Returns:
- does this result prevent the vanilla behavior from running
-
isPass
public boolean isPass()- Returns:
- does this result allow for events to continue processing and for vanilla behavior to apply
-
pass
- Returns:
PASS
-
interrupt
- Returns:
INTERRUPT
-
allow
- Returns:
ALLOW
-
deny
- Returns:
DENY
-