Class RegistrationFailedException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
net.neoforged.neoforge.network.registration.RegistrationFailedException
All Implemented Interfaces:
Serializable

public class RegistrationFailedException extends RuntimeException
Defines an exception that can be thrown at runtime, if a modder has registered a payload incorrectly. In practice there are three reasons this exception can be thrown:
  • The payload id is already registered.
  • The payload id is registered in the wrong namespace.
  • Some other unknown reason.
The reason for the exception can be determined by the RegistrationFailedException.Reason enum.

Note: this exception is a runtime exception, meaning that it does not need to be caught. It is not recommended that this exception is caught, since it is a sign of a programming error.

See Also:
  • Field Details

  • Constructor Details

    • RegistrationFailedException

      @Internal public RegistrationFailedException(ResourceLocation id, String namespace, RegistrationFailedException.Reason reason)
      Creates a new exception with the given parameters. The reason can not be unknown.
      Parameters:
      id - The id of the payload that was being registered.
      namespace - The namespace the payload was being registered in.
      reason - The reason the registration failed.
    • RegistrationFailedException

      @Internal public RegistrationFailedException(ResourceLocation id, String namespace, Throwable throwable)
      Creates a new exception with the given parameters. Automatically sets the reason to unknown, and passes the given throwable to the super constructor as reason for the exception.
      Parameters:
      id - The id of the payload that was being registered.
      namespace - The namespace the payload was being registered in.
      throwable - The throwable that caused the registration to fail.
  • Method Details

    • getId

      public ResourceLocation getId()
      The id of the payload that was being registered.
      Returns:
      The id of the payload that was being registered.
    • getNamespace

      public String getNamespace()
      The namespace the payload should be registered in.
      Returns:
      The namespace the payload should be registered in.
    • getReason

      The reason the registration failed.
      Returns:
      The reason the registration failed.