Jump to content

[1.6.4] [CLIENT] The variable onGround is always false for other players on the


GoblinBob

Recommended Posts

Hi

 

In my mod, I am changing the player's model a litte bit, but then a problem appears..

 

It seems that the client doesn't know if the other player on the server is on ground or not. The same is with the variable moveForward.

 

I am trying to get the value of the onGround variable in the player's model class, but I have also tried it in the RenderBiped and it still is always false.

 

What is the problem, or what am I doing wrong?

 

Thanks in advance :).

 

 

Link to comment
Share on other sites

onGround should be in EntityPlayer, not the model class... I don't know of any way that you can access another player's client-side information (e.g. the other player's model's data) from another client. Your best bet is probably just to check if the other player's posX, Y - 1, and Z are a solid block (on the server), and then send a packet if you need to know on the client, but why you need to know if another player is on the ground or not to render yourself escapes me... perhaps I'm just not understanding what you mean.

Link to comment
Share on other sites

Let's say that I wanted to make a jump animation, that is why I need to know if the player is in air or not. And about the position cheching, I already tried that, and it "works", but it is stilll buggy, cuz you can stay at the edge of a block, and it thinks that you are in air. And I don't use the onGround from the ModelBiped class, but in the setRotationsAndAngles method in the ModelBiped I check the onGround from the EntityPlayer argument

 

public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity)

    {

        EntityPlayer thePlayer = (EntityPlayer) par7Entity;

        thePlayer.onGround;  <-- This is the variable I am using.

Link to comment
Share on other sites

Even if you are trying to animate a player, only do so for the player that is currently available from the client side and then send an animation packet to all nearby clients to update them with the information about the player needing animating.

 

Btw, if you just want to know if the player is in the air, try player.motionY != 0. Your best bet is to do all this stuff client side anyway, since it is just animating. I think you are overcomplicating it when you say you are trying to animate another player - you should never have to do that.

Link to comment
Share on other sites

My mod will be only CLIENT-SIDE, that is the point... . I did a debug, and if you are on ground, the value of motionY is not equal to 0... . It is equal to the motion that it could have when  there would be no ground, if you understand what I am saying. But probbably, just like the onGround variable, the motionX,motionY and motionZ will be always zero for any player but you. Remember, it IS CLIENT SIDE, not a server mod.

Link to comment
Share on other sites

Hi

 

From memory, the packets sent from the server to the client only update entity position and velocity, not on ground. Entity.moveEntity contains logic to set .onGround, but perhaps it is not called for client-side entities (I'm not sure).  Basically, it tries to move you in the negative y direction, finds that there is a block in the way, clips your new y to the block position, and then compares how far you actually moved to how far the caller asked for; if they don't match, you're on the ground.

 

Anyway you could probably copy the onGround logic from moveEntity and run it yourself before rendering. 

 

-TGG

Link to comment
Share on other sites

My mod will be only CLIENT-SIDE, that is the point... . I did a debug, and if you are on ground, the value of motionY is not equal to 0... . It is equal to the motion that it could have when  there would be no ground, if you understand what I am saying. But probbably, just like the onGround variable, the motionX,motionY and motionZ will be always zero for any player but you. Remember, it IS CLIENT SIDE, not a server mod.

I thought that the big [CLIENT] in your title meant you were having troubles with the client side of things, not that you were making a client-side only mod. It's a bit ambiguous, see?

 

The question is still there: why are you trying to render a player other than the one that is currently being rendered? Or is that not what you meant when you said "It seems that the client doesn't know if the other player on the server is on ground or not." ? By "other player" are you just referring to the server-side doppleganger of the client-side player, or actually to another player?

 

Anyway, TGG is spot on, as usual - onGround isn't updated on the client, so you have to do it yourself. You could have just sent a packet from the server to the client with that information, but you are making a client-only mod so you will just have to do the position / block intersection calculations on the client.

Link to comment
Share on other sites

I'd say this, if he's not flying (isFlying?) or falling (changing Y values in a negative direction) then he is probably on ground. I could be wrong.

Link to comment
Share on other sites

Just to throw in my own experience, using Minecraft.getMinecraft().thePlayer.onGround works just fine for me in a client environment, so if you have an EntityPlayer object of any kind onGround should work for you.

 

And....that call will only return the player that is using the client that code is on.  It will not get other players within the client's view frustum.

 

It seems that the client doesn't know if the other player on the server is on ground or not. The same is with the variable moveForward.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Just to throw in my own experience, using Minecraft.getMinecraft().thePlayer.onGround works just fine for me in a client environment, so if you have an EntityPlayer object of any kind onGround should work for you.

 

And....that call will only return the player that is using the client that code is on.  It will not get other players within the client's view frustum.

Yes, but I'm still not 100% sure that he's trying to get other players and not the one using the code. If so, then you are completely right and that solution will not work, but if it turns out the question was just worded poorly and he is, in fact, trying to render the original player, then it will work. By "EntityPlayer of any kind" I really meant any class, not from any client, though if onGround is working client-side for one player, I don't see why it wouldn't work if you grabbed the EntityPlayer instance from the other client with a ray-trace or something. Apparently it doesn't work, though I haven't tried it.

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.