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:
- Title and subtitle system, see:
- Automatically adds a back button when set inside the constructor
- Helper functions:
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
FieldsFields 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 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRefreshButton(Runnable click) voidextractRenderState(@NonNull net.minecraft.client.gui.GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) net.minecraft.client.gui.screens.Screenget(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.PlainTextButtonprotected voidinit()voidonClose()voidopen(net.minecraft.client.gui.screens.Screen prevScreen) Intended method to open a VFP screenvoidrenderScreenTitle(net.minecraft.client.gui.GuiGraphicsExtractor context) voidrenderSubtitle(net.minecraft.client.gui.GuiGraphicsExtractor context) Renders the subtitle that doesn't have a press actionvoidrenderTitle(net.minecraft.client.gui.GuiGraphicsExtractor context) Renders the ViaFabricPlus titlestatic voidsetScreen(net.minecraft.client.gui.screens.Screen screen) voidSets 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 screenvoidsetupSubtitle(@Nullable net.minecraft.network.chat.Component subtitle) Sets the subtitle and the subtitle press actionvoidsetupSubtitle(@Nullable net.minecraft.network.chat.Component subtitle, net.minecraft.client.gui.components.Button.OnPress subtitlePressAction) Sets the subtitle and the subtitle press actionvoidsetupUrlSubtitle(String subtitle) Sets the subtitle and the subtitle press action to the default valuesstatic voidshowErrorScreen(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 throwableprotected booleanMethods 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, updateNarratorStatusMethods inherited from class net.minecraft.client.gui.components.events.AbstractContainerEventHandler
getFocused, isDragging, setDragging, setFocusedMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.client.gui.components.events.ContainerEventHandler
charTyped, getBorderForArrowNavigation, getChildAt, getCurrentFocusPath, isFocused, keyReleased, mouseClicked, mouseDragged, mouseReleased, mouseScrolled, nextFocusPath, preeditUpdated, setFocusedMethods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
mouseMoved, shouldTakeFocusAfterInteractionMethods inherited from interface net.minecraft.client.gui.components.TabOrderedElement
getTabOrderGroup
-
Field Details
-
prevScreen
public net.minecraft.client.gui.screens.Screen prevScreen
-
-
Constructor Details
-
VFPScreen
-
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
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 renderedsubtitlePressAction- 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:
initin classnet.minecraft.client.gui.screens.Screen
-
addRefreshButton
-
extractRenderState
public void extractRenderState(@NonNull net.minecraft.client.gui.GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) - Specified by:
extractRenderStatein interfacenet.minecraft.client.gui.components.Renderable- Overrides:
extractRenderStatein classnet.minecraft.client.gui.screens.Screen
-
onClose
public void onClose()- Overrides:
onClosein classnet.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 screenthrowable- The throwable that should be thrownnext- The screen that should be opened after the error screen is closed
-