EquipUpdate.java 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.network.serverpackets;
  20. import com.l2jserver.gameserver.model.items.L2Item;
  21. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  22. public final class EquipUpdate extends L2GameServerPacket
  23. {
  24. private final L2ItemInstance _item;
  25. private final int _change;
  26. public EquipUpdate(L2ItemInstance item, int change)
  27. {
  28. _item = item;
  29. _change = change;
  30. }
  31. @Override
  32. protected final void writeImpl()
  33. {
  34. int bodypart = 0;
  35. writeC(0x4b);
  36. writeD(_change);
  37. writeD(_item.getObjectId());
  38. switch (_item.getItem().getBodyPart())
  39. {
  40. case L2Item.SLOT_L_EAR:
  41. bodypart = 0x01;
  42. break;
  43. case L2Item.SLOT_R_EAR:
  44. bodypart = 0x02;
  45. break;
  46. case L2Item.SLOT_NECK:
  47. bodypart = 0x03;
  48. break;
  49. case L2Item.SLOT_R_FINGER:
  50. bodypart = 0x04;
  51. break;
  52. case L2Item.SLOT_L_FINGER:
  53. bodypart = 0x05;
  54. break;
  55. case L2Item.SLOT_HEAD:
  56. bodypart = 0x06;
  57. break;
  58. case L2Item.SLOT_R_HAND:
  59. bodypart = 0x07;
  60. break;
  61. case L2Item.SLOT_L_HAND:
  62. bodypart = 0x08;
  63. break;
  64. case L2Item.SLOT_GLOVES:
  65. bodypart = 0x09;
  66. break;
  67. case L2Item.SLOT_CHEST:
  68. bodypart = 0x0a;
  69. break;
  70. case L2Item.SLOT_LEGS:
  71. bodypart = 0x0b;
  72. break;
  73. case L2Item.SLOT_FEET:
  74. bodypart = 0x0c;
  75. break;
  76. case L2Item.SLOT_BACK:
  77. bodypart = 0x0d;
  78. break;
  79. case L2Item.SLOT_LR_HAND:
  80. bodypart = 0x0e;
  81. break;
  82. case L2Item.SLOT_HAIR:
  83. bodypart = 0x0f;
  84. break;
  85. case L2Item.SLOT_BELT:
  86. bodypart = 0x10;
  87. break;
  88. }
  89. writeD(bodypart);
  90. }
  91. }