java.lang.Object
com.ultikits.ultitools.abstracts.gui.declarative.core.RenderNode

public class RenderNode extends Object
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 Details

    • key

      @Nullable private final @Nullable SlotKey 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 slotIndex
      The 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 icon
      The Icon to display in this slot. If null, this slot should be empty.
    • clickHandler

      @Nullable private @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> clickHandler
      The click event handler.
    • parent

      @Nullable private @Nullable RenderNode parent
      The parent node.
    • children

      @NotNull private final @NotNull List<RenderNode> children
      The child nodes (for container-type nodes).
    • metadata

      @NotNull private final Map<String,Object> metadata
      Node metadata, used to store extra information.
  • Constructor Details

    • RenderNode

      public RenderNode(@Nullable @Nullable SlotKey key, int slotIndex)
      Creates a new RenderNode.
      Parameters:
      key - the slot identifier, may be null
      slotIndex - 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 identifier
      slotIndex - the slot index
      icon - the icon
  • Method Details

    • getKey

      @Nullable public @Nullable SlotKey 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

      @Nullable public @Nullable RenderNode getParent()
      Gets the parent node.
      Returns:
      the parent node, may be null
    • setParent

      void setParent(@Nullable @Nullable RenderNode parent)
      Sets the parent node.
      Parameters:
      parent - the parent node
    • getChildren

      @NotNull public @NotNull List<RenderNode> getChildren()
      Gets the list of child nodes (unmodifiable).
      Returns:
      the list of child nodes
    • addChild

      public void addChild(@NotNull @NotNull RenderNode child)
      Adds a child node.
      Parameters:
      child - the child node
    • removeChild

      public void removeChild(@NotNull @NotNull RenderNode child)
      Removes a child node.
      Parameters:
      child - the child node
    • clearChildren

      public void clearChildren()
      Clears all child nodes.
    • getMetadata

      @Nullable public @Nullable Object getMetadata(@NotNull @NotNull String key)
      Gets a metadata value.
      Parameters:
      key - the key
      Returns:
      the value, or null if it does not exist
    • setMetadata

      public void setMetadata(@NotNull @NotNull String key, @Nullable @Nullable Object value)
      Sets a metadata value.
      Parameters:
      key - the key
      value - 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

      @NotNull public @NotNull List<RenderNode> 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

      @NotNull public @NotNull RenderNode copy()
      Creates a deep copy of this node (excluding its children).
      Returns:
      the new RenderNode
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object