MCRaichu Posted October 4, 2015 Posted October 4, 2015 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. Quote It doesn't work, I don't know why. It works, I don't know why.
coolAlias Posted October 5, 2015 Posted October 5, 2015 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. Quote http://i.imgur.com/NdrFdld.png[/img]
MCRaichu Posted October 5, 2015 Author Posted October 5, 2015 I looked at the iron golem but couldn't figure out what is used. Thanks. Quote It doesn't work, I don't know why. It works, I don't know why.
coolAlias Posted October 5, 2015 Posted October 5, 2015 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. Quote http://i.imgur.com/NdrFdld.png[/img]
Recommended Posts
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.