Interface GuiParent<T extends GuiParent<?>>

All Known Implementing Classes:
ConstrainedGeometry, GuiButton, GuiColourPicker, GuiColourPicker.ColourPreview, GuiColourPicker.SliderBG, GuiContextMenu, GuiDialog, GuiDVD, GuiElement, GuiEnergyBar, GuiEntityRenderer, GuiEventProvider, GuiFluidTank, GuiItemStack, GuiList, GuiManipulable, GuiProgressIcon, GuiRectangle, GuiScrolling, GuiSlider, GuiSlots, GuiText, GuiTextField, GuiTextList, GuiTexture, ModularGui

public interface GuiParent<T extends GuiParent<?>>
This is the base interface that allows an element or screen to define its basic geometry. As well as defining the primary methods for handling child elements.

It also provides a way to access some common minecraft fields.

Created by brandon3055 on 29/06/2023

  • Method Details

    • xMin

      double xMin()
      Returns:
      The position of the Left edge of this element.
    • xMax

      double xMax()
      Returns:
      The position of the Right edge of this element.
    • xSize

      double xSize()
      Returns:
      The Width of this element.
    • yMin

      double yMin()
      Returns:
      The position of the Top edge of this element.
    • yMax

      double yMax()
      Returns:
      The position of the Bottom edge of this element.
    • ySize

      double ySize()
      Returns:
      The Height of this element.
    • get

      default GeoRef get(GeoParam param)
      Returns a reference to the specified geometry parameter. This is primarily used when defining geometry constraints. But it can also be used as a simple Supplier<Integer> that will return the current parameter value when requested.

      Note: The returned geometry reference will always be valid

      Parameters:
      param - The geometry parameter.
      Returns:
      A Geometry Reference
    • getValue

      default double getValue(GeoParam param)
      Parameters:
      param - The geometry parameter.
      Returns:
      The current value of the specified parameter.
    • getChildren

      List<GuiElement<?>> getChildren()
      Returns:
      An unmodifiable list of all assigned child elements assigned to this parent. The list should be sorted in the order they were added.
    • addChild

      void addChild(GuiElement<?> child)
      Adds a new child element to this parent. You should almost never need to use this because this is handled automatically when an element is created.

      Note: Due to the way relative coordinates work with the new geometry system, Transferring an element to a different parent can have unpredictable results. Therefor, to help avoid confusion it is not possible to transfer a child to a new parent using this method.

      Parameters:
      child - The child element to be added.
      Throws:
      UnsupportedOperationException - - If child has previously been assigned to a different parent.
      See Also:
    • addChild

      @Experimental default T addChild(Consumer<T> createChild)
      This meant to be a convenience method that allows builder style addition of a child element. I'm not sure how useful it will be yet, so it may or may not stay.
      Parameters:
      createChild - A consumer that is given this element to be used in the construction of the child element.
      Returns:
      The parent element
    • adoptChild

      void adoptChild(GuiElement<?> child)
      This method can be used to transfer an already initialized child to this parent element. This automatically handles removing the element from its previous parent, adds it to this element. Note: This will most likely break any relative constraints on the child's geometry. To fix this you will need to re-apply geometry constraints after the transfer.
      Parameters:
      child - The child element to be adopted.
    • removeChild

      void removeChild(GuiElement<?> child)
      Allows the removal of a child element. Child removal is not instantaneous, Instead all removals occur at the end of the current screen thick. This is to avoid any possible concurrency issues.
      Parameters:
      child - The child element to be removed.
    • isDescendantOf

      default boolean isDescendantOf(GuiElement<?> ancestor)
      Checks if this element is a descendant of the specified.
      Returns:
      true if the specified element is a parent or grandparent etc... of this element.
    • mc

      net.minecraft.client.Minecraft mc()
      Returns:
      The minecraft instance.
    • font

      net.minecraft.client.gui.Font font()
      Returns:
      The active font instance.
    • scaledScreenWidth

      int scaledScreenWidth()
      Returns:
      The current gui screen width, As returned by mc.getWindow().getGuiScaledWidth()
    • scaledScreenHeight

      int scaledScreenHeight()
      Returns:
      The current gui screen height, As returned by mc.getWindow().getGuiScaledHeight()
    • getModularGui

      ModularGui getModularGui()
      Returns:
      the parent ModularGui instance.
    • onScreenInit

      default void onScreenInit(net.minecraft.client.Minecraft mc, net.minecraft.client.gui.Font font, int screenWidth, int screenHeight)
      Called when the minecraft Screen is initialised or resized.
      Parameters:
      mc - The Minecraft instance.
      font - The active font.
      screenWidth - The current guiScaledWidth.
      screenHeight - The current guiScaledHeight.
    • blockMouseOver

      default boolean blockMouseOver(GuiElement<?> element, double mouseX, double mouseY)
      Allows an element to override the GuiElement.isMouseOver() method of its children. This is primarily used for things like scroll elements where mouseover interactions need to be blocked outside the view area.
      Parameters:
      element - The element on which isMouseOver is getting called.
      Returns:
      true if mouse-over interaction should be blocked for this child element.