2
0

SpawnItem.java 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 com.l2jserver.gameserver.network.serverpackets;
  16. import com.l2jserver.gameserver.model.L2ItemInstance;
  17. import com.l2jserver.gameserver.model.L2Object;
  18. /**
  19. * 15
  20. * ee cc 11 43 object id
  21. * 39 00 00 00 item id
  22. * 8f 14 00 00 x
  23. * b7 f1 00 00 y
  24. * 60 f2 ff ff z
  25. * 01 00 00 00 show item count
  26. * 7a 00 00 00 count .
  27. *
  28. * format dddddddd
  29. *
  30. * @version $Revision: 1.3.2.1.2.3 $ $Date: 2005/03/27 15:29:39 $
  31. */
  32. public final class SpawnItem extends L2GameServerPacket
  33. {
  34. private static final String _S__15_SPAWNITEM = "[S] 05 SpawnItem";
  35. private int _objectId;
  36. private int _itemId;
  37. private int _x, _y, _z;
  38. private int _stackable;
  39. private long _count;
  40. public SpawnItem(L2Object obj)
  41. {
  42. _objectId = obj.getObjectId();
  43. _x = obj.getX();
  44. _y = obj.getY();
  45. _z = obj.getZ();
  46. if (obj instanceof L2ItemInstance)
  47. {
  48. L2ItemInstance item = (L2ItemInstance) obj;
  49. _itemId = item.getItemId();
  50. _stackable = item.isStackable() ? 0x01 : 0x00;
  51. _count = item.getCount();
  52. }
  53. else
  54. {
  55. _itemId = obj.getPoly().getPolyId();
  56. _stackable = 0;
  57. _count = 1;
  58. }
  59. }
  60. @Override
  61. protected final void writeImpl()
  62. {
  63. writeC(0x05);
  64. writeD(_objectId);
  65. writeD(_itemId);
  66. writeD(_x);
  67. writeD(_y);
  68. writeD(_z);
  69. // only show item count if it is a stackable item
  70. writeD(_stackable);
  71. writeQ(_count);
  72. writeD(0x00); //c2
  73. }
  74. /* (non-Javadoc)
  75. * @see com.l2jserver.gameserver.serverpackets.ServerBasePacket#getType()
  76. */
  77. @Override
  78. public String getType()
  79. {
  80. return _S__15_SPAWNITEM;
  81. }
  82. }