Posted December 27, 201212 yr 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 =( =( =(
December 27, 201212 yr 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.
December 28, 201212 yr 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).
January 2, 201312 yr 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.
January 2, 201312 yr 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.
January 3, 201312 yr 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.
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.