Class VFPScreen

java.lang.Object
net.minecraft.client.gui.components.events.AbstractContainerEventHandler
net.minecraft.client.gui.screens.Screen
com.viaversion.viafabricplus.screen.VFPScreen
All Implemented Interfaces:
net.minecraft.client.gui.components.events.ContainerEventHandler, net.minecraft.client.gui.components.events.GuiEventListener, net.minecraft.client.gui.components.Renderable, net.minecraft.client.gui.components.TabOrderedElement
Direct Known Subclasses:
AcceptInvitationCodeScreen, BedrockRealmsScreen, BetaCraftScreen, ClassiCubeLoginScreen, ClassiCubeMFAScreen, ClassiCubeServerListScreen, PerServerVersionScreen, ProtocolSelectionScreen, ReportIssuesScreen, ServerListScreen, SettingsScreen

public class VFPScreen extends net.minecraft.client.gui.screens.Screen
This class is a wrapper for the Screen class which provides some global functions and features used in all screens which are added by ViaFabricPlus.

Features:

Terminology:

Instead of creating the screen every time it needs to be opened, the screen is created once and hold by a static field and later opened by calling the open(Screen) method.

  • Nested Class Summary

    Nested classes/interfaces inherited from class net.minecraft.client.gui.screens.Screen

    net.minecraft.client.gui.screens.Screen.NarratableSearchResult
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    net.minecraft.client.gui.screens.Screen
     

    Fields inherited from class net.minecraft.client.gui.screens.Screen

    FADE_IN_TIME, font, FOOTER_SEPARATOR, HEADER_SEPARATOR, height, INWORLD_FOOTER_SEPARATOR, INWORLD_HEADER_SEPARATOR, MENU_BACKGROUND, minecraft, narratorButton, screenExecutor, title, width
  • Constructor Summary

    Constructors
    Constructor
    Description
    VFPScreen(String title, boolean backButton)
     
    VFPScreen(net.minecraft.network.chat.Component title, boolean backButton)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    extractRenderState(@NonNull net.minecraft.client.gui.GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a)
     
    net.minecraft.client.gui.screens.Screen
    get(net.minecraft.client.gui.screens.Screen prevScreen)
    Returns this screen instance after setting the previous screen.
    @Nullable net.minecraft.network.chat.Component
     
    @Nullable net.minecraft.client.gui.components.PlainTextButton
     
    protected void
     
    void
     
    void
    open(net.minecraft.client.gui.screens.Screen prevScreen)
    Intended method to open a VFP screen
    void
    renderScreenTitle(net.minecraft.client.gui.GuiGraphicsExtractor context)
     
    void
    renderSubtitle(net.minecraft.client.gui.GuiGraphicsExtractor context)
    Renders the subtitle that doesn't have a press action
    void
    renderTitle(net.minecraft.client.gui.GuiGraphicsExtractor context)
    Renders the ViaFabricPlus title
    static void
    setScreen(net.minecraft.client.gui.screens.Screen screen)
     
    void
    Sets the subtitle and the subtitle press action to the default values The default value of the subtitle is the url to the GitHub repository of VFP The default value of the subtitle press action is to open the url in a confirmation screen
    void
    setupSubtitle(@Nullable net.minecraft.network.chat.Component subtitle)
    Sets the subtitle and the subtitle press action
    void
    setupSubtitle(@Nullable net.minecraft.network.chat.Component subtitle, net.minecraft.client.gui.components.Button.OnPress subtitlePressAction)
    Sets the subtitle and the subtitle press action
    void
    Sets the subtitle and the subtitle press action to the default values
    static void
    showErrorScreen(net.minecraft.network.chat.Component title, Throwable throwable, net.minecraft.client.gui.screens.Screen next)
    Opens an error screen with a specific title and throws the given throwable
    protected boolean
     

    Methods inherited from class net.minecraft.client.gui.screens.Screen

    added, addRenderableOnly, addRenderableWidget, addWidget, afterKeyboardAction, afterMouseAction, afterMouseMove, canInterruptWithAnotherScreen, changeFocus, children, clearFocus, clearWidgets, clickCommandAction, clickUrlAction, defaultHandleClickEvent, defaultHandleGameClickEvent, extractBackground, extractBlurredBackground, extractMenuBackground, extractMenuBackground, extractMenuBackgroundTexture, extractPanorama, extractRenderStateWithTooltipAndSubtitles, extractTransparentBackground, fadeWidgets, fillCrashDetails, findNarratableWidget, getBackgroundMusic, getFont, getNarrationMessage, getRectangle, getTitle, getTooltipFromItem, getUsageNarration, handleDelayedNarration, init, insertText, isAllowedInPortal, isInGameUi, isMouseOver, isPauseScreen, isValidCharacterForName, keyPressed, onFilesDrop, rebuildWidgets, removed, removeWidget, repositionElements, resize, setInitialFocus, setInitialFocus, shouldCloseOnEsc, shouldNarrateNavigation, showsActiveEffects, tick, triggerImmediateNarration, updateNarratedWidget, updateNarrationState, updateNarratorStatus

    Methods inherited from class net.minecraft.client.gui.components.events.AbstractContainerEventHandler

    getFocused, isDragging, setDragging, setFocused

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.minecraft.client.gui.components.events.ContainerEventHandler

    charTyped, getBorderForArrowNavigation, getChildAt, getCurrentFocusPath, isFocused, keyReleased, mouseClicked, mouseDragged, mouseReleased, mouseScrolled, nextFocusPath, preeditUpdated, setFocused

    Methods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener

    mouseMoved, shouldTakeFocusAfterInteraction

    Methods inherited from interface net.minecraft.client.gui.components.TabOrderedElement

    getTabOrderGroup
  • Field Details

    • prevScreen

      public net.minecraft.client.gui.screens.Screen prevScreen
  • Constructor Details

    • VFPScreen

      public VFPScreen(String title, boolean backButton)
    • VFPScreen

      public VFPScreen(net.minecraft.network.chat.Component title, boolean backButton)
  • Method Details

    • setupDefaultSubtitle

      public void setupDefaultSubtitle()
      Sets the subtitle and the subtitle press action to the default values The default value of the subtitle is the url to the GitHub repository of VFP The default value of the subtitle press action is to open the url in a confirmation screen
    • setupUrlSubtitle

      public void setupUrlSubtitle(String subtitle)
      Sets the subtitle and the subtitle press action to the default values
      Parameters:
      subtitle - The subtitle which should be rendered
    • setupSubtitle

      public void setupSubtitle(@Nullable @Nullable net.minecraft.network.chat.Component subtitle)
      Sets the subtitle and the subtitle press action
      Parameters:
      subtitle - The subtitle that should be rendered
    • setupSubtitle

      public void setupSubtitle(@Nullable @Nullable net.minecraft.network.chat.Component subtitle, @Nullable net.minecraft.client.gui.components.Button.OnPress subtitlePressAction)
      Sets the subtitle and the subtitle press action
      Parameters:
      subtitle - The subtitle that should be rendered
      subtitlePressAction - The press action that should be executed when the subtitle is clicked
    • open

      public void open(net.minecraft.client.gui.screens.Screen prevScreen)
      Intended method to open a VFP screen
      Parameters:
      prevScreen - The current screen from which the VFP screen is opened
    • get

      public net.minecraft.client.gui.screens.Screen get(net.minecraft.client.gui.screens.Screen prevScreen)
      Returns this screen instance after setting the previous screen.
      Parameters:
      prevScreen - The screen to return to when this screen is closed
      Returns:
      This screen instance
    • setScreen

      public static void setScreen(net.minecraft.client.gui.screens.Screen screen)
    • init

      protected void init()
      Overrides:
      init in class net.minecraft.client.gui.screens.Screen
    • addRefreshButton

      public void addRefreshButton(Runnable click)
    • extractRenderState

      public void extractRenderState(@NonNull net.minecraft.client.gui.GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a)
      Specified by:
      extractRenderState in interface net.minecraft.client.gui.components.Renderable
      Overrides:
      extractRenderState in class net.minecraft.client.gui.screens.Screen
    • onClose

      public void onClose()
      Overrides:
      onClose in class net.minecraft.client.gui.screens.Screen
    • renderTitle

      public void renderTitle(net.minecraft.client.gui.GuiGraphicsExtractor context)
      Renders the ViaFabricPlus title
      Parameters:
      context - The current draw context
    • renderSubtitle

      public void renderSubtitle(net.minecraft.client.gui.GuiGraphicsExtractor context)
      Renders the subtitle that doesn't have a press action
      Parameters:
      context - The current draw context
    • subtitleCentered

      protected boolean subtitleCentered()
    • renderScreenTitle

      public void renderScreenTitle(net.minecraft.client.gui.GuiGraphicsExtractor context)
    • getSubtitle

      @Nullable public @Nullable net.minecraft.network.chat.Component getSubtitle()
    • getSubtitleWidget

      @Nullable public @Nullable net.minecraft.client.gui.components.PlainTextButton getSubtitleWidget()
    • showErrorScreen

      public static void showErrorScreen(net.minecraft.network.chat.Component title, Throwable throwable, net.minecraft.client.gui.screens.Screen next)
      Opens an error screen with a specific title and throws the given throwable
      Parameters:
      title - The title of the error screen
      throwable - The throwable that should be thrown
      next - The screen that should be opened after the error screen is closed