Class TScreen

All Implemented Interfaces:
INode<TElement>, INodeBounded<TElement,Bounds2i>, INodeRenderable<TElement, TGuiGraphics>, Iterable<TElement>, Collection<TElement>
Direct Known Subclasses:
TCompletableScreen, TScreenPlus

@Environment(CLIENT) public abstract class TScreen extends TElement
An abstraction layer that represents a game's Screen.
See Also:
  • Constructor Details

    • TScreen

      public TScreen(@NotNull @NotNull net.minecraft.network.chat.Component title)
    • TScreen

      public TScreen()
  • Method Details

    • createWrapperScreen

      @Virtual @NotNull protected @NotNull TScreenWrapper<?> createWrapperScreen()
      Creates a TScreenWrapper instance for this TScreen.
      See Also:
    • getAsScreen

      @NotNull public final @NotNull TScreenWrapper<?> getAsScreen()
      Returns the Screen representation of this TScreen.
    • getClient

      @NotNull public final @NotNull net.minecraft.client.Minecraft getClient()
      Returns the Minecraft client instance that last opened this TScreen, if any.
      Overrides:
      getClient in class TElement
    • titleProperty

      public final NotNullProperty<net.minecraft.network.chat.Component> titleProperty()
      Returns the NotNullProperty for this TScreen's title.
    • hoveredElementProperty

      public final ObjectProperty<TElement> hoveredElementProperty()
      Returns the ObjectProperty for the currently mouse-hovered TElement.
      API Note:
      Is read only! Set calls will throw!
    • focusedElementProperty

      public final ObjectProperty<TElement> focusedElementProperty()
      Returns the ObjectProperty for the currently focused TElement.
      API Note:
      Cannot be set to a TElement that is not a child or grandchild of this TScreen.
    • isOpen

      @Contract(pure=true) public final boolean isOpen()
      Returns true if this TScreen is currently opened by a Minecraft client instance.
      See Also:
      • Gui.screen()
    • isPauseScreen

      @Contract(pure=true) @Virtual public boolean isPauseScreen()
      Returns a boolean indicating whether the game should be paused while this TScreen is open.
      API Note:
      Game pausing might not take place in multiplayer.
    • isAllowingInGameHud

      @Contract(pure=true) @Virtual public boolean isAllowingInGameHud()
      Returns true if the in-game HUD (heads-up display) GUI should be rendered while this TScreen is open. If false, the HUD will not be rendered while this TScreen is open.
    • sendInput

      public final boolean sendInput(@NotNull @NotNull TInputContext context)
      Emulates a user input event for this TScreen.
      Parameters:
      context - Information about the user's input.
      Returns:
      true if the input event was handled by a GUI element.
      API Note:
      Does not affect the native GUI.
    • initCallback

      protected abstract void initCallback()
      Description copied from class: TElement
      Callback method that is invoked when this TElement is initializing. You may override this method to create and add child TElements.
      Overrides:
      initCallback in class TElement
      See Also:
    • openCallback

      @Virtual protected void openCallback()
      Callback method that is invoked whenever this TScreen is opened via Gui.setScreen(Screen).
      This takes place before initCallback() is invoked.
      See Also:
      • Screen.added()
    • closeCallback

      @Virtual protected void closeCallback()
      Callback method that is invoked whenever this TScreen is closed via Gui.setScreen(Screen).
      This takes place after close() is invoked.
      See Also:
      • Screen.removed()
    • close

      @Virtual public void close()
      Callback method that is invoked whenever this TScreen is closing. By default, this sets Gui.screen() to null, but you may override this to set another Screen instance if necessary.
      API Note:
      This method must use Gui.setScreen(Screen).