content: /**
   * This file is part of Aion-Lightning <aion-lightning.org>.
   *
   *  Aion-Lightning is free software: you can redistribute it and/or modify
   *  it under the terms of the GNU General Public License as published by
   *  the Free Software Foundation, either version 3 of the License, or
   *  (at your option) any later version.
   *
   *  Aion-Lightning is distributed in the hope that it will be useful,
   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *  GNU General Public License for more details. *
   *  You should have received a copy of the GNU General Public License
   *  along with Aion-Lightning.
   *  If not, see <http://www.gnu.org/licenses/>.
   */
  package com.aionemu.gameserver.network.aion.serverpackets;
  
  import com.aionemu.gameserver.model.gameobjects.Item;
  import com.aionemu.gameserver.model.gameobjects.player.Player;
  import com.aionemu.gameserver.network.aion.AionConnection;
  import com.aionemu.gameserver.network.aion.AionServerPacket;
  import com.aionemu.gameserver.world.World;
  
  /**
   * @author ATracer
   * @rework FrozenKiller
   */
  public class SM_ITEM_USAGE_ANIMATION extends AionServerPacket {
  
  	private int playerObjId;
  	private int targetObjId;
  	private int itemObjId;
  	private int itemId;
  	private int time;
  	private int animationsId;
  
  	public SM_ITEM_USAGE_ANIMATION(int playerObjId, int itemObjId, int itemId, int animationsId, int unk) {
  		this.playerObjId = playerObjId;
  		this.targetObjId = 0;
  		this.itemObjId = itemObjId;
  		this.itemId = itemId;
  		this.time = 0;
  		this.animationsId = 1;
  	}
  
  	public SM_ITEM_USAGE_ANIMATION(int playerObjId, int itemObjId, int itemId) {
  		this.playerObjId = playerObjId;
  		this.targetObjId = 0;
  		this.itemObjId = itemObjId;
  		this.itemId = itemId;
  		this.time = 0;
  		this.animationsId = 1;
  	}
  
  	public SM_ITEM_USAGE_ANIMATION(int playerObjId, int targetObjId, int itemObjId, int itemId, int time, int animationsId) {
  		this.playerObjId = playerObjId;
  		this.targetObjId = targetObjId;
  		this.itemObjId = itemObjId;
  		this.itemId = itemId;
  		this.time = time;
  		this.animationsId = animationsId;
  	}
  
  	@Override
  	protected void writeImpl(AionConnection con) {
  		if (time > 0) {
  			final Player player = World.getInstance().findPlayer(playerObjId);
  			final Item item = player.getInventory().getItemByObjId(itemObjId);
  			player.setUsingItem(item);
  		}
  
  		writeD(playerObjId);
  		writeD(targetObjId);
  		writeD(itemObjId);
  		writeD(itemId);
  		writeD(time);
  		writeH(animationsId); // AnimationsId
  		writeH(1); // Always 1 (5.4)
  		writeD(0); // unk
  	}
  }
  