Class TContextMenu.Builder
java.lang.Object
com.thecsdev.commonmc.api.client.gui.ctxmenu.TContextMenu.Builder
- Enclosing class:
TContextMenu
A builder for creating a simple
TContextMenu instance.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal TContextMenu.BuilderaddButton(@NotNull net.minecraft.network.chat.Component text, @NotNull Consumer<TClickableWidget> onClick) Adds aTButtonWidgetwith the specified text to the context menu.final TContextMenu.BuilderaddContextMenu(@NotNull net.minecraft.network.chat.Component text, @NotNull Function<TClickableWidget, TContextMenu> menuBuilder) Adds aTButtonWidgetthat opens a sub-menu when clicked.final TContextMenu.BuilderaddElement(@NotNull TElement element) Adds a customTElementto the context menu.final TContextMenu.BuilderAdds a separator line to the context menu.final @NotNull TContextMenubuild()Builds and returns theTContextMenuinstance.final TContextMenu.BuildersetMaxHeight(int maxHeight) Sets the maximum height of the context menu.final TContextMenu.BuildersetMaxSize(int maxWidth, int maxHeight) Sets the maximum size of the context menu.final TContextMenu.BuildersetMaxWidth(int maxWidth) Sets the maximum width of the context menu.
-
Constructor Details
-
Builder
public Builder(@NotNull @NotNull net.minecraft.client.Minecraft client)
-
-
Method Details
-
setMaxWidth
Sets the maximum width of the context menu.- Parameters:
maxWidth- The maximum width in game's GUI units.
-
setMaxHeight
Sets the maximum height of the context menu.- Parameters:
maxHeight- The maximum height in game's GUI units.
-
setMaxSize
Sets the maximum size of the context menu.- Parameters:
maxWidth- The maximum width in game's GUI units.maxHeight- The maximum height in game's GUI units.
-
addElement
public final TContextMenu.Builder addElement(@NotNull @NotNull TElement element) throws NullPointerException Adds a customTElementto the context menu.- Parameters:
element- TheTElementto add.- Throws:
NullPointerException- If the argument isnull.- API Note:
- This element will be stretched horizontally to fit the context menu's width.
-
addButton
public final TContextMenu.Builder addButton(@NotNull @NotNull net.minecraft.network.chat.Component text, @NotNull @NotNull Consumer<TClickableWidget> onClick) throws NullPointerException Adds aTButtonWidgetwith the specified text to the context menu.- Parameters:
text- The text to display on the button.onClick- The callback to invoke when the button is clicked.- Throws:
NullPointerException- If the argument isnull.
-
addContextMenu
public final TContextMenu.Builder addContextMenu(@NotNull @NotNull net.minecraft.network.chat.Component text, @NotNull @NotNull Function<TClickableWidget, TContextMenu> menuBuilder) throws NullPointerException Adds aTButtonWidgetthat opens a sub-menu when clicked.- Parameters:
text- The text to display on the entry.menuBuilder- TheTContextMenubuilder function.- Throws:
NullPointerException- If an argument isnull.
-
addSeparator
Adds a separator line to the context menu. -
build
Builds and returns theTContextMenuinstance.
-