@Environment(value=CLIENT) public abstract class Screen extends AbstractParentElement implements TickableElement, Drawable
Modifier and Type | Field and 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 |
GUI_ICONS_TEXTURE, OPTIONS_BACKGROUND_TEXTURE, STATS_ICON_TEXTURE
Modifier and Type | Method and Description |
---|---|
protected <T extends AbstractButtonWidget> |
addButton(T button)
Adds a button to this screen.
|
protected <T extends Element> |
addChild(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) |
protected void |
renderTooltip(MatrixStack matrices,
ItemStack stack,
int x,
int y) |
void |
renderTooltip(MatrixStack matrices,
List<Text> lines,
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) |
getFocused, isDragging, setDragging, setFocused
drawCenteredString, drawCenteredText, drawHorizontalLine, drawSprite, drawStringWithShadow, drawTexture, drawTexture, drawTexture, drawTexture, drawTextWithShadow, drawVerticalLine, fill, fillGradient, fillGradient, getZOffset, method_29343, setZOffset
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
changeFocus, charTyped, focusOn, hoveredElement, keyReleased, mouseClicked, mouseDragged, mouseReleased, mouseScrolled, setInitialFocus
mouseMoved
private static final Logger LOGGER
protected final Text title
@Nullable protected MinecraftClient client
protected ItemRenderer itemRenderer
public int width
public int height
protected final List<AbstractButtonWidget> buttons
public boolean passEvents
protected TextRenderer textRenderer
private URI clickedLink
protected Screen(Text title)
public Text getTitle()
public String getNarrationMessage()
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta)
public boolean keyPressed(int keyCode, int scanCode, int modifiers)
GLFW
class.keyPressed
in interface Element
keyPressed
in interface ParentElement
keyCode
- the named key code of the event as described in the GLFW
classscanCode
- 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)true
to indicate that the event handling is successful/validKeyboard.onKey(long, int, int, int, int)
,
GLFW.GLFW_KEY_Q
,
GLFWKeyCallbackI.invoke(long, int, int, int, int)
public boolean shouldCloseOnEsc()
public void onClose()
protected <T extends AbstractButtonWidget> T addButton(T button)
addChild(Element)
since buttons are automatically rendered when added to a screen.protected <T extends Element> T addChild(T child)
AbstractButtonWidget
, you should use addButton(AbstractButtonWidget)
instead.
Adding a child element to a screen does not guarantee the widget is rendered or ticked.
addButton(AbstractButtonWidget)
protected void renderTooltip(MatrixStack matrices, ItemStack stack, int x, int y)
public void renderTooltip(MatrixStack matrices, Text text, int x, int y)
public void renderTooltip(MatrixStack matrices, List<Text> lines, int x, int y)
public void renderOrderedTooltip(MatrixStack matrices, List<? extends OrderedText> lines, int x, int y)
protected void renderTextHoverEffect(MatrixStack matrices, @Nullable Style style, int x, int y)
protected void insertText(String text, boolean override)
public void sendMessage(String message)
public void sendMessage(String message, boolean toHud)
public void init(MinecraftClient client, int width, int height)
public List<? extends Element> children()
children
in interface ParentElement
protected void init()
This method is called when this screen is opened
or resized.
public void tick()
tick
in interface TickableElement
public void removed()
public void renderBackground(MatrixStack matrices)
If the client is in a world, renders the translucent background gradient. Otherwise renders the background texture.
public void renderBackground(MatrixStack matrices, int vOffset)
If the client is in a world, renders the translucent background gradient. Otherwise renders the background texture.
vOffset
- an offset applied to the V coordinate of the background texturepublic void renderBackgroundTexture(int vOffset)
vOffset
- an offset applied to the V coordinate of the background texturepublic boolean isPauseScreen()
private void confirmLink(boolean open)
private void openLink(URI link)
public static boolean hasControlDown()
public static boolean hasShiftDown()
public static boolean hasAltDown()
public static boolean isCut(int code)
public static boolean isPaste(int code)
public static boolean isCopy(int code)
public static boolean isSelectAll(int code)
public void resize(MinecraftClient client, int width, int height)
public static void wrapScreenError(Runnable task, String errorTitle, String screenName)
protected boolean isValidCharacterForName(String name, char character, int cursorPos)
public boolean isMouseOver(double mouseX, double mouseY)
isMouseOver
in interface Element
mouseX
- the X coordinate of the mousemouseY
- the Y coordinate of the mousetrue
if the mouse is within the bound of the element, otherwise false