I know how to do basic animation for my mobs, like having the mob look at the player or have the legs move. But I want my mob to occasionally flick it's tail, make a small chewing motion, and on another mob have an animation that has it tail ripple whenever it walks. I've looked at Jabelar's tutorials and about everything I can think of but no tutorials are clear enough...they usually just show examples or show them typing something. Could someone please help? I'm a little bit of a noob in this area.
You can override setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) like I do here to apply rotations and animations. The second parameter indicates motion and is often used for any sort of walking animations.
(Note: I linked to a very old project that can be improved in many ways. For one, that was before I took Trigonometry. No need to copy word-for-word if you know a better way)
For occasional animations, I recommend adding an int timer field for each animation type, say, public int flickingTailTicks . In your entity code, occasionally set that field to a higher number based on whatever conditions. Decrement it every tick if it is more than 0. Alternatively, you can set it to 0 to trigger the start and increment it until it hits a certain number.
There is no need to use DataWatchers here if you only use those fields for client-side rendering algorithms.
In setRotationAngles, cast to your entity so you can access those timers. Then, there are a few ways you can implement your animation:
Jabelar points out the benefits of an array of rotations to iterate through in his Complex Entity Models tutorial. Most periodic motions use mathematic functions such as sine and cosine, along with Entity#ticksExisted and Entity#getEntityId() (for unique per-entity values to keep each model different).
How you do this is up to you, really, and will be different for every animation.
Does that help?
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
That array of rotations is ONLY for rotationY .This is an example of extremely customized code, which you will have to come up with on your own. Since your animation is extremely customized as well (usually).
As you can tell from the second code snippet, each line represents one animation "frame" and each float in the line is used for the corresponding body part. The first float is used for the first body part, second float for the second part, etc.
In other words, every time Jabelar's python moves, he increases cycleIndex, wrapping it to the length of his array to avoid an IndexOutOfBoundsException . That cycleIndex is used to pick a line of the float[ ][ ] . That float[ ] is used to set the Y rotations of each body part. X and Z rotations are left the same as they were when he initialized it.