Jump to content

[1.8] custom mob rendering during attack


MCRaichu

Recommended Posts

Hi,

I'm trying to render a mob differently while it is attacking. But since the combat AI is executed at the server (the attackTarget is only set there), what would be the best way to synchronize them? I know datawatcher is an option but when i tried it was totally out of sync.

It doesn't work, I don't know why.

It works, I don't know why.

Link to comment
Share on other sites

I find #setEntityState in combination with #handleHealthUpdate to be useful methods of triggering animations. In a nutshell, #setEntityState takes an integer and sends it over the network to the client which then calls #handleHealthUpdate with that integer as an argument, so you can use different values to trigger different animations.

 

Take a look at EntityIronGolem to see an example.

Link to comment
Share on other sites

When the golem attacks (which happens on the server), it calls #setEntityState with flag '4' - this gets sent to the client-side version of the golem via #handleHealthUpdate; when it receives the flag '4', it sets the golem's attackTimer to 10 on the client side, which is visible to the the golem's model. In the model class, the attackTimer is used to animate the golem's swinging arms.

 

The most important point is you need a way to notify the client to perform the animation, and that's where those 2 methods come in super handy.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.