Package net.minecraft.client.gui.screen
Class Screen
java.lang.Object
net.minecraft.client.gui.DrawableHelper
net.minecraft.client.gui.AbstractParentElement
net.minecraft.client.gui.screen.Screen
- All Implemented Interfaces:
Drawable,Element,ParentElement,TickableElement
- Direct Known Subclasses:
AbstractCommandBlockScreen,AddServerScreen,AdvancementsScreen,BackupPromptScreen,BookEditScreen,BookScreen,ChatScreen,ConfirmScreen,ConnectScreen,CreateWorldScreen,CreditsScreen,CustomizeBuffetLevelScreen,CustomizeFlatLevelScreen,DatapackFailureScreen,DeathScreen,DemoScreen,DialogScreen,DirectConnectScreen,DisconnectedScreen,DownloadingTerrainScreen,EditGameRulesScreen,EditWorldScreen,FatalErrorScreen,GameMenuScreen,GameModeSelectionScreen,GameOptionsScreen,HandledScreen,JigsawBlockScreen,LevelLoadingScreen,MultiplayerScreen,MultiplayerWarningScreen,NoticeScreen,OpenToLanScreen,OptimizeWorldScreen,OptionsScreen,OutOfMemoryScreen,PackScreen,PresetsScreen,ProgressScreen,RealmsScreen,SaveLevelScreen,SelectWorldScreen,SignEditScreen,SocialInteractionsScreen,StatsScreen,StructureBlockScreen,TitleScreen
@Environment(CLIENT) public abstract class Screen extends AbstractParentElement implements TickableElement, Drawable
-
Field Summary
Fields Modifier and Type Field Description private static Set<String>ALLOWED_PROTOCOLSprotected List<AbstractButtonWidget>buttonsprotected List<Element>childrenprivate URIclickedLinkprotected MinecraftClientclientintheightprotected ItemRendereritemRendererprivate static LoggerLOGGERbooleanpassEventsprotected TextRenderertextRendererprotected TexttitleintwidthFields inherited from class net.minecraft.client.gui.DrawableHelper
GUI_ICONS_TEXTURE, OPTIONS_BACKGROUND_TEXTURE, STATS_ICON_TEXTURE -
Constructor Summary
-
Method Summary
Modifier and Type Method Description protected <T extends AbstractButtonWidget>
TaddButton(T button)Adds a button to this screen.protected <T extends Element>
TaddChild(T child)Adds a child element to this screen.List<? extends Element>children()Gets a list of all child GUI elements.private voidconfirmLink(boolean open)voidfilesDragged(List<Path> paths)StringgetNarrationMessage()TextgetTitle()List<Text>getTooltipFromItem(ItemStack stack)booleanhandleTextClick(Style style)static booleanhasAltDown()static booleanhasControlDown()static booleanhasShiftDown()protected voidinit()Called when a screen should be initialized.voidinit(MinecraftClient client, int width, int height)protected voidinsertText(String text, boolean override)static booleanisCopy(int code)static booleanisCut(int code)booleanisMouseOver(double mouseX, double mouseY)Checks if the mouse position is within the bound of the element.static booleanisPaste(int code)booleanisPauseScreen()static booleanisSelectAll(int code)protected booleanisValidCharacterForName(String name, char character, int cursorPos)booleankeyPressed(int keyCode, int scanCode, int modifiers)Callback for when a key down event has been captured.voidonClose()private voidopenLink(URI link)voidremoved()voidrender(MatrixStack matrices, int mouseX, int mouseY, float delta)voidrenderBackground(MatrixStack matrices)Renders the background of this screen.voidrenderBackground(MatrixStack matrices, int vOffset)Renders the background of this screen.voidrenderBackgroundTexture(int vOffset)Renders the fullscreen background texture of this screen.voidrenderOrderedTooltip(MatrixStack matrices, List<? extends OrderedText> lines, int x, int y)protected voidrenderTextHoverEffect(MatrixStack matrices, Style style, int x, int y)voidrenderTooltip(MatrixStack matrices, List<Text> lines, int x, int y)voidrenderTooltip(MatrixStack matrices, List<Text> lines, Optional<TooltipData> data, int x, int y)protected voidrenderTooltip(MatrixStack matrices, ItemStack stack, int x, int y)voidrenderTooltip(MatrixStack matrices, Text text, int x, int y)private voidrenderTooltipFromComponents(MatrixStack matrices, List<TooltipComponent> components, int x, int y)voidresize(MinecraftClient client, int width, int height)voidsendMessage(String message)voidsendMessage(String message, boolean toHud)booleanshouldCloseOnEsc()Checks whether this screen should be closed when the escape key is pressed.voidtick()static voidwrapScreenError(Runnable task, String errorTitle, String screenName)Methods inherited from class net.minecraft.client.gui.AbstractParentElement
getFocused, isDragging, setDragging, setFocusedMethods inherited from class net.minecraft.client.gui.DrawableHelper
drawCenteredString, drawCenteredText, drawHorizontalLine, drawSprite, drawStringWithShadow, drawTexture, drawTexture, drawTexture, drawTexture, drawTextWithShadow, drawVerticalLine, fill, fillGradient, fillGradient, getZOffset, method_29343, method_33284, setZOffsetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.client.gui.Element
mouseMovedMethods inherited from interface net.minecraft.client.gui.ParentElement
changeFocus, charTyped, focusOn, hoveredElement, keyReleased, mouseClicked, mouseDragged, mouseReleased, mouseScrolled, setInitialFocus
-
Field Details
-
LOGGER
-
ALLOWED_PROTOCOLS
-
title
-
children
-
client
-
itemRenderer
-
width
public int width -
height
public int height -
buttons
-
passEvents
public boolean passEvents -
textRenderer
-
clickedLink
-
-
Constructor Details
-
Screen
-
-
Method Details
-
getTitle
-
getNarrationMessage
-
render
-
keyPressed
public boolean keyPressed(int keyCode, int scanCode, int modifiers)Callback for when a key down event has been captured. The key code is identified by the constants inGLFWclass.- Specified by:
keyPressedin interfaceElement- Specified by:
keyPressedin interfaceParentElement- Parameters:
keyCode- the named key code of the event as described in theGLFWclassscanCode- the unique/platform-specific scan code of the keyboard inputmodifiers- a GLFW bitfield describing the modifier keys that are held down (see GLFW Modifier key flags)- Returns:
trueto indicate that the event handling is successful/valid- See Also:
Keyboard.onKey(long, int, int, int, int),GLFW.GLFW_KEY_Q,GLFWKeyCallbackI.invoke(long, int, int, int, int)
-
shouldCloseOnEsc
public boolean shouldCloseOnEsc()Checks whether this screen should be closed when the escape key is pressed. -
onClose
public void onClose() -
addButton
Adds a button to this screen. This method should be preferred overaddChild(Element)since buttons are automatically rendered when added to a screen. -
addChild
Adds a child element to this screen. If the child element is anAbstractButtonWidget, you should useaddButton(AbstractButtonWidget)instead.Adding a child element to a screen does not guarantee the widget is rendered or ticked.
- See Also:
addButton(AbstractButtonWidget)
-
renderTooltip
-
renderTooltip
public void renderTooltip(MatrixStack matrices, List<Text> lines, Optional<TooltipData> data, int x, int y) -
getTooltipFromItem
-
renderTooltip
-
renderTooltip
-
renderOrderedTooltip
public void renderOrderedTooltip(MatrixStack matrices, List<? extends OrderedText> lines, int x, int y) -
renderTooltipFromComponents
private void renderTooltipFromComponents(MatrixStack matrices, List<TooltipComponent> components, int x, int y) -
renderTextHoverEffect
-
insertText
-
handleTextClick
-
sendMessage
-
sendMessage
-
init
-
children
Gets a list of all child GUI elements.- Specified by:
childrenin interfaceParentElement
-
init
protected void init()Called when a screen should be initialized.This method is called when this screen is opened or resized.
-
tick
public void tick()- Specified by:
tickin interfaceTickableElement
-
removed
public void removed() -
renderBackground
Renders the background of this screen.If the client is in a world, renders the translucent background gradient. Otherwise renders the background texture.
-
renderBackground
Renders the background of this screen.If the client is in a world, renders the translucent background gradient. Otherwise renders the background texture.
- Parameters:
vOffset- an offset applied to the V coordinate of the background texture
-
renderBackgroundTexture
public void renderBackgroundTexture(int vOffset)Renders the fullscreen background texture of this screen.- Parameters:
vOffset- an offset applied to the V coordinate of the background texture
-
isPauseScreen
public boolean isPauseScreen() -
confirmLink
private void confirmLink(boolean open) -
openLink
-
hasControlDown
public static boolean hasControlDown() -
hasShiftDown
public static boolean hasShiftDown() -
hasAltDown
public static boolean hasAltDown() -
isCut
public static boolean isCut(int code) -
isPaste
public static boolean isPaste(int code) -
isCopy
public static boolean isCopy(int code) -
isSelectAll
public static boolean isSelectAll(int code) -
resize
-
wrapScreenError
-
isValidCharacterForName
-
isMouseOver
public boolean isMouseOver(double mouseX, double mouseY)Checks if the mouse position is within the bound of the element.- Specified by:
isMouseOverin interfaceElement- Parameters:
mouseX- the X coordinate of the mousemouseY- the Y coordinate of the mouse- Returns:
trueif the mouse is within the bound of the element, otherwisefalse
-
filesDragged
-