🏃♂️ AnimationAction
If you want to perform an action after the animation is done player, you would want to look into using AnimationAction
.
It is separated into action types and instances. Type is responsible for creating and executing action instance, while the instance itself is tasked with holding and serializing context information applicable to your action.
If you don't need to store much information, you can just use an empty default AnimationActionInstance
. It still offers storage of data through NBT, using AnimationActionInstance.getExtra()
method (you can create instance with extra data and execute it that way).
If you want to create custom action instance for storing data, you will need to override AnimationAction.createInstance
method to return a new unconfigured instance of your action.
☕ Registration (Java)
⌨️ ModAnimations Class
To bind actions, create an interface ModAnimationActions
inside your init package.
The result should look something like this:
package com.yourname.yourmod.init;
import org.zeith.hammerlib.annotations.*;
@SimplyRegister
public interface ModAnimationActions
{
}
📦 Adding action types
To add a new animation container into the mod, simply create a new field inside ModAnimationActions
of type AnimationAction
, assign it a new AnimationAction type instance, and annotating the field with @RegistryName("name")
. The "name" must be unique.
package com.yourname.yourmod.init;
import org.zeith.hammeranims.api.animation.*;
import org.zeith.hammerlib.annotations.*;
@SimplyRegister
public interface ModAnimationActions
{
@RegistryName("my_action")
AnimationAction MY_ACTION = new MyAnimationAction();
}