Interface GuiDescription
- All Known Implementing Classes:
ItemSyncedGuiDescription, LightweightGuiDescription, SyncedGuiDescription
public interface GuiDescription
A GUI description represents a GUI without depending on screens.
GUI descriptions contain the root panel and the property delegate of the GUI. They also manage the focused widget.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA listener for focus change events. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener that is called when the focused widget changes.voidGuis should use this method to add clientside styles and BackgroundPainters to their controlsvoidaddSlotPeer(ValidatedSlot slot) Typical users won't call this.@Nullable net.minecraft.world.inventory.ContainerDataGets the object which manages the integer properties used by WBars and such.getFocus()Gets the currently-focused WWidget.default @Nullable net.minecraft.world.inventory.ContainerDataDeprecated, for removal: This API element is subject to removal in a future version.Gets the horizontal alignment of the GUI title.intGets the position of the screen title.booleanTests whether the root panel should get a vanilla background in the defaultaddPainters()implementations.default TriStateChecks whether dark mode is used for this GUI description.booleanTests whether the widget is the currently-focused one.booleanGets whether this GUI is fullscreen.booleanGets whether the title of this GUI should be rendered by the screen.voidreleaseFocus(WWidget widget) Notifies this gui that the widget wants to give up its hold over focus.voidrequestFocus(WWidget widget) Notifies this gui that the widget wants to acquire focus.setContainerData(@Nullable net.minecraft.world.inventory.ContainerData data) Sets the object which manages the integer properties used by WBars.voidsetFullscreen(boolean fullscreen) Sets whether this GUI is fullscreen.default GuiDescriptionsetPropertyDelegate(net.minecraft.world.inventory.ContainerData delegate) Deprecated, for removal: This API element is subject to removal in a future version.Replaced withsetContainerData(ContainerData).setRootPanel(WPanel panel) voidsetTitleAlignment(HorizontalAlignment alignment) Sets the horizontal alignment of the GUI title.setTitleColor(int color) Sets the title color of this GUI.setTitleColor(int lightColor, int darkColor) Sets the light and dark title colors of this GUI.voidsetTitlePos(Vec2i titlePos) Sets the position of the screen title.voidsetTitleVisible(boolean titleVisible) Sets whether the title of this GUI should be rendered by the screen.voidsetUseDefaultRootBackground(boolean useDefaultRootBackground) Enables or disables the default vanilla background for root panels.
-
Method Details
-
getRootPanel
WPanel getRootPanel() -
getTitleColor
int getTitleColor() -
setRootPanel
-
setTitleColor
Sets the title color of this GUI.The dark-mode title color will also be set by this method. If the specified color is
WLabel.DEFAULT_TEXT_COLOR, the dark-mode color will beWLabel.DEFAULT_DARKMODE_TEXT_COLOR; otherwise it will be the specified color.- Parameters:
color- the new title color- Returns:
- this GUI
-
setTitleColor
Sets the light and dark title colors of this GUI.- Parameters:
lightColor- the light-mode colordarkColor- the dark-mode color- Returns:
- this GUI
- Since:
- 2.1.0
-
setPropertyDelegate
@Deprecated(forRemoval=true) default GuiDescription setPropertyDelegate(net.minecraft.world.inventory.ContainerData delegate) Deprecated, for removal: This API element is subject to removal in a future version.Replaced withsetContainerData(ContainerData).Sets the object which manages the integer properties used by WBars. -
addSlotPeer
Typical users won't call this. This adds a Slot to Container/Controller-based guis, and does nothing on lightweight guis. -
addPainters
@Environment(CLIENT) void addPainters()Guis should use this method to add clientside styles and BackgroundPainters to their controls -
getUseDefaultRootBackground
boolean getUseDefaultRootBackground()Tests whether the root panel should get a vanilla background in the defaultaddPainters()implementations.- Returns:
trueif the default background painter is applied,falseotherwise- Since:
- 12.0.0
-
setUseDefaultRootBackground
void setUseDefaultRootBackground(boolean useDefaultRootBackground) Enables or disables the default vanilla background for root panels.- Parameters:
useDefaultRootBackground-trueif the default background painter is applied,falseotherwise- Since:
- 12.0.0
- See Also:
-
getPropertyDelegate
@Deprecated(forRemoval=true) default @Nullable net.minecraft.world.inventory.ContainerData getPropertyDelegate()Deprecated, for removal: This API element is subject to removal in a future version.Replaced withgetContainerData().Gets the object which manages the integer properties used by WBars and such. -
getContainerData
@Nullable net.minecraft.world.inventory.ContainerData getContainerData()Gets the object which manages the integer properties used by WBars and such.- Since:
- 16.0.0
-
setContainerData
Sets the object which manages the integer properties used by WBars.- Since:
- 16.0.0
-
isFocused
Tests whether the widget is the currently-focused one. -
getFocus
-
requestFocus
Notifies this gui that the widget wants to acquire focus. -
releaseFocus
Notifies this gui that the widget wants to give up its hold over focus. -
isFullscreen
boolean isFullscreen()Gets whether this GUI is fullscreen.Fullscreen GUIs have no default background painter and have the root panel stretched to fit the entire screen on the client.
- Returns:
- true if this GUI is fullscreen, false otherwise
- Since:
- 2.0.0
-
setFullscreen
void setFullscreen(boolean fullscreen) Sets whether this GUI is fullscreen.- Parameters:
fullscreen- true if this GUI is fullscreen, false otherwise- Since:
- 2.0.0
-
isTitleVisible
boolean isTitleVisible()Gets whether the title of this GUI should be rendered by the screen.Modders can disable this to render the title themselves with a widget.
- Returns:
- true if the title is visible, false otherwise
- Since:
- 2.0.0
-
setTitleVisible
void setTitleVisible(boolean titleVisible) Sets whether the title of this GUI should be rendered by the screen.- Parameters:
titleVisible- true if the title is visible, false otherwise- Since:
- 2.0.0
-
getTitleAlignment
HorizontalAlignment getTitleAlignment()Gets the horizontal alignment of the GUI title.- Returns:
- the alignment
- Since:
- 2.1.0
-
setTitleAlignment
Sets the horizontal alignment of the GUI title.- Parameters:
alignment- the new alignment- Since:
- 2.1.0
-
getTitlePos
-
setTitlePos
Sets the position of the screen title.- Parameters:
titlePos- the new title position- Since:
- 4.0.0
-
isDarkMode
Checks whether dark mode is used for this GUI description.- Returns:
TriState.TRUEto force dark modeTriState.FALSEto force light modeTriState.DEFAULTto use the global dark mode setting
- Since:
- 7.1.0
-
addFocusChangeListener
Adds a listener that is called when the focused widget changes.- Parameters:
listener- the listener- Since:
- 16.0.0
-
getContainerData().