Make player do a backflip


New member
Nov 12, 2023
Hi y'all, I've been working on a plugin that allows the player to do a backflip.

Everything works except for this little animation detail that I just can't get over. This detail is less of a problem for a front flip animation, so I've changed the plugin to be "frontflip" for the time being.

I'm using a ClientboundMoveEntityPacket.PosRot in order to move a ServerPlayer that I've created. I've setGliding(true) on the ServerPlayer so that I can simply rotate the pitch of the player in order to get the player's entire body to rotate. However, ClientboundMoveEntityPacket.PosRot has a constructor that has a single byte [-128, 127] for pitch. So the issue I'm experiencing is that once the byte overflows, i.e. goes from -90, -91, -92, ... -126, -127, -128 to 127, the animation for gliding resets on the client side. This screws up the entire animation because the player rotates clockwise for 38 degrees then suddenly jumps back to 12:00 (once the byte overflows) and rotates couterclockwise until it reaches 127, and then resumes its clockwise animation.

I feel like it's so close to working exactly how I want it. If this weren't a byte, this would work. I don't think reflection would work here, though, because I suspect the client expects a byte, too.

Using moveTo on the ServerPlayer only works for valid pitches [-90, 90]. Even though works for armor stands, it won't work for my ServerPlayer :/

Adding the player with a specified pitch only works for valid pitches [-90, 90].

The player will always animate to the pitch value instead of just "teleporting" to the value, too. I've tried several methods using packets to remove and add the player, but alas, I can't remove the counterclockwise animation.

Perhaps there's some sort of packet the allows for relative pitch and yaw movement? Maybe there's a different way to remove the counterclockwise animation?

Just kinda looking for ideas. I'll update this as I go.

Here's a link to the backflip (frontflip) code.