How to play or stop player animations - ZigyTheBird/ZigysPlayerAnimatorAPI GitHub Wiki
Using Java code
Simply use the PlayerAnimAPI
class on server side or the PlayerAnimAPIClient
for.. you get it.
If you are on the client side you can also trigger animations from the PlayerAnimations
class, this will bypass fancy stuff like the mod logging the animations played for the Replaymod.
THE PlayerAnimAPI
CLASS SENDS A PACKET TO THE CLIENT IN ORDER TO PLAY AN ANIMATION YOU DON'T HAVE TO DO IT YOURSELF.
The methods have Java docs so you should be fine on that front just choose the method that best fits what you want to do.
Using commands
The command for playing animations is /playPlayerAnimation and you can either just give it an animation ID or A LOT of paramaters which you will get introduced to further into this wiki page.
The command for stopping animations is /stopPlayerAnimation which takes the ID of the animation you want to cancel.
You can play the animation in the simplest way possible like this:
/playPlayerAnimation @p playeranimatorapi:wave
Or you can play it in a more advanced way like this:
/playPlayerAnimation @p playeranimatorapi:wave -1 -1 -1 false
Or you can give it all the parameters like this:
/playPlayerAnimation @p playeranimatorapi:wave -1 -1 -1 false "axq5j8jrytibv8jj" null
YOU CANNOT PLAY AN ANIMATION LIKE THIS ❌❌❌:
/playPlayerAnimation @p playeranimatorapi:wave -1
Default values
All paramaters except numerical ones can be set to null.
The default value for the priority paramater is 1000 which is what Emotecraft uses.
Animations like idle animations should have a lower priority number and important ones like attack animations should have a higher priority than 1000.
The startTick parameter should usually be set to 0.
All other numerical parameters other than those two can be set to -1 in order to use the default value.
The Paramaters
- Player/Level: Pretty self explanatory.
- animationID: Just a ResourceLocation that points to the animation.
- fadeLength: How long it takes to transition to your animation (in ticks).
- easeID: Here is a list of all different eases and their IDs. (Some might not apply to custom models)
- priority: Self explanatory, 1000 by default. (Same value as Emotecraft)
- playerParts: A Java class for disabling modification of certain player parts. Use this for string form used in commands.
- modifiers: You can find out more about those in their dedicated wiki page.
- firstPersonEnabled: Whether or not your animation gets played in first person. (Like Better Combat)
- replaceTick: Only found in the Java client side methods, if set to false the new animation playing will start where the previous one left off.
- startTick: Starts the animation from this tick, will use the tick the animation being replaced is on if a negative value.