Class TScreenWrapper<T extends TScreen>
- All Implemented Interfaces:
net.minecraft.client.gui.Drawable
,net.minecraft.client.gui.Element
,net.minecraft.client.gui.navigation.Navigable
,net.minecraft.client.gui.ParentElement
TScreenWrapper
serves as an adapter for the TScreen
class. This class extends Minecraft's Screen
class and translates
calls from the Minecraft engine into calls on the TScreen
instances.
The purpose of this class is to isolate TScreen
from Minecraft's
GUI code, making the mod more resilient to changes in the game's code. This
isolation makes TScreen
act like a Screen
, but in a more controlled
and independent way, similar to how custom rendering engines interact with rendering APIs.
This class should remain thin, serving only as a pass-through layer to
TScreen
. All interactions with the Screen
class that the mod
needs should be encapsulated within this class, keeping TScreen
unaware of Minecraft's GUI code.
Important:
If you wish to implement listener interfaces such as IStatsListener
,
then you may extend this class and create your own TScreenWrapper
implementation.
However, avoid interacting with Minecraft's Screen
code as much as possible!
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.client.gui.screen.Screen
net.minecraft.client.gui.screen.Screen.SelectedElementNarrationData
-
Field Summary
Modifier and TypeFieldDescriptionprotected @Nullable net.minecraft.client.util.Window
protected final T
Fields inherited from class net.minecraft.client.gui.screen.Screen
client, executor, FOOTER_SEPARATOR_TEXTURE, HEADER_SEPARATOR_TEXTURE, height, INWORLD_FOOTER_SEPARATOR_TEXTURE, INWORLD_HEADER_SEPARATOR_TEXTURE, MENU_BACKGROUND_TEXTURE, PANORAMA_RENDERER, ROTATING_PANORAMA_RENDERER, textRenderer, title, width
Fields inherited from interface net.minecraft.client.gui.Element
MAX_DOUBLE_CLICK_INTERVAL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
applyBlur
(float delta) final boolean
charTyped
(char chr, int modifiers) protected final void
final void
close()
InvokesTScreen.close()
on thegetTargetTScreen()
.final void
filesDragged
(List<Path> paths) final T
final net.minecraft.text.Text
getTitle()
protected final void
init()
protected final boolean
input
(TInputContext inputContext) An input handling system that mimics the mechanics of DOM.
By default, inputs are "forwarded" to the appropriate "target" GUI elements, after which the events "bubbles" towards the "root" akaTScreen
.protected final boolean
inputMainPhase
(TParentElement targetElement, TInputContext inputContext) Similar toinputMainPhaseBubble(TParentElement, TInputContext)
, except the input is not "bubbled" to parent elements.protected final @Nullable TParentElement
inputMainPhaseBubble
(TParentElement targetElement, TInputContext inputContext) Forwards an input to a target element, after which the input "bubbles" towards the "root"TParentElement
.final boolean
keyPressed
(int keyCode, int scanCode, int modifiers) final boolean
keyReleased
(int keyCode, int scanCode, int modifiers) final boolean
mouseClicked
(double mouseX, double mouseY, int button) final boolean
mouseDragged
(double mouseX, double mouseY, int button, double deltaX, double deltaY) final void
mouseMoved
(double mouseX, double mouseY) final boolean
mouseReleased
(double mouseX, double mouseY, int button) final boolean
mouseScrolled
(double mouseX, double mouseY, double hAmount, double vAmount) final void
render
(net.minecraft.client.gui.DrawContext drawContext, int mouseX, int mouseY, float deltaTime) final void
renderBackground
(net.minecraft.client.gui.DrawContext context, int mouseX, int mouseY, float delta) final void
renderDarkening
(net.minecraft.client.gui.DrawContext context) final void
renderPanoramaBackground
(net.minecraft.client.gui.DrawContext context, float delta) final void
resize
(net.minecraft.client.MinecraftClient client, int width, int height) final void
final void
Screen_super_renderBackground
(net.minecraft.client.gui.DrawContext context, int mouseX, int mouseY, float delta) final boolean
Returns false to fix the ESC input handling bug that prevents GUI elements from handling the key-press.
Please refer toTScreen.shouldCloseOnEsc()
instead.final boolean
final void
tick()
Methods inherited from class net.minecraft.client.gui.screen.Screen
addDrawable, addDrawableChild, addElementNarrations, addScreenNarrations, addSelectableChild, applyKeyPressNarratorDelay, applyMouseMoveNarratorDelay, applyMousePressScrollNarratorDelay, applyNarratorModeChangeDelay, blur, children, clearAndInit, clearTooltip, findSelectedElementData, getMusic, getNarratedTitle, getNavigationFocus, getPanoramaTickDelta, getTooltipFromItem, getUsageNarrationText, handleTextClick, hasAltDown, hasControlDown, hasShiftDown, hasUsageText, init, initTabNavigation, insertText, isCopy, isCut, isMouseOver, isPaste, isSelectAll, isValidCharacterForName, narrateScreenIfNarrationEnabled, onDisplayed, remove, removed, renderBackgroundTexture, renderDarkening, renderInGameBackground, renderWithTooltip, setInitialFocus, setInitialFocus, setTooltip, setTooltip, setTooltip, setTooltip, switchFocus, updateNarrator, wrapScreenError
Methods inherited from class net.minecraft.client.gui.AbstractParentElement
getFocused, isDragging, setDragging, setFocused
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.navigation.Navigable
getNavigationOrder
Methods inherited from interface net.minecraft.client.gui.ParentElement
getFocusedPath, getNavigationPath, hoveredElement, isFocused, setFocused
-
Field Details
-
target
-
clientWindow
@Nullable protected @Nullable net.minecraft.client.util.Window clientWindow
-
-
Constructor Details
-
TScreenWrapper
-
-
Method Details
-
getTargetTScreen
-
Screen_super_close
public final void Screen_super_close() -
getTitle
public final net.minecraft.text.Text getTitle()- Overrides:
getTitle
in classnet.minecraft.client.gui.screen.Screen
-
shouldPause
public final boolean shouldPause()- Overrides:
shouldPause
in classnet.minecraft.client.gui.screen.Screen
-
shouldCloseOnEsc
public final boolean shouldCloseOnEsc()Returns false to fix the ESC input handling bug that prevents GUI elements from handling the key-press.
Please refer toTScreen.shouldCloseOnEsc()
instead.- Overrides:
shouldCloseOnEsc
in classnet.minecraft.client.gui.screen.Screen
-
close
public final void close()InvokesTScreen.close()
on thegetTargetTScreen()
.- Overrides:
close
in classnet.minecraft.client.gui.screen.Screen
- See Also:
-
init
protected final void init()- Overrides:
init
in classnet.minecraft.client.gui.screen.Screen
-
clearChildren
protected final void clearChildren()- Overrides:
clearChildren
in classnet.minecraft.client.gui.screen.Screen
-
tick
public final void tick()- Overrides:
tick
in classnet.minecraft.client.gui.screen.Screen
-
Screen_super_renderBackground
public final void Screen_super_renderBackground(net.minecraft.client.gui.DrawContext context, int mouseX, int mouseY, float delta) -
renderBackground
public final void renderBackground(net.minecraft.client.gui.DrawContext context, int mouseX, int mouseY, float delta) - Overrides:
renderBackground
in classnet.minecraft.client.gui.screen.Screen
-
renderPanoramaBackground
public final void renderPanoramaBackground(net.minecraft.client.gui.DrawContext context, float delta) - Overrides:
renderPanoramaBackground
in classnet.minecraft.client.gui.screen.Screen
-
applyBlur
public final void applyBlur(float delta) - Overrides:
applyBlur
in classnet.minecraft.client.gui.screen.Screen
-
renderDarkening
public final void renderDarkening(net.minecraft.client.gui.DrawContext context) - Overrides:
renderDarkening
in classnet.minecraft.client.gui.screen.Screen
-
render
public final void render(net.minecraft.client.gui.DrawContext drawContext, int mouseX, int mouseY, float deltaTime) - Specified by:
render
in interfacenet.minecraft.client.gui.Drawable
- Overrides:
render
in classnet.minecraft.client.gui.screen.Screen
-
keyPressed
public final boolean keyPressed(int keyCode, int scanCode, int modifiers) - Specified by:
keyPressed
in interfacenet.minecraft.client.gui.Element
- Specified by:
keyPressed
in interfacenet.minecraft.client.gui.ParentElement
- Overrides:
keyPressed
in classnet.minecraft.client.gui.screen.Screen
-
keyReleased
public final boolean keyReleased(int keyCode, int scanCode, int modifiers) -
charTyped
public final boolean charTyped(char chr, int modifiers) -
mouseClicked
public final boolean mouseClicked(double mouseX, double mouseY, int button) -
mouseReleased
public final boolean mouseReleased(double mouseX, double mouseY, int button) -
mouseMoved
public final void mouseMoved(double mouseX, double mouseY) -
mouseDragged
public final boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) -
mouseScrolled
public final boolean mouseScrolled(double mouseX, double mouseY, double hAmount, double vAmount) -
input
An input handling system that mimics the mechanics of DOM.
By default, inputs are "forwarded" to the appropriate "target" GUI elements, after which the events "bubbles" towards the "root" akaTScreen
.- Parameters:
inputContext
- TheTInputContext
.
-
inputMainPhaseBubble
@Internal @Nullable protected final @Nullable TParentElement inputMainPhaseBubble(TParentElement targetElement, TInputContext inputContext) Forwards an input to a target element, after which the input "bubbles" towards the "root"TParentElement
.- Parameters:
targetElement
- The initial targetTParentElement
that is supposed to handle the inputinputContext
- TheTInputContext
- Returns:
- The
TParentElement
that eventually ended up handing the input event
-
inputMainPhase
@Internal protected final boolean inputMainPhase(TParentElement targetElement, TInputContext inputContext) Similar toinputMainPhaseBubble(TParentElement, TInputContext)
, except the input is not "bubbled" to parent elements. -
filesDragged
- Overrides:
filesDragged
in classnet.minecraft.client.gui.screen.Screen
-
resize
public final void resize(net.minecraft.client.MinecraftClient client, int width, int height) - Overrides:
resize
in classnet.minecraft.client.gui.screen.Screen
-