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.

Featured Replies

Posted

Hi all!

 

Is it possible to get an entity's health on the client side?

 

I'm working on a health bar but the entity's health is always max =( =( =(

 

No it's not, client side health bars are impossible.

 

Server has to send the client the new health information with custom packets, this information is not sent to the client in vanilla.

Client side health bars aren't 'impossible'.  But, as stated, they require sending custom packets from server-> every client tracking that entity. (I believe there is even a function in one of the network handlers that does exactly that).

 

I currently have client-side health bars for vehicles in my mod, using the above method.  (send health in initial IEntityAdditionalSpawnData(sp?) packet, and then send updates to all tracking clients every time health changes.)

 

Also there is a function IN the entities precisely for this use.  I think it is called something like handleHealthUpdate(byte data), which is called in world.setEntityState(Entity ent , byte data)  to send the packet to all players, without needing custom packets or handling.  If you look in the wolf or golem code, you can see how this method is used to internally update client-side statistics (health determines a wolf's tail angle, and the golems use it to determine if they should display a rose or not).

Client side health bars aren't 'impossible'.  But, as stated, they require sending custom packets from server-> every client tracking that entity.

That's not client side. That's like saying unaided flight isn't impossible, you just need a plane.

 

'Client Side' health bars, meaning, no server mod required, is impossible.

 

Wow...I'm going to quit trying to help people.

 

I believe I correctly answered his question.

 

Your answer was completely unhelpful, and so was your reply.

 

 

 

This is why people never help/answer questions, I why I no longer will.

 

 

 

  • Author

Your answer was really helpfull=)

 

You shouldn't quit helping =) =)

 

Here is an image about my health bar =D (Don't look at health i was just testing,btw the health number works too.

913dc3fe2e5b524d771b2218e3621bf2.png

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.