/** * Updates a non-this player's movement. * @param packet The packet. * @param otherPlayer The player. */ public void updatePlayerMovement(PacketBuilder packet, Player otherPlayer) { /* * Check which type of movement took place. */ if(otherPlayer.getSprites().getPrimarySprite() == -1) { /* * If no movement did, check if an update is required. */ if(otherPlayer.getUpdateFlags().isUpdateRequired()) { /* * Signify that an update happened. */ packet.putBits(1, 1); /* * Signify that there was no movement. */ packet.putBits(2, 0); } else { /* * Signify that nothing changed. */ packet.putBits(1, 0); } } else if(otherPlayer.getSprites().getSecondarySprite() == -1) { /* * The player moved but didn't run. Signify that an update is * required. */ packet.putBits(1, 1); /* * Signify we moved one tile. */ packet.putBits(2, 1); /* * Write the primary sprite (i.e. walk direction). */ packet.putBits(3, otherPlayer.getSprites().getPrimarySprite()); /* * Write a flag indicating if a block update happened. */ packet.putBits(1, otherPlayer.getUpdateFlags().isUpdateRequired() ? 1 : 0); } else { /* * The player ran. Signify that an update happened. */ packet.putBits(1, 1); /* * Signify that we moved two tiles. */ packet.putBits(2, 2); /* * Write the primary sprite (i.e. walk direction). */ packet.putBits(3, otherPlayer.getSprites().getPrimarySprite()); /* * Write the secondary sprite (i.e. run direction). */ packet.putBits(3, otherPlayer.getSprites().getSecondarySprite()); /* * Write a flag indicating if a block update happened. */ packet.putBits(1, otherPlayer.getUpdateFlags().isUpdateRequired() ? 1 : 0); } }