PetInventoryUpdate.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package net.sf.l2j.gameserver.serverpackets;
  16. import java.util.List;
  17. import java.util.logging.Logger;
  18. import javolution.util.FastList;
  19. import net.sf.l2j.Config;
  20. import net.sf.l2j.gameserver.model.ItemInfo;
  21. import net.sf.l2j.gameserver.model.L2ItemInstance;
  22. /**
  23. * This class ...
  24. *
  25. * @author Yme
  26. * @version $Revision: 1.3.2.1.2.5 $ $Date: 2005/03/27 15:29:57 $
  27. * Rebuild 23.2.2006 by Advi
  28. */
  29. public class PetInventoryUpdate extends L2GameServerPacket
  30. {
  31. private static Logger _log = Logger.getLogger(InventoryUpdate.class.getName());
  32. private static final String _S__37_INVENTORYUPDATE = "[S] b4 InventoryUpdate";
  33. private List<ItemInfo> _items;
  34. /**
  35. * @param items
  36. */
  37. public PetInventoryUpdate(List<ItemInfo> items)
  38. {
  39. _items = items;
  40. if (Config.DEBUG)
  41. {
  42. showDebug();
  43. }
  44. }
  45. public PetInventoryUpdate()
  46. {
  47. this(new FastList<ItemInfo>());
  48. }
  49. public void addItem(L2ItemInstance item) { _items.add(new ItemInfo(item)); }
  50. public void addNewItem(L2ItemInstance item) { _items.add(new ItemInfo(item, 1)); }
  51. public void addModifiedItem(L2ItemInstance item) { _items.add(new ItemInfo(item, 2)); }
  52. public void addRemovedItem(L2ItemInstance item) { _items.add(new ItemInfo(item, 3)); }
  53. public void addItems(List<L2ItemInstance> items) { for (L2ItemInstance item : items) _items.add(new ItemInfo(item)); }
  54. private void showDebug()
  55. {
  56. for (ItemInfo item : _items)
  57. {
  58. _log.fine("oid:" + Integer.toHexString(item.getObjectId()) +
  59. " item:" + item.getItem().getName()+" last change:" + item.getChange());
  60. }
  61. }
  62. @Override
  63. protected final void writeImpl()
  64. {
  65. writeC(0xb4);
  66. int count = _items.size();
  67. writeH(count);
  68. for (ItemInfo item : _items)
  69. {
  70. writeH(item.getChange());
  71. writeH(item.getItem().getType1()); // item type1
  72. writeD(item.getObjectId());
  73. writeD(item.getItem().getItemId());
  74. writeD(item.getCount());
  75. writeH(item.getItem().getType2()); // item type2
  76. writeH(0x00); // ?
  77. writeH(item.getEquipped());
  78. writeD(item.getItem().getBodyPart()); // rev 415 slot 0006-lr.ear 0008-neck 0030-lr.finger 0040-head 0080-?? 0100-l.hand 0200-gloves 0400-chest 0800-pants 1000-feet 2000-?? 4000-r.hand 8000-r.hand
  79. writeH(item.getEnchant()); // enchant level
  80. writeH(0x00); // ?
  81. writeD(0x00); // T1
  82. writeD(0x00); // T1
  83. writeD(0x00); // T1
  84. writeD(0x00); // T1
  85. writeD(0x00); // T1
  86. writeD(0x00); // T1
  87. writeD(0x00); // T1
  88. writeD(0x00); // T1
  89. }
  90. }
  91. /* (non-Javadoc)
  92. * @see net.sf.l2j.gameserver.serverpackets.ServerBasePacket#getType()
  93. */
  94. @Override
  95. public String getType()
  96. {
  97. return _S__37_INVENTORYUPDATE;
  98. }
  99. }