How to make complex animations for custom mobs?

Started by Sajevius on Sun, 10/11/2020 - 13:42

Topic category: Help with modding (Java Edition)

Last seen on 03:28, 22. Nov 2020
Joined Aug 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
How to make complex animations for custom mobs?
Sun, 10/11/2020 - 13:42

I know this got asked a lot, but I've seen that nobody really gets to the point and give a code snippet example instead of just telling the OP to code custom animations. Yes, it's obvious - just like how the sky is blue in the morning - that custom animations require coding to some extent, but how would we go about to do it exactly? I've wanted to make an arm swing animation for an entity of mine when it attacks, and as far as I've searched, what did I find? Nothing. Not even the code for custom complex animations, and I already know how to animate head, arms, and legs rotations 'coz those stuff are easy to animate. I really need help on custom, more complex animations such as arm swings, and to get better at entity animations as well... and browsing through Minecraft's deobfuscated entity models' source code does not even help me understand the animation mechanics as well. I know full well that it's not very easy, but still, I want a digestible explanation and even a straightforward elaboration of the things it requires. And I'm using Forge 1.14.4 by the way, so I can't really use the GeckoLib plugin for now 'coz I'm not planning 1.15 support for my mods anytime soon...

 

P.S. If you don't know the code itself, think well before even posting a comment, please. I want honest, working answers, if ever there are, and maybe also words of encouragement as well tbh.

 

Any working solution would be immensely appreciated :D

Last seen on 20:47, 23. Nov 2020
Joined Apr 2010
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
In 1.14.4, for custom…
Sun, 10/11/2020 - 16:23

In 1.14.4, for custom animations, you will need a lot of heavy coding, understanding of maths and coodinate systems. Then check renderers of existing mobs and learn from there.

Last seen on 03:28, 22. Nov 2020
Joined Aug 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Klemen, that's fine. I still…
Sun, 10/11/2020 - 23:04

Klemen, that's fine. I still like learning thigs the hard way. Also, looking at the vanilla animations I already knew that people would need to have the prerequisites of a decent understanding of Java (fair enough), mathematics (check?), coordinate system (check), and such, which leads me to the next small question: where should I start? Basically, in net.minecraft.client.renderer.entity, should i ckeck both the models and renderers of certain entities and understand the parameters & arguments used as well as the math operations?

 

thanks in advance

Last seen on 08:35, 23. Nov 2020
Joined Nov 2019
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
model animations are not…
Mon, 10/12/2020 - 18:28

model animations are not easy. i can make simple animations since i'm not very good at making models or textures.

basically when you make your entity model be sure to put all the cubes of each limb you want to animate in one group and label it, so that in your code you can reference that group. your model class should extend net.minecraft.client.renderer.entity.model.EntityModel which has a method your class inherits called setRotationAngles. this is where you input your rotation angles for your model. take a look at net.minecraft.client.renderer.entity.model.BipedModel, the method does some rotations for the biped's arms legs, etc. just remember the angles in your model code are in radians, so if you want your body part to rotate 30 degrees in the Y axis, you would code something like

this.bipedRightLeg.rotateAngleY += 30.0F * 0.017453292F; // in the positive direction
this.bipedRightLeg.rotateAngleY -= 30.0F * 0.017453292F; // in the negative direction

0.017453292F is just PI / 180 (converting from degrees to radian.

Last seen on 08:35, 23. Nov 2020
Joined Nov 2019
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
thats just part 1. then you…
Mon, 10/12/2020 - 18:55

thats just part 1. then you will have to make a custom renderer for your entity, it should extend net.minecraft.client.renderer.entity.EntityRenderer, and override doRender to call the above mentioned setRotationAngles before calling your model class renderer.

and then you will have to pass on the rotation angles from your entity's class to your custom renderer, which crosses sides (from server to client) since the renderer is always run on the client side while you set your entity's limb swings on the server side. this requires you to send packets from your server side entity class to the client (which you will need to learn, or maybe Klemen has solved that for you using nbt tags).

and finally you will need to register your renderers and/or packet sending classes through forge's FMLPreInitializationEvent (Klemen already sets that up for you when you create a new living entity, look at that code and copy it).

i know i'm over simplifying the process, but basically you get the idea. lots of things to do.

Last seen on 03:28, 22. Nov 2020
Joined Aug 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
@ahznb i am enlightened :v…
Mon, 10/12/2020 - 22:25

@ahznb

i am enlightened :v

that does look like a lot of work (speaking of renderers and all), but i'll take a look into it. believe it or not though, i'm quite familiar w/ the structure of entity models, but model renderers... they were always in the peak of my confusion. but those sure are some useful and interesting information :P

though you claim it's been oversimplified, thanks for the quite detailed explanation! so yeah, i'll be sure to look into and test everything in my free time.

Last seen on 08:59, 23. Nov 2020
Joined Jul 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
wait what about 1.15.2? i…
Tue, 10/13/2020 - 00:57

wait what about 1.15.2? i want complex tail animation for tadpole

Last seen on 08:59, 23. Nov 2020
Joined Jul 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
will geckolib work
Tue, 10/13/2020 - 01:01

will geckolib work

Last seen on 08:35, 23. Nov 2020
Joined Nov 2019
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
if all that seems…
Tue, 10/13/2020 - 05:41

if all that seems complicated, just let mcreator build a simple one for you and you modify it. make a simple ranged item element with just the default settings and use your entity's java model for the bullet. mcreator will build all the necessary code for you which includes the renderer and all the registering. then create your living entity element and copy the code from the ranged item code, use that as a starting point.

Last seen on 15:57, 7. Nov 2020
Joined Oct 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I think Geckolib is for the…
Sun, 10/18/2020 - 16:58

I think Geckolib is for the 2020.5 snapshot, but if you're using the snapshot then it should work. I haven't tried it out yet, though.