private void handleSwapSlot(Player player, Packet packet) { int oldSlot = packet.readUShort(); int childId = packet.readLEShort(); int interfaceId = packet.readLEShort(); int newSlot = packet.readShortA(); int swapType = packet.readByteS(); int oldItem = player.getInventory().getItemInSlot(oldSlot); int oldAmount = player.getInventory().getAmountInSlot(oldSlot); int newItem = player.getInventory().getItemInSlot(newSlot); int newAmount = player.getInventory().getAmountInSlot(newSlot); if (oldSlot > 28 || oldSlot < 0 || newSlot > 28 || oldSlot < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) { return; } switch (interfaceId) { case 149: if (swapType == 0 && childId == 0) { player.getInventory().getSlot(oldSlot).setItemId(newItem); player.getInventory().getSlot(oldSlot).setItemAmount(newAmount); player.getInventory().getSlot(newSlot).setItemId(oldItem); player.getInventory().getSlot(newSlot).setItemAmount(oldAmount); } break; default: Misc.WriteError("UNHANDLED ITEM SWAP 1 : interface = " + interfaceId); break; } //No need to update the screen since the client does it for us! }
public void handlePacket(Player player, Packet packet) { int size = packet.getLength(); if (packet.getPacketId() == PacketHandlers.PacketId.WALK_2) { size -= 14; } player.getWalkingQueue().resetWalkingQueue(); int steps = (size - 5) / 2; if (steps > WalkingQueue.MAX_WALKING_WAYPOINTS) { Misc.WriteError("Warning: Walk command contains too many steps (" + steps + ") currently set to 50 [maybe need increase?]"); return; } player.getWalkingQueue().setIsRunning(packet.readByteA() == 1); bool following = false; if (!canWalk(player, packet, following)) { player.getPackets().clearMapFlag(); player.getWalkingQueue().resetWalkingQueue(); return; } int firstX = packet.readUShort() - (player.getLocation().getRegionX() - 6) * 8; int firstY = packet.readShortA() - (player.getLocation().getRegionY() - 6) * 8; player.getWalkingQueue().addToWalkingQueue(firstX, firstY); for (int i = 0; i < steps; i++) //all the waypoints. player.getWalkingQueue().addToWalkingQueue((packet.readByteA() + firstX), (packet.readByteS() + firstY)); if (player.getTeleportTo() != null) //is teleporting? player.getWalkingQueue().resetWalkingQueue(); if (player.getTemporaryAttribute("homeTeleporting") != null) { player.removeTemporaryAttribute("homeTeleporting"); } SkillHandler.resetAllSkills(player); if (player.getTrade() != null) player.getTrade().decline(); if (player.getDuel() != null) { if (player.getDuel().getStatus() < 4) player.getDuel().declineDuel(); else if (player.getDuel().getStatus() == 8) player.getDuel().recieveWinnings(player); } if (player.getTarget() != null) { if (!following && player.getTarget().getAttacker() != null && player.getTarget().getAttacker().Equals(player)) player.getTarget().setAttacker(null); } if (!following) { player.getFollow().setFollowing(null); player.setTarget(null); player.removeTemporaryAttribute("autoCasting"); if (player.getEntityFocus() != 65535) player.setEntityFocus(65535); } player.getPackets().closeInterfaces(); }