Class RenderNode
java.lang.Object
com.ultikits.ultitools.abstracts.gui.declarative.core.RenderNode
RenderNode is a node in the virtual render tree, representing one slot to be rendered.
RenderNode is a framework-internal object used to:
- describe what each slot should display (Icon)
- record the slot's position (slotIndex)
- support stable identification (slotKey) for diffing
- organize into a tree structure to support layout calculation
Note: RenderNode never touches the Bukkit Inventory directly;
it is only a virtual representation, translated into actual Inventory operations by
GuiRenderer.
- Since:
- 6.2.0
- Version:
- 1.0.0
- Author:
- UltiTools Team
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final @NotNull List<RenderNode> The child nodes (for container-type nodes).private @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> The click event handler.private @Nullable mc.obliviate.inventory.IconThe Icon to display in this slot.private final @Nullable SlotKeyThe slot's unique identifier, used by the diff algorithm to recognize the same node.Node metadata, used to store extra information.private @Nullable RenderNodeThe parent node.private intThe slot's index within the Inventory (0-based). -
Constructor Summary
ConstructorsConstructorDescriptionRenderNode(@Nullable SlotKey key, int slotIndex) Creates a new RenderNode.RenderNode(@Nullable SlotKey key, int slotIndex, @Nullable mc.obliviate.inventory.Icon icon) Creates a leaf RenderNode (no child nodes). -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChild(@NotNull RenderNode child) Adds a child node.intCalculates the number of slots occupied by this subtree.voidClears all child nodes.private voidcollectLeaves(@NotNull RenderNode node, @NotNull List<RenderNode> leaves) @NotNull RenderNodecopy()Creates a deep copy of this node (excluding its children).boolean@NotNull List<RenderNode> Gets the list of all leaf nodes (recursively).@NotNull List<RenderNode> Gets the list of child nodes (unmodifiable).@Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> Gets the click handler.@Nullable mc.obliviate.inventory.IcongetIcon()Gets the icon.@Nullable SlotKeygetKey()Gets the slot identifier.@Nullable ObjectgetMetadata(@NotNull String key) Gets a metadata value.@Nullable RenderNodeGets the parent node.inthashCode()booleanChecks whether this is a container node (has child nodes).booleanisLeaf()Checks whether this is a leaf node (no child nodes).voidremoveChild(@NotNull RenderNode child) Removes a child node.voidsetClickHandler(@Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> clickHandler) Sets the click handler.voidsetIcon(@Nullable mc.obliviate.inventory.Icon icon) Sets the icon.voidsetMetadata(@NotNull String key, @Nullable Object value) Sets a metadata value.(package private) voidsetParent(@Nullable RenderNode parent) Sets the parent node.toString()
-
Field Details
-
key
The slot's unique identifier, used by the diff algorithm to recognize the same node. If null, slotIndex is used for identification instead. -
slotIndex
private int slotIndexThe slot's index within the Inventory (0-based). -1 means no position has been assigned yet (e.g. a container node). -- GETTER -- Gets the slot index. -- SETTER -- Sets the slot index. -
icon
@Nullable private @Nullable mc.obliviate.inventory.Icon iconThe Icon to display in this slot. If null, this slot should be empty. -
clickHandler
The click event handler. -
parent
The parent node. -
children
The child nodes (for container-type nodes). -
metadata
Node metadata, used to store extra information.
-
-
Constructor Details
-
RenderNode
Creates a new RenderNode.- Parameters:
key- the slot identifier, may be nullslotIndex- the slot index
-
RenderNode
public RenderNode(@Nullable @Nullable SlotKey key, int slotIndex, @Nullable @Nullable mc.obliviate.inventory.Icon icon) Creates a leaf RenderNode (no child nodes).- Parameters:
key- the slot identifierslotIndex- the slot indexicon- the icon
-
-
Method Details
-
getKey
Gets the slot identifier.- Returns:
- the SlotKey, may be null
-
getIcon
@Nullable public @Nullable mc.obliviate.inventory.Icon getIcon()Gets the icon.- Returns:
- the Icon, may be null
-
setIcon
public void setIcon(@Nullable @Nullable mc.obliviate.inventory.Icon icon) Sets the icon.- Parameters:
icon- the icon
-
getClickHandler
@Nullable public @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> getClickHandler()Gets the click handler.- Returns:
- the click handler, may be null
-
setClickHandler
public void setClickHandler(@Nullable @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> clickHandler) Sets the click handler.- Parameters:
clickHandler- the click handler
-
getParent
Gets the parent node.- Returns:
- the parent node, may be null
-
setParent
Sets the parent node.- Parameters:
parent- the parent node
-
getChildren
Gets the list of child nodes (unmodifiable).- Returns:
- the list of child nodes
-
addChild
Adds a child node.- Parameters:
child- the child node
-
removeChild
Removes a child node.- Parameters:
child- the child node
-
clearChildren
public void clearChildren()Clears all child nodes. -
getMetadata
Gets a metadata value.- Parameters:
key- the key- Returns:
- the value, or null if it does not exist
-
setMetadata
Sets a metadata value.- Parameters:
key- the keyvalue- the value
-
isLeaf
public boolean isLeaf()Checks whether this is a leaf node (no child nodes).- Returns:
- true if this is a leaf node
-
isContainer
public boolean isContainer()Checks whether this is a container node (has child nodes).- Returns:
- true if this is a container node
-
getAllLeaves
Gets the list of all leaf nodes (recursively).- Returns:
- all leaf nodes
-
collectLeaves
private void collectLeaves(@NotNull @NotNull RenderNode node, @NotNull @NotNull List<RenderNode> leaves) -
calculateSlotCount
public int calculateSlotCount()Calculates the number of slots occupied by this subtree.- Returns:
- the slot count
-
copy
Creates a deep copy of this node (excluding its children).- Returns:
- the new RenderNode
-
equals
-
hashCode
public int hashCode() -
toString
-