Class TitleScreenButton

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.TitleScreenButton
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 TitleScreenButton extends net.minecraft.client.gui.components.Button
Button that appears on the Pixel MK title screen.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Button Builder.

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

    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
    final int
    Offset on the vertical.
    boolean
    Is this button aligned to the right of the screen.

    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
    Modifier
    Constructor
    Description
    protected
    Takes in a button builder to build a TitleScreenButton.
     
    TitleScreenButton(net.minecraft.client.gui.components.Button button)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    builder(net.minecraft.network.chat.Component message, net.minecraft.client.gui.components.Button.OnPress onPress)
    Get a button builder from just the message component and the onPress action.
    builder(net.minecraft.network.chat.Component message, net.minecraft.client.gui.components.Button.OnPress onPress, boolean rightAlign)
    Get a button builder from just the message component and the onPress action.
    void
    drawButtonBackground(net.minecraft.client.gui.GuiGraphics guiGraphics, Boolean mouseOver, int hightlightAlpha, int highlightRGBCol)
    Wrapper to configure params passed to drawRect.
    void
    drawButtonText(boolean mouseOver, net.minecraft.client.gui.GuiGraphics guiGraphics)
    Draws and colours text of the button.
    static void
    drawRect(net.minecraft.client.gui.GuiGraphics guiGraphics, int x1, int y1, int x2, int y2, int colour, int offset)
    Draws the parallelogram for the button.
    final net.minecraft.network.chat.Component
    Returns the apropriate message of the button.
    void
    playDownSound(net.minecraft.client.sounds.SoundManager soundManager)
    Empty method to remove the sound of clicking a button.
    protected void
    renderWidget(net.minecraft.client.gui.GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
     
    void
    updateButton(int updateCounter, float partialTick, int mouseX, int mouseY)
    Updates the button's propertys per tick.

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

    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, getRectangle, getRight, getTabOrderGroup, getTooltip, getWidth, getX, getY, isActive, isFocused, isHovered, isHoveredOrFocused, isMouseOver, isValidClickButton, mouseClicked, mouseDragged, mouseReleased, narrationPriority, nextFocusPath, onDrag, onRelease, render, renderScrollingString, renderScrollingString, renderScrollingString, setAlpha, setFGColor, setFocused, setHeight, setMessage, setRectangle, setSize, setTabOrderGroup, setTooltip, setTooltipDelay, setWidth, setX, setY, 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

    • offsetY

      public final int offsetY
      Offset on the vertical.
    • rightAlign

      public boolean rightAlign
      Is this button aligned to the right of the screen.
  • Constructor Details

    • TitleScreenButton

      protected TitleScreenButton(TitleScreenButton.Builder builder)
      Takes in a button builder to build a TitleScreenButton.
      Parameters:
      builder - Button builder
    • TitleScreenButton

      public TitleScreenButton(net.minecraft.client.gui.components.Button button)
  • Method Details

    • builder

      public static TitleScreenButton.Builder builder(net.minecraft.network.chat.Component message, net.minecraft.client.gui.components.Button.OnPress onPress)
      Get a button builder from just the message component and the onPress action.
      Parameters:
      message - message component to be displayed.
      onPress - action on press.
      Returns:
      the button builder.
    • builder

      public static TitleScreenButton.Builder builder(net.minecraft.network.chat.Component message, net.minecraft.client.gui.components.Button.OnPress onPress, boolean rightAlign)
      Get a button builder from just the message component and the onPress action.
      Parameters:
      message - message component to be displayed.
      onPress - action on press.
      rightAlign - is this button aligned to the right of the screen?
      Returns:
      the button builder.
    • drawRect

      public static void drawRect(net.minecraft.client.gui.GuiGraphics guiGraphics, int x1, int y1, int x2, int y2, int colour, int offset)
      Draws the parallelogram for the button.
      Parameters:
      guiGraphics - GUI draw helper
      x1 - bottom left corner x
      y1 - bottom left corner y
      x2 - top right corner x
      y2 - top right corner y
      colour - colour of the background
      offset - how slanted do you want the parallelogram
    • drawButtonBackground

      public void drawButtonBackground(net.minecraft.client.gui.GuiGraphics guiGraphics, Boolean mouseOver, int hightlightAlpha, int highlightRGBCol)
      Wrapper to configure params passed to drawRect.
      Parameters:
      guiGraphics - GUI Graphics Helper
      mouseOver - is the mouse over the button
      hightlightAlpha - alpha transparency
      highlightRGBCol - RGB hex.
    • playDownSound

      public void playDownSound(@Nonnull net.minecraft.client.sounds.SoundManager soundManager)
      Empty method to remove the sound of clicking a button.
      Overrides:
      playDownSound in class net.minecraft.client.gui.components.AbstractWidget
    • getMessage

      public final net.minecraft.network.chat.Component getMessage()
      Returns the apropriate message of the button.
      Overrides:
      getMessage in class net.minecraft.client.gui.components.AbstractWidget
    • renderWidget

      protected void renderWidget(@Nonnull net.minecraft.client.gui.GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
      Overrides:
      renderWidget in class net.minecraft.client.gui.components.AbstractButton
    • drawButtonText

      public void drawButtonText(boolean mouseOver, net.minecraft.client.gui.GuiGraphics guiGraphics)
      Draws and colours text of the button.
      Parameters:
      mouseOver - is mouse over this widget
      guiGraphics - graphics helper
    • updateButton

      public void updateButton(int updateCounter, float partialTick, int mouseX, int mouseY)
      Updates the button's propertys per tick.

      Updates and sets the following fields:

      • lastTickNumber
      • lastPartialTick
      • alpha

      alpha is the most useful of these as it controls the state of the button.

      Parameters:
      updateCounter - the update counter
      partialTick - current partial tick
      mouseX - mouse position on the horizontal
      mouseY - mouse position on the vertical