Class ButtonPanel
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 ClassesModifier and TypeClassDescriptionstatic enumWhere 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.OnPressNested classes/interfaces inherited from interface net.minecraft.client.gui.narration.NarratableEntry
net.minecraft.client.gui.narration.NarratableEntry.NarrationPriority -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ButtonPanel.AnchorTypeWhere to anchor the panel to the screen.protected List<TitleScreenButton> List of buttons in the panel.protected TitleScreenButtonPreviously/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_WIDTHFields inherited from class net.minecraft.client.gui.components.AbstractButton
SPRITES, TEXT_MARGINFields inherited from class net.minecraft.client.gui.components.AbstractWidget
active, alpha, height, isHovered, packedFGColor, UNSET_FG_COLOR, visible, widthFields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
DOUBLE_CLICK_THRESHOLD_MS -
Constructor Summary
ConstructorsConstructorDescriptionButtonPanel(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 TypeMethodDescriptionvoidaddButton(TitleScreenButton button) Adds a button to the panel usingdisplayTextandActionInstance.Adds a button to the panel usingdisplayTextandActionInstance.booleanisMouseOver(TitleScreenButton button, net.minecraft.client.Minecraft minecraft, int mouseX, int mouseY) Checks if the mouse is over a particular button.booleanmouseClicked(double mouseX, double mouseY, int buttonNum) voidrenderWidget(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 voidsetX(int x) final voidsetY(int y) voidupdateButtons(int updateCounter, float partialTick, int mouseX, int mouseY) Update each button in order.final voidupdatePosition(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, updateWidgetNarrationMethods inherited from class net.minecraft.client.gui.components.AbstractButton
keyPressed, onClick, renderStringMethods 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, wrapDefaultNarrationMessageMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
charTyped, getCurrentFocusPath, keyReleased, mouseMoved, mouseScrolledMethods inherited from interface net.neoforged.neoforge.client.extensions.IAbstractWidgetExtension
onClickMethods inherited from interface net.minecraft.client.gui.layouts.LayoutElement
setPosition
-
Field Details
-
anchorType
Where to anchor the panel to the screen. -
buttons
List of buttons in the panel. -
pressedButton
Previously/currently pressed button in the panel.
-
-
Constructor Details
-
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 panelcontainerHeight- height of the button panel
-
setY
public final void setY(int y) - Specified by:
setYin interfacenet.minecraft.client.gui.layouts.LayoutElement- Overrides:
setYin classnet.minecraft.client.gui.components.AbstractWidget
-
setX
public final void setX(int x) - Specified by:
setXin interfacenet.minecraft.client.gui.layouts.LayoutElement- Overrides:
setXin classnet.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 usingdisplayTextandActionInstance.- Parameters:
displayText- Button textonPress- Action taken by button on press- Returns:
- Created button
-
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:
renderWidgetin classnet.minecraft.client.gui.components.AbstractButton
-
mouseClicked
public boolean mouseClicked(double mouseX, double mouseY, int buttonNum) - Specified by:
mouseClickedin interfacenet.minecraft.client.gui.components.events.GuiEventListener- Overrides:
mouseClickedin classnet.minecraft.client.gui.components.AbstractWidget
-
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.
-