Class TScreenWrapper<T extends TScreen>

java.lang.Object
net.minecraft.client.gui.AbstractParentElement
net.minecraft.client.gui.screen.Screen
io.github.thecsdev.tcdcommons.api.client.gui.screen.TScreenWrapper<T>
All Implemented Interfaces:
net.minecraft.client.gui.Drawable, net.minecraft.client.gui.Element, net.minecraft.client.gui.navigation.Navigable, net.minecraft.client.gui.ParentElement

public class TScreenWrapper<T extends TScreen> extends net.minecraft.client.gui.screen.Screen
The 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

    Fields
    Modifier and Type
    Field
    Description
    protected @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, narratorToggleButton, PANORAMA_RENDERER, ROTATING_PANORAMA_RENDERER, textRenderer, title, width

    Fields inherited from interface net.minecraft.client.gui.Element

    MAX_DOUBLE_CLICK_INTERVAL
  • Constructor Summary

    Constructors
    Constructor
    Description
    TScreenWrapper(T target)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    applyBlur(float delta)
     
    final boolean
    charTyped(char chr, int modifiers)
     
    protected final void
     
    final void
    final void
     
    final T
    Returns the target TScreen for this TScreenWrapper.
    final net.minecraft.text.Text
     
    protected final void
     
    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" aka TScreen.
    protected final boolean
    inputMainPhase(TParentElement targetElement, TInputContext inputContext)
    Similar to inputMainPhaseBubble(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 to TScreen.shouldCloseOnEsc() instead.
    final boolean
     
    final void
     

    Methods inherited from class net.minecraft.client.gui.screen.Screen

    addDrawable, addDrawableChild, addElementNarrations, addScreenNarrations, addSelectableChild, applyKeyPressNarratorDelay, applyMouseMoveNarratorDelay, applyMousePressScrollNarratorDelay, blur, children, clearAndInit, clearTooltip, findSelectedElementData, getMusic, getNarratedTitle, getNavigationFocus, getTooltipFromItem, getUsageNarrationText, handleTextClick, hasAltDown, hasControlDown, hasShiftDown, hasUsageText, init, initTabNavigation, insertText, isCopy, isCut, isMouseOver, isPaste, isSelectAll, isValidCharacterForName, narrateScreenIfNarrationEnabled, onDisplayed, refreshNarrator, 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

      protected final T extends TScreen target
    • clientWindow

      @Nullable protected @Nullable net.minecraft.client.util.Window clientWindow
  • Constructor Details

    • TScreenWrapper

      public TScreenWrapper(T target)
  • Method Details

    • getTargetTScreen

      public final T getTargetTScreen()
      Returns the target TScreen for this TScreenWrapper.
    • Screen_super_close

      public final void Screen_super_close()
    • getTitle

      public final net.minecraft.text.Text getTitle()
      Overrides:
      getTitle in class net.minecraft.client.gui.screen.Screen
    • shouldPause

      public final boolean shouldPause()
      Overrides:
      shouldPause in class net.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 to TScreen.shouldCloseOnEsc() instead.
      Overrides:
      shouldCloseOnEsc in class net.minecraft.client.gui.screen.Screen
    • close

      public final void close()
      Overrides:
      close in class net.minecraft.client.gui.screen.Screen
      See Also:
    • init

      protected final void init()
      Overrides:
      init in class net.minecraft.client.gui.screen.Screen
    • clearChildren

      protected final void clearChildren()
      Overrides:
      clearChildren in class net.minecraft.client.gui.screen.Screen
    • tick

      public final void tick()
      Overrides:
      tick in class net.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 class net.minecraft.client.gui.screen.Screen
    • renderPanoramaBackground

      public final void renderPanoramaBackground(net.minecraft.client.gui.DrawContext context, float delta)
      Overrides:
      renderPanoramaBackground in class net.minecraft.client.gui.screen.Screen
    • applyBlur

      public final void applyBlur(float delta)
      Overrides:
      applyBlur in class net.minecraft.client.gui.screen.Screen
    • renderDarkening

      public final void renderDarkening(net.minecraft.client.gui.DrawContext context)
      Overrides:
      renderDarkening in class net.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 interface net.minecraft.client.gui.Drawable
      Overrides:
      render in class net.minecraft.client.gui.screen.Screen
    • keyPressed

      public final boolean keyPressed(int keyCode, int scanCode, int modifiers)
      Specified by:
      keyPressed in interface net.minecraft.client.gui.Element
      Specified by:
      keyPressed in interface net.minecraft.client.gui.ParentElement
      Overrides:
      keyPressed in class net.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

      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" aka TScreen.
      Parameters:
      inputContext - The TInputContext.
    • 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 target TParentElement that is supposed to handle the input
      inputContext - The TInputContext
      Returns:
      The TParentElement that eventually ended up handing the input event
    • inputMainPhase

      @Internal protected final boolean inputMainPhase(TParentElement targetElement, TInputContext inputContext)
      Similar to inputMainPhaseBubble(TParentElement, TInputContext), except the input is not "bubbled" to parent elements.
    • filesDragged

      public final void filesDragged(List<Path> paths)
      Overrides:
      filesDragged in class net.minecraft.client.gui.screen.Screen
    • resize

      public final void resize(net.minecraft.client.MinecraftClient client, int width, int height)
      Overrides:
      resize in class net.minecraft.client.gui.screen.Screen