Class GuiAnimatedItem
java.lang.Object
com.github.darksoulq.abyssallib.world.gui.element.GuiAnimatedItem
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionGuiAnimatedItem(BiFunction<GuiView, Integer, org.bukkit.inventory.ItemStack> renderer) Constructs a new GuiAnimatedItem with a custom renderer. -
Method Summary
Modifier and TypeMethodDescriptionstatic GuiAnimatedItemof(BiFunction<GuiView, Integer, org.bukkit.inventory.ItemStack> renderer) Static factory method to create a GuiAnimatedItem with a custom renderer.static GuiAnimatedItemCreates an animated item from a list of frames.static GuiAnimatedItemCreates an animated item from a list of frames.onClick(GuiClickContext ctx) Cancels the click action.onDrag(GuiDragContext ctx) Cancels the drag action.@Nullable org.bukkit.inventory.ItemStackRenders the item based on the current server tick.Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface GuiElement
onClick, onDrag
-
Constructor Details
-
GuiAnimatedItem
Constructs a new GuiAnimatedItem with a custom renderer.- Parameters:
renderer- the animation rendering function
-
-
Method Details
-
render
Renders the item based on the current server tick.- Specified by:
renderin interfaceGuiElement- Parameters:
view- the current GUI viewslot- the slot index- Returns:
- the item stack for the current frame
-
onClick
Cancels the click action.- Specified by:
onClickin interfaceGuiElement- Parameters:
ctx- the click context- Returns:
ActionResult.CANCEL
-
onDrag
Cancels the drag action.- Specified by:
onDragin interfaceGuiElement- 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
Creates an animated item from a list of frames.- Parameters:
frames- the list of item stacks for animationinterval- 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 animationinterval- the tick interval between frame changesloop- whether the animation should repeat- Returns:
- a new GuiAnimatedItem instance
- Throws:
IllegalArgumentException- if frames list is empty
-