java.lang.Object
net.minecraft.client.gui.components.AbstractWidget
net.minecraft.client.gui.components.AbstractButton
net.minecraft.client.gui.components.Button
io.github.pixelmk.pixelmkmenu.gui.components.ButtonPanel
All Implemented Interfaces:
net.minecraft.client.gui.components.events.GuiEventListener, net.minecraft.client.gui.components.Renderable, net.minecraft.client.gui.components.TabOrderedElement, net.minecraft.client.gui.layouts.LayoutElement, net.minecraft.client.gui.narration.NarratableEntry, net.minecraft.client.gui.narration.NarrationSupplier, net.neoforged.neoforge.client.extensions.IAbstractWidgetExtension

public class ButtonPanel extends net.minecraft.client.gui.components.Button
Button panels for organising buttons on the menu.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Where the anchor for the button panel is located.

    Nested classes/interfaces inherited from class net.minecraft.client.gui.components.Button

    net.minecraft.client.gui.components.Button.Builder, net.minecraft.client.gui.components.Button.CreateNarration, net.minecraft.client.gui.components.Button.OnPress

    Nested classes/interfaces inherited from interface net.minecraft.client.gui.narration.NarratableEntry

    net.minecraft.client.gui.narration.NarratableEntry.NarrationPriority
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Where to anchor the panel to the screen.
    List of buttons in the panel.
    Previously/currently pressed button in the panel.

    Fields inherited from class net.minecraft.client.gui.components.Button

    BIG_WIDTH, createNarration, DEFAULT_HEIGHT, DEFAULT_NARRATION, DEFAULT_SPACING, DEFAULT_WIDTH, onPress, SMALL_WIDTH

    Fields inherited from class net.minecraft.client.gui.components.AbstractButton

    SPRITES, TEXT_MARGIN

    Fields inherited from class net.minecraft.client.gui.components.AbstractWidget

    active, alpha, height, isHovered, packedFGColor, UNSET_FG_COLOR, visible, width

    Fields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener

    DOUBLE_CLICK_THRESHOLD_MS
  • Constructor Summary

    Constructors
    Constructor
    Description
    ButtonPanel(ButtonPanel.AnchorType anchorType, int offsetX, int offsetY, int width, int height, int buttonSpacing, int containerWidth, int containerHeight, String tag, net.minecraft.client.gui.components.Button.OnPress onPress)
    Construct a button panel.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a button to the panel using displayText and ActionInstance.
    addButton(String displayText, net.minecraft.client.gui.components.Button.OnPress onPress)
    Adds a button to the panel using displayText and ActionInstance.
    boolean
    isMouseOver(TitleScreenButton button, net.minecraft.client.Minecraft minecraft, int mouseX, int mouseY)
    Checks if the mouse is over a particular button.
    boolean
    mouseClicked(double mouseX, double mouseY, int buttonNum)
     
    void
    renderWidget(net.minecraft.client.gui.GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks)
    Renders the panel and also renders the children of the panel iteratively.
    final void
    setX(int x)
     
    final void
    setY(int y)
     
    void
    updateButtons(int updateCounter, float partialTick, int mouseX, int mouseY)
    Update each button in order.
    final void
    updatePosition(int containerWidth, int containerHeight)
    Updates the position of the panel and then the buttons.

    Methods inherited from class net.minecraft.client.gui.components.Button

    builder, createNarrationMessage, onPress, updateWidgetNarration

    Methods inherited from class net.minecraft.client.gui.components.AbstractButton

    keyPressed, onClick, renderString

    Methods inherited from class net.minecraft.client.gui.components.AbstractWidget

    clearFGColor, clicked, defaultButtonNarrationText, getBottom, getFGColor, getHeight, getMessage, getRectangle, getRight, getTabOrderGroup, getTooltip, getWidth, getX, getY, isActive, isFocused, isHovered, isHoveredOrFocused, isMouseOver, isValidClickButton, mouseDragged, mouseReleased, narrationPriority, nextFocusPath, onDrag, onRelease, playDownSound, render, renderScrollingString, renderScrollingString, renderScrollingString, setAlpha, setFGColor, setFocused, setHeight, setMessage, setRectangle, setSize, setTabOrderGroup, setTooltip, setTooltipDelay, setWidth, updateNarration, visitWidgets, wrapDefaultNarrationMessage

    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.components.events.GuiEventListener

    charTyped, getCurrentFocusPath, keyReleased, mouseMoved, mouseScrolled

    Methods inherited from interface net.neoforged.neoforge.client.extensions.IAbstractWidgetExtension

    onClick

    Methods inherited from interface net.minecraft.client.gui.layouts.LayoutElement

    setPosition
  • Field Details

  • Constructor Details

    • ButtonPanel

      public ButtonPanel(ButtonPanel.AnchorType anchorType, int offsetX, int offsetY, int width, int height, int buttonSpacing, int containerWidth, int containerHeight, String tag, net.minecraft.client.gui.components.Button.OnPress onPress)
      Construct a button panel.
      Parameters:
      anchorType - where to place the button panel.
      offsetX - How far from the side of the button panel should a button be placed.
      offsetY - How far from the vertical of the panel should a button be placed.
      width - How wide the button panel is
      height - How tall the button panel is
      buttonSpacing - How far apart from each other should each button be
      containerWidth - How wide the inside of the panel should be
      containerHeight - How tall the inside of the panel sould be
      tag - Narratable name
      onPress - action taken on press.
  • Method Details

    • updatePosition

      public final void updatePosition(int containerWidth, int containerHeight)
      Updates the position of the panel and then the buttons.
      Parameters:
      containerWidth - width of the button panel
      containerHeight - height of the button panel
    • setY

      public final void setY(int y)
      Specified by:
      setY in interface net.minecraft.client.gui.layouts.LayoutElement
      Overrides:
      setY in class net.minecraft.client.gui.components.AbstractWidget
    • setX

      public final void setX(int x)
      Specified by:
      setX in interface net.minecraft.client.gui.layouts.LayoutElement
      Overrides:
      setX in class net.minecraft.client.gui.components.AbstractWidget
    • addButton

      public TitleScreenButton addButton(String displayText, net.minecraft.client.gui.components.Button.OnPress onPress)
      Adds a button to the panel using displayText and ActionInstance.
      Parameters:
      displayText - Button text
      onPress - Action taken by button on press
      Returns:
      Created button
    • addButton

      public void addButton(TitleScreenButton button)
      Adds a button to the panel using displayText and ActionInstance.
      Parameters:
      button - button to add
    • renderWidget

      public void renderWidget(@Nonnull net.minecraft.client.gui.GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks)
      Renders the panel and also renders the children of the panel iteratively.
      Overrides:
      renderWidget in class net.minecraft.client.gui.components.AbstractButton
    • mouseClicked

      public boolean mouseClicked(double mouseX, double mouseY, int buttonNum)
      Specified by:
      mouseClicked in interface net.minecraft.client.gui.components.events.GuiEventListener
      Overrides:
      mouseClicked in class net.minecraft.client.gui.components.AbstractWidget
    • isMouseOver

      public boolean isMouseOver(TitleScreenButton button, net.minecraft.client.Minecraft minecraft, int mouseX, int mouseY)
      Checks if the mouse is over a particular button.
      Parameters:
      button - button to check
      minecraft - minecraft instance
      mouseX - mouse position on the horizontal
      mouseY - mouse position on the vertical
      Returns:
      if the mouse is over the button.
    • updateButtons

      public void updateButtons(int updateCounter, float partialTick, int mouseX, int mouseY)
      Update each button in order.
      Parameters:
      updateCounter - Current tick.
      partialTick - partial tick.
      mouseX - location of mouse on the horizontal.
      mouseY - location of mouse on the vertical.