Getting the player OnGround status

Hi,

I’ve started to develop a plugin and was searching for a way to get the ground status of the player, naturally I found the Player#isOnGround method and thought it to be the ground status the client sends. However from some testing I found it to be a value calculated by the server. Thus, I was wondering how I can get access to the ground status that the client sends.

There should be no difference between the two approaches. I don’t even think that there is a onGround packet like thing that the client sends. It is probably just calculated by the client based on the player’s location, too.
What do you want to achieve?

The client does send a ground status with its movement updates. That value is what the server does its fall damage calculations on. I’m developing an AntiCheat and I’m currently working on a NoFall check, that’s why I want that value.

I could just cancel all fall damage (for hackers and legit players) and just damage them based on my own calculations but then I wouldn’t be able to get any violation data from it.

I searched in the NMS’s sources, I found that Entity#isOnGround returns the onGround field and this field is updated for any movement or teleport packet received in NetHandlerPlayClient:
entity.onGround = packetIn.getOnGround();

So when the server receive a packet from the client, the onGround field is synced, but everytime the NMS method Entity#move is called, the server recalculate the onGround status:
this.onGround = this.isCollidedVertically && d4 < 0.0D;

To intercept the onGround status sent by the client, you have to call Entity#isOnGround at the right time.

1 Like

That’s annoying. I can’t think of an event that would allow me to capture it before it’s calculated by the server. It’s weird though, if the server calculates the value, why does Mojang send it to the server at all?

Thanks for the help, I guess I’ll just have to try and work around the limitations.

An anti cheat must often interact with a very low level of the server (NMS), using only the top level api is almost impossible. I suggest you to use Mixin to get rid of the limitations of the api.

1 Like

I guess you’re right, it’s something I’d rather not do for obvious reasons but I might have to. Right now I’m able to block NoFall using the method in my post above but like I said, I can’t collect violation data off of this.

Again thanks a lot.