-
-
Notifications
You must be signed in to change notification settings - Fork 131
Triggerable Animations (Geckolib4)
New to GeckoLib4 is the ability to trigger animations in an animatable, from the server! This opens a lot of interesting options for more complex objects and animations.
Triggered animations will override the AnimationState
calls for the AnimationController
that is running it for the duration that it is being run, so it is recommended that you only trigger non-looping animations, but it can still be stopped by calling stop()
on the controller at any stage.
To use this system, we must first tell our controller that they have a triggerable animation. This is done by calling .triggerableAnim
on the controller when we instantiate it, giving it a trigger name, and the RawAnimation
associated with the trigger
E.G.
public void registerControllers(AnimatableManager.ControllerRegistrar controllers) {
controllers.add(new AnimationController<>(this, "shoot_controller", state -> PlayState.STOP)
.triggerableAnim("shoot", SHOOT_ANIM));
}
Once that has been done, we can then call triggerAnim
from the server side at any time, providing the controller name and the trigger name.
E.G.
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
if (level instanceof ServerLevel serverLevel)
triggerAnim(player, GeoItem.getOrAssignId(player.getItemInHand(hand), serverLevel), "shoot_controller", "shoot");
return super.use(level, player, hand);
}
Note that for singleton animatables (Items and replaced geo entities), you must additionally register your syncable animatable with GeckoLib in your class constructor via SingletonGeoAnimatable.registerSyncedAnimatable
E.G.
public ExampleItem(Properties properties) {
super(properties);
SingletonGeoAnimatable.registerSyncedAnimatable(this);
}
Geckolib 3
Geckolib 4
- Installation
- Getting Started
- Upgrading from GeckoLib 3.1.x to 4.0
- Updating to GeckoLib 4.5
- Basic
- Advanced
- Miscellaneous
Package repository hosting is graciously provided by Cloudsmith.
Cloudsmith is the only fully hosted, cloud-native, universal package management solution that enables your organization to create, store and share packages in any format, to any place, with total confidence.