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_PROTOCOLS
protected List<AbstractButtonWidget>
buttons
protected List<Element>
children
private URI
clickedLink
protected MinecraftClient
client
int
height
protected ItemRenderer
itemRenderer
private static Logger
LOGGER
boolean
passEvents
protected TextRenderer
textRenderer
protected Text
title
int
width
Fields 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 void
confirmLink(boolean open)
void
filesDragged(List<Path> paths)
String
getNarrationMessage()
Text
getTitle()
List<Text>
getTooltipFromItem(ItemStack stack)
boolean
handleTextClick(Style style)
static boolean
hasAltDown()
static boolean
hasControlDown()
static boolean
hasShiftDown()
protected void
init()
Called when a screen should be initialized.void
init(MinecraftClient client, int width, int height)
protected void
insertText(String text, boolean override)
static boolean
isCopy(int code)
static boolean
isCut(int code)
boolean
isMouseOver(double mouseX, double mouseY)
Checks if the mouse position is within the bound of the element.static boolean
isPaste(int code)
boolean
isPauseScreen()
static boolean
isSelectAll(int code)
protected boolean
isValidCharacterForName(String name, char character, int cursorPos)
boolean
keyPressed(int keyCode, int scanCode, int modifiers)
Callback for when a key down event has been captured.void
onClose()
private void
openLink(URI link)
void
removed()
void
render(MatrixStack matrices, int mouseX, int mouseY, float delta)
void
renderBackground(MatrixStack matrices)
Renders the background of this screen.void
renderBackground(MatrixStack matrices, int vOffset)
Renders the background of this screen.void
renderBackgroundTexture(int vOffset)
Renders the fullscreen background texture of this screen.void
renderOrderedTooltip(MatrixStack matrices, List<? extends OrderedText> lines, int x, int y)
protected void
renderTextHoverEffect(MatrixStack matrices, Style style, int x, int y)
void
renderTooltip(MatrixStack matrices, List<Text> lines, int x, int y)
protected void
renderTooltip(MatrixStack matrices, ItemStack stack, int x, int y)
void
renderTooltip(MatrixStack matrices, Text text, int x, int y)
void
resize(MinecraftClient client, int width, int height)
void
sendMessage(String message)
void
sendMessage(String message, boolean toHud)
boolean
shouldCloseOnEsc()
Checks whether this screen should be closed when the escape key is pressed.void
tick()
static void
wrapScreenError(Runnable task, String errorTitle, String screenName)
Methods inherited from class net.minecraft.client.gui.AbstractParentElement
getFocused, isDragging, setDragging, setFocused
Methods 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, setZOffset
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraft.client.gui.Element
mouseMoved
Methods 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 inGLFW
class.- Specified by:
keyPressed
in interfaceElement
- Specified by:
keyPressed
in interfaceParentElement
- Parameters:
keyCode
- the named key code of the event as described in theGLFW
classscanCode
- the unique/platform-specific scan code of the keyboard inputmodifiers
- a GLFW bitfield describing the modifier keys that are held down (see {@linkplain https://www.glfw.org/docs/3.3/group__mods.html GLFW Modifier key flags})- Returns:
true
to 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
-
getTooltipFromItem
-
renderTooltip
-
renderTooltip
-
renderOrderedTooltip
public void renderOrderedTooltip(MatrixStack matrices, List<? extends OrderedText> lines, int x, int y) -
renderTextHoverEffect
-
insertText
-
handleTextClick
-
sendMessage
-
sendMessage
-
init
-
children
Gets a list of all child GUI elements.- Specified by:
children
in 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:
tick
in 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:
isMouseOver
in interfaceElement
- Parameters:
mouseX
- the X coordinate of the mousemouseY
- the Y coordinate of the mouse- Returns:
true
if the mouse is within the bound of the element, otherwisefalse
-
filesDragged
-