Fluid Animations
Add life and movement to your interfaces with zero performance cost.
How it Works
InvLib uses a global AnimationTicker that manages all AnimatedButtons. To stay lightweight, the ticker only processes menus that are actively being viewed by at least one player.
Once a menu is closed, it is automatically removed from the ticker's cycle, ensuring minimal CPU usage even with hundreds of concurrent menus.
Functional Animation
Use a lambda to define how the item looks based on the current tick. This is perfect for progress bars or complex visual patterns.
ItemAnimation cycle = tick -> {
Material mat = (tick % 20 < 10) ? Material.GOLD_INGOT : Material.IRON_INGOT;
return new ItemStack(mat);
};
AnimatedButton button = new AnimatedButton(cycle);
menu.setButton(13, button);
Frame-based Animation
If you have a fixed sequence of items, use the frames() helper. You can specify a tick delay between each frame for precise control.
List<ItemStack> frames = List.of(frame1, frame2, frame3);
// 5 tick delay between frames
ItemAnimation anim = ItemAnimation.frames(5, frames);
Performance Fact
The AnimationTicker uses optimized WeakReferences and internal tracking to ensure that closed or discarded menus are never ticked and don't leak memory. We prioritize server stability above all else.