Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.8] custom mob rendering during attack

Featured Replies

Posted

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.

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.

  • Author

I looked at the iron golem but couldn't figure out what is used. Thanks.

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

It works, I don't know why.

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.