Interface ILastScreenProvider

All Known Implementing Classes:
TCompletableScreen, TFileChooserScreen, TTestScreen, TTextDialogScreen

@Environment(CLIENT) public interface ILastScreenProvider
This interface is implemented by TScreens that can provide information about the last Screen instance that was open before them.

This is generally used to open the previous screen when closing the current one.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static @Nullable ILastScreenProvider
    getCurrent(@NotNull net.minecraft.client.Minecraft client)
    A utility method that retrieves the current ILastScreenProvider instance for a Minecraft client.
    @Nullable net.minecraft.client.gui.screens.Screen
    Returns the last Screen instance that was open before this one.
    static @Nullable net.minecraft.client.gui.screens.Screen
    getLastScreen(@Nullable TScreen screen)
    A utility method that retrieves the last Screen from a TScreen instance.
    static @Nullable net.minecraft.client.gui.screens.Screen
    getLastScreen(@Nullable net.minecraft.client.gui.screens.Screen screen)
    A utility method that retrieves the last Screen from a Screen instance.
  • Method Details

    • getLastScreen

      @Nullable @Nullable net.minecraft.client.gui.screens.Screen getLastScreen()
      Returns the last Screen instance that was open before this one.
    • getLastScreen

      @Contract("null -> null; _ -> _") @Nullable static @Nullable net.minecraft.client.gui.screens.Screen getLastScreen(@Nullable @Nullable TScreen screen)
      A utility method that retrieves the last Screen from a TScreen instance.
      Parameters:
      screen - The TScreen instance.
    • getLastScreen

      @Contract("null -> null; _ -> _") @Nullable static @Nullable net.minecraft.client.gui.screens.Screen getLastScreen(@Nullable @Nullable net.minecraft.client.gui.screens.Screen screen)
      A utility method that retrieves the last Screen from a Screen instance.
      Parameters:
      screen - The Screen instance.
    • getCurrent

      @Nullable static @Nullable ILastScreenProvider getCurrent(@NotNull @NotNull net.minecraft.client.Minecraft client) throws NullPointerException
      A utility method that retrieves the current ILastScreenProvider instance for a Minecraft client.

      This method checks if the current screen is an instance of ILastScreenProvider, and if not, it checks if it's an instance of TScreenWrapper that wraps an ILastScreenProvider.

      Parameters:
      client - The Minecraft client.
      Returns:
      Any ILastScreenProvider associated with the current Gui.screen(), if any.
      Throws:
      NullPointerException - If the argument is null.