Class RegisterGameTestsEvent

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.RegisterGameTestsEvent
All Implemented Interfaces:
net.neoforged.fml.event.IModBusEvent

public class RegisterGameTestsEvent extends net.neoforged.bus.api.Event implements net.neoforged.fml.event.IModBusEvent
Game tests are registered on client or server startup. It is only run once for a given instance of the game if GameTestHooks.isGametestEnabled() returns true. This is the preferred way to register your game tests.

Fired on the Mod bus, see IModBusEvent.

  • Field Details

    • gameTestMethods

      private final Set<Method> gameTestMethods
  • Constructor Details

    • RegisterGameTestsEvent

      public RegisterGameTestsEvent(Set<Method> gameTestMethods)
  • Method Details

    • register

      public void register(Class<?> testClass)
      Registers an entire class to the game test registry. All methods annotated with GameTest or GameTestGenerator will be registered. If the set of enabled namespaces is non-empty, a method will only be registered if its template namespace is in an enabled namespace.
      Parameters:
      testClass - the test class to register to the game test registry
    • register

      public void register(Method testMethod)
      Registers a single method to the game test registry. The method will only be registered if it is annotated with GameTest or GameTestGenerator. If the set of enabled namespaces is non-empty, the method will only be registered if its template namespace is an enabled namespace.
      Parameters:
      testMethod - the test method to register to the game test registry