Package net.minecraft.client.gui
Interface ComponentPath
- All Known Implementing Classes:
ComponentPath.Leaf
,ComponentPath.Path
public interface ComponentPath
Represents a path of components in a user interface hierarchy.
It provides methods to create and manipulate component paths.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final record
TheLeaf
class represents a leaf component path in the hierarchy.static final record
ThePath
class represents a non-leaf component path in the hierarchy. -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyFocus
(boolean focused) Applies focus to or removes focus from the component associated with this component path.static ComponentPath
leaf
(GuiEventListener component) Creates a leaf component path with the specifiedGuiEventListener
component.static ComponentPath
path
(ContainerEventHandler component, ComponentPath childPath) Creates a component path with the specifiedContainerEventHandler
component and an optional child path.static ComponentPath
path
(GuiEventListener leafComponent, ContainerEventHandler... ancestorComponents) Creates a newComponentPath
leaf node with the specifiedGuiEventListener
component and an array ofContainerEventHandler
ancestors.
-
Method Details
-
leaf
Creates a leaf component path with the specifiedGuiEventListener
component.- Parameters:
component
- the component associated with the leaf path- Returns:
- a new leaf component path.
-
path
@Nullable static ComponentPath path(ContainerEventHandler component, @Nullable ComponentPath childPath) Creates a component path with the specifiedContainerEventHandler
component and an optional child path.- Parameters:
component
- the component associated with the pathchildPath
- the child path associated with the component- Returns:
- a new component path, or
null
if the child path is null
-
path
static ComponentPath path(GuiEventListener leafComponent, ContainerEventHandler... ancestorComponents) Creates a newComponentPath
leaf node with the specifiedGuiEventListener
component and an array ofContainerEventHandler
ancestors.- Parameters:
leafComponent
- the new 'Leaf' component associated with the pathancestorComponents
- the array of ancestor components associated with the path, ordered in reverse ascending order towards root .- Returns:
- a new component path
-
component
GuiEventListener component() -
applyFocus
void applyFocus(boolean focused) Applies focus to or removes focus from the component associated with this component path.- Parameters:
focused
-true
to apply focus,false
to remove focus.
-