Guest User

Untitled

a guest
Jul 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. private void updateNPC(PacketBuilder packet, NPC npc) {
  2. /*
  3. * Calculate the mask.
  4. */
  5. int mask = 0;
  6. final UpdateFlags flags = npc.getUpdateFlags();
  7.  
  8. if(flags.get(UpdateFlag.TRANSFORM)) {
  9. mask |= 0x1;
  10. }
  11. if(flags.get(UpdateFlag.FACE_ENTITY)) {
  12. mask |= 0x40;
  13. }
  14. if(flags.get(UpdateFlag.HIT)) {
  15. mask |= 0x80;
  16. }
  17. if(flags.get(UpdateFlag.GRAPHICS)) {
  18. mask |= 0x4;
  19. }
  20. if(flags.get(UpdateFlag.FORCED_CHAT)) {
  21. mask |= 0x20;
  22. }
  23. if(flags.get(UpdateFlag.FACE_COORDINATE)) {
  24. mask |= 0x8;
  25. }
  26. if(flags.get(UpdateFlag.ANIMATION)) {
  27. mask |= 0x2;
  28. }
  29. if(flags.get(UpdateFlag.HIT_2)) {
  30. mask |= 0x10;
  31. }
  32.  
  33. /*
  34. * And write the mask.
  35. */
  36. packet.put((byte) mask);
  37.  
  38. if(flags.get(UpdateFlag.TRANSFORM)) {
  39. //putShortA(transformId)
  40. }
  41. if(flags.get(UpdateFlag.FACE_ENTITY)) {
  42. Entity entity = npc.getInteractingEntity();
  43. packet.putLEShort(entity == null ? -1 : entity.getClientIndex());
  44. }
  45. if(flags.get(UpdateFlag.HIT)) {
  46. //UByteA - hit
  47. //UByteA - hitType
  48. //UByte -
  49. //UByteS -
  50. }
  51. if(flags.get(UpdateFlag.GRAPHICS)) {
  52. packet.putShort(npc.getCurrentGraphic().getId());
  53. packet.putInt2(npc.getCurrentGraphic().getDelay());
  54. }
  55. if(flags.get(UpdateFlag.FORCED_CHAT)) {
  56. //putString
  57. }
  58. if(flags.get(UpdateFlag.FACE_COORDINATE)) {
  59. Location loc = npc.getFaceLocation();
  60. if(loc == null) {
  61. packet.putLEShort(0);
  62. packet.putLEShort(0);
  63. } else {
  64. packet.putLEShortA(loc.getX() * 2 + 1);
  65. packet.putLEShort(loc.getY() * 2 + 1);
  66. }
  67. }
  68. if(flags.get(UpdateFlag.ANIMATION)) {
  69. packet.putShort(npc.getCurrentAnimation().getId());
  70. packet.putByteS((byte) npc.getCurrentAnimation().getDelay());
  71. }
  72. if(flags.get(UpdateFlag.HIT_2)) {
  73. //UByteS - hit
  74. //UByteS - hitType
  75. //UByte -
  76. //UByteC -
  77. }
  78. }
Add Comment
Please, Sign In to add comment