Class ScreenEvent.Opening

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.client.event.ScreenEvent
net.neoforged.neoforge.client.event.ScreenEvent.Opening
All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent
Enclosing class:
ScreenEvent

public static class ScreenEvent.Opening extends ScreenEvent implements net.neoforged.bus.api.ICancellableEvent
Fired before any Screen is opened, to allow changing it or preventing it from being opened. All screen layers on the screen are closed before this event is fired.

This event is cancellable, and does not

invalid reference
have a result
. If this event is cancelled, then the Screen shall be prevented from opening and any previous screen will remain open. However, cancelling this event will not prevent the closing of screen layers which happened before this event fired.

This event is fired on the main Forge event bus, only on the logical client.

  • Field Details

    • currentScreen

      @Nullable private final @Nullable Screen currentScreen
    • newScreen

      private Screen newScreen
  • Constructor Details

    • Opening

      @Internal public Opening(@Nullable @Nullable Screen currentScreen, Screen screen)
  • Method Details

    • getCurrentScreen

      @Nullable public @Nullable Screen getCurrentScreen()
      Gets the currently open screen at the time of the event being fired.

      May be null if no screen was open.

    • getNewScreen

      @Nullable public @Nullable Screen getNewScreen()
      Returns:
      The screen that will be opened if the event is not cancelled. May be null.
    • setNewScreen

      public void setNewScreen(Screen newScreen)
      Sets the new screen to be opened if the event is not cancelled. May be null.