commit f6333429eba6269d19498eb9eddc6f49be0ed9f9 from: SDFTDusername <85052868+SDFTDusername@users.noreply.github.com> via: GitHub date: Sun Sep 14 13:59:25 2025 UTC implement arm swinging animation * Added packets to show players swinging their arms * fix misleading comment --------- Co-authored-by: p2r3 commit - a34134918ad5eb64192e6d33828d433aa9db2f8c commit + f6333429eba6269d19498eb9eddc6f49be0ed9f9 blob - fa0eaa1a46f85c514b3461b4db2128f598da1c47 blob + 4d3b36cd73eed7d55c33642fa532ddfe6a6a1d73 --- include/packets.h +++ include/packets.h @@ -14,6 +14,7 @@ int cs_setPlayerPosition (int client_fd, double *x, do int cs_setPlayerRotation (int client_fd, float *yaw, float *pitch, uint8_t *on_ground); int cs_setPlayerMovementFlags (int client_fd, uint8_t *on_ground); int cs_setHeldItem (int client_fd); +int cs_swingArm (int client_fd); int cs_clickContainer (int client_fd); int cs_closeContainer (int client_fd); int cs_clientStatus (int client_fd); @@ -47,6 +48,7 @@ int sc_acknowledgeBlockChange (int client_fd, int sequ int sc_playerInfoUpdateAddPlayer (int client_fd, PlayerData player); int sc_spawnEntity (int client_fd, int id, uint8_t *uuid, int type, double x, double y, double z, uint8_t yaw, uint8_t pitch); int sc_spawnEntityPlayer (int client_fd, PlayerData player); +int sc_entityAnimation (int client_fd, int id, uint8_t animation); int sc_teleportEntity (int client_fd, int id, double x, double y, double z, float yaw, float pitch); int sc_setHeadRotation (int client_fd, int id, uint8_t yaw); int sc_updateEntityRotation (int client_fd, int id, uint8_t yaw, uint8_t pitch); blob - 0e36da5f71cfa939566a23966deafbcf0b8870ca blob + a489810b0140fda7963e4352b88e1989b77ca6cc --- src/main.c +++ src/main.c @@ -437,6 +437,10 @@ void handlePacket (int client_fd, int length, int pack case 0x34: if (state == STATE_PLAY) cs_setHeldItem(client_fd); break; + + case 0x3C: + if (state == STATE_PLAY) cs_swingArm(client_fd); + break; case 0x28: if (state == STATE_PLAY) cs_playerAction(client_fd); blob - e712d6b478ccfb10e6d1cb66759ad6b2d081f5ee blob + 8fd13a4fc3fee6359f994ce4f14d246d2d7a5791 --- src/packets.c +++ src/packets.c @@ -762,6 +762,43 @@ int cs_setPlayerMovementFlags (int client_fd, uint8_t return 0; } +// C->S Swing Arm (serverbound) +int cs_swingArm (int client_fd) { + + PlayerData *player; + if (getPlayerData(client_fd, &player)) return 1; + + uint8_t hand = readVarInt(client_fd); + + uint8_t animation = 255; + switch (hand) { + case 0: { + animation = 0; + break; + } + case 1: { + animation = 2; + break; + } + } + + if (animation == 255) + return 1; + + // Forward animation to all connected players + for (int i = 0; i < MAX_PLAYERS; i ++) { + PlayerData* other_player = &player_data[i]; + + if (other_player->client_fd == -1) continue; + if (other_player->client_fd == player->client_fd) continue; + if (other_player->flags & 0x20) continue; + + sc_entityAnimation(other_player->client_fd, player->client_fd, animation); + } + + return 0; +} + // C->S Set Held Item (serverbound) int cs_setHeldItem (int client_fd) { @@ -880,6 +917,17 @@ int sc_spawnEntityPlayer (int client_fd, PlayerData pl ); } +// S->C Entity Animation +int sc_entityAnimation (int client_fd, int id, uint8_t animation) { + writeVarInt(client_fd, 2 + sizeVarInt(id)); + writeByte(client_fd, 0x02); + + writeVarInt(client_fd, id); // Entity ID + writeByte(client_fd, animation); // Animation + + return 0; +} + // S->C Teleport Entity int sc_teleportEntity ( int client_fd, int id,