Class GuiAnimatedItem

java.lang.Object
com.github.darksoulq.abyssallib.world.gui.element.GuiAnimatedItem
All Implemented Interfaces:
GuiElement

public class GuiAnimatedItem extends Object implements GuiElement
A GUI element that updates its visual state based on server ticks.

This allows for frame-based animations or dynamic item rendering that changes over time.

  • Constructor Details

    • GuiAnimatedItem

      public GuiAnimatedItem(BiFunction<GuiView, Integer, org.bukkit.inventory.ItemStack> renderer)
      Constructs a new GuiAnimatedItem with a custom renderer.
      Parameters:
      renderer - the animation rendering function
  • Method Details

    • render

      @Nullable public @Nullable org.bukkit.inventory.ItemStack render(GuiView view, int slot)
      Renders the item based on the current server tick.
      Specified by:
      render in interface GuiElement
      Parameters:
      view - the current GUI view
      slot - the slot index
      Returns:
      the item stack for the current frame
    • onClick

      public ActionResult onClick(GuiClickContext ctx)
      Cancels the click action.
      Specified by:
      onClick in interface GuiElement
      Parameters:
      ctx - the click context
      Returns:
      ActionResult.CANCEL
    • onDrag

      public ActionResult onDrag(GuiDragContext ctx)
      Cancels the drag action.
      Specified by:
      onDrag in interface GuiElement
      Parameters:
      ctx - the drag context
      Returns:
      ActionResult.CANCEL
    • of

      public static GuiAnimatedItem of(BiFunction<GuiView, Integer, org.bukkit.inventory.ItemStack> renderer)
      Static factory method to create a GuiAnimatedItem with a custom renderer.
      Parameters:
      renderer - the rendering function
      Returns:
      a new GuiAnimatedItem instance
    • of

      public static GuiAnimatedItem of(List<org.bukkit.inventory.ItemStack> frames, int interval)
      Creates an animated item from a list of frames.
      Parameters:
      frames - the list of item stacks for animation
      interval - the tick interval between frame changes
      Returns:
      a new looping GuiAnimatedItem
    • of

      public static GuiAnimatedItem of(List<org.bukkit.inventory.ItemStack> frames, int interval, boolean loop)
      Creates an animated item from a list of frames.
      Parameters:
      frames - the list of item stacks for animation
      interval - the tick interval between frame changes
      loop - whether the animation should repeat
      Returns:
      a new GuiAnimatedItem instance
      Throws:
      IllegalArgumentException - if frames list is empty