Example #1
0
 private void handleEquipItem(Player player, Packet packet) {
   int itemId = packet.getIn().readShort(); // Item ID.
   player.setSlot(packet.getIn().readShort(StreamBuffer.ValueType.A));
   player.setInterfaceId(packet.getIn().readShort(StreamBuffer.ValueType.A)); // Interface ID.
   RSInterface inter = RSInterface.forId(player.getInterfaceId());
   if (!player.hasInterfaceOpen(inter)) {
     return;
   }
   if (itemId == 6541) {
     player.getPets().registerPet(6541, 901);
     return;
   }
   if (itemId == 5608) {
     player.getEquipment().equip(player.getSlot());
     return;
   }
   if (itemId == 5609) {
     player.getEquipment().equip(player.getSlot());
     return;
   }
   if (GoblinDiplomacy.itemHandling(player, itemId)) {
     return;
   }
   if (AnimalMagnetism.itemHandling(player, itemId)) {
     return;
   }
   if (itemId == 11664)
     if (player.hasFullVoidRange()
         && player.getSkill().getLevel()[4] <= player.getSkill().getPlayerLevel(4)) {
       player.getSkill().getLevel()[4] = (int) (player.getSkill().getPlayerLevel(4) * 1.1);
       return;
     }
   if (new Item(itemId).getDefinition().getSlot() == -1) {
     return;
   }
   if (player.getDuelMainData().getOpponent() != null && !player.inDuelArena()) {
     player.getDuelInteraction().endDuelInteraction(true);
     return;
   }
   // player.getActionSender().removeInterfaces();
   Item item = player.getInventory().getItemContainer().get(player.getSlot());
   if (item == null || item.getId() != itemId || !item.validItem()) {
     return;
   }
   player.getEquipment().equip(player.getSlot());
 }
Example #2
0
  private void useItemOnItem(Player player, Packet packet) {
    int itemSecondClickSlot = packet.getIn().readShort();
    int itemFirstClickSlot = packet.getIn().readShort(StreamBuffer.ValueType.A);
    packet.getIn().readShort();
    packet.getIn().readShort();
    if (itemFirstClickSlot > 28 || itemSecondClickSlot > 28) {
      return;
    }
    Item firstClickItem = player.getInventory().getItemContainer().get(itemFirstClickSlot);
    Item secondClickItem = player.getInventory().getItemContainer().get(itemSecondClickSlot);
    if (firstClickItem == null
        || secondClickItem == null
        || !firstClickItem.validItem()
        || !secondClickItem.validItem()) return;
    int firstItem = firstClickItem.getId();
    int secondItem = secondClickItem.getId();
    if (player.getDuelMainData().getOpponent() != null) {
      player.getDuelInteraction().endDuelInteraction(true);
      return;
    }
    if (OneIngredients.mixItems(
        player, firstItem, secondItem, itemFirstClickSlot, itemSecondClickSlot)) return;
    if (TwoIngredients.mixItems(
        player, firstItem, secondItem, itemFirstClickSlot, itemSecondClickSlot)) return;
    if (ThreeIngredients.mixItems(
        player, firstItem, secondItem, itemFirstClickSlot, itemSecondClickSlot)) return;
    if (DoughHandler.handleInterface(
        player, firstItem, secondItem, itemFirstClickSlot, itemSecondClickSlot)) return;
    /* Fletching */
    if (ArrowMaking.perform(player, firstItem, secondItem)) return;
    if (BowStringing.perform(player, firstItem, secondItem)) return;
    if (LogCuttingInterfaces.handleItemOnItem(player, firstItem, secondItem)) return;
    if (CbowFletching.attachLimbs(player, firstItem, secondItem)
        || CbowFletching.stringCbow(player, firstItem, secondItem)) return;
    if (GemTips.handleCutting(
        player,
        firstItem,
        secondItem,
        firstItem != GemTips.CHISEL ? itemFirstClickSlot : itemSecondClickSlot)) return;
    /* Crafting */
    if (GemCutting.handleCutting(
        player,
        firstItem,
        secondItem,
        firstItem != GemCutting.CHISEL ? itemFirstClickSlot : itemSecondClickSlot)) return;
    if (LeatherMakingHandler.handleItemOnItem(
        player, firstItem, secondItem, itemFirstClickSlot, itemSecondClickSlot)) return;
    if (BasicCraft.handleItemOnItem(player, firstItem, secondItem)) return;
    if ((firstItem == GlassMaking.GLASSBLOWING_PIPE && secondItem == GlassMaking.MOLTEN_GLASS)
        || (secondItem == GlassMaking.GLASSBLOWING_PIPE && firstItem == GlassMaking.MOLTEN_GLASS)) {
      Menus.sendSkillMenu(player, "glassMaking");
      return;
    }
    /* STRINGING AMULETS */
    for (int i = 0; i < GemData.stringItems.length; i++) {
      if (GemData.stringItems[i][0] == firstItem || GemData.stringItems[i][0] == secondItem) {
        GemCrafting.string(player, i);
        return;
      }
    }
    if (ElementalWorkshop.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    if (ShieldOfArrav.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    if (DragonSlayer.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    if (GoblinDiplomacy.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    if (PiratesTreasure.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    if (ErnestTheChicken.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    if (GhostsAhoy.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    if (AnimalMagnetism.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    if (TabHandler.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    if (wetClayHandler.itemOnItemHandling(player, firstItem, secondItem)) {
      return;
    }
    /* Farming */
    if (player
        .getSeedling()
        .placeSeedInPot(
            firstClickItem.getId(),
            secondClickItem.getId(),
            itemFirstClickSlot,
            itemSecondClickSlot)) {
      return;
    }
    if (player
        .getSeedling()
        .waterSeedling(
            firstClickItem.getId(),
            secondClickItem.getId(),
            itemFirstClickSlot,
            itemSecondClickSlot)) {
      return;
    }
    if (player
        .getItemOnItem()
        .handleItemOnItem(
            firstClickItem, secondClickItem, itemFirstClickSlot, itemSecondClickSlot)) {
      return;
    }
    if (Tools.attachTool(player, firstItem, secondItem)) {
      player.getActionSender().sendMessage("You put together the head and handle.");
      return;
    }
    /*Slayer*/
    if (player.getSlayer().handleItemOnItem(firstItem, secondItem)) {
      return;
    }
    /* Herblore */
    if (PotionMaking.createPotion(
        player, firstClickItem, secondClickItem, itemFirstClickSlot, itemSecondClickSlot)) {
      return;
    }
    if (Grinding.createProduct(
        player, firstClickItem, secondClickItem, itemFirstClickSlot, itemSecondClickSlot)) {
      return;
    }
    if (PoisoningWeapon.handlePoison(player, firstClickItem, secondClickItem)) {
      return;
    }
    if (Coconut.handleCoconut(player, firstClickItem, secondClickItem)) {
      return;
    }
    if (PotionMaking.combineDose(
        player, firstItem, secondItem, itemFirstClickSlot, itemSecondClickSlot)) {
      return;
    }
    /* Firemaking */
    if (firstItem == 590 || secondItem == 590) {
      if (firstItem == 596 && secondItem == 596) {
        if (player.getInventory().removeItem(new Item(596))) {
          player.getInventory().addItem(new Item(594));
          player.getActionSender().sendMessage("You light the torch.");
          return;
        }
      }
      if (firstItem == 36 && secondItem == 36) {
        if (player.getInventory().removeItem(new Item(36))) {
          player.getInventory().addItem(new Item(33));
          player.getActionSender().sendMessage("You light the candle.");
          return;
        }
      }
      player
          .getFiremaking()
          .attemptFire(
              firstItem,
              secondItem,
              false,
              player.getPosition().getX(),
              player.getPosition().getY(),
              player.getPosition().getZ());
      return;
    }

    if (GodBook.addPageToBook(
        player, firstClickItem, secondClickItem, itemFirstClickSlot, itemSecondClickSlot)) {
      return;
    }
    if (firstClickItem.getId() == 1765 && secondClickItem.getId() == 2421) {
      player.getActionSender().sendMessage("You carefully dye the wig blonde.");
      player.getInventory().removeItem(new Item(2421));
      player.getInventory().removeItem(new Item(1765));
      player.getInventory().addItem(new Item(2419));
      return;
    }
    if (firstClickItem.getId() == 1973 && secondClickItem.getId() == 233) {
      player
          .getActionSender()
          .sendMessage("You use your pestle and mortar to turn the chocolate to dust.");
      player.getInventory().removeItem(new Item(1973));
      player.getInventory().addItem(new Item(1975));
      return;
    }
    if (firstClickItem.getId() == 946 && secondClickItem.getId() == 1973) {
      player.getActionSender().sendMessage("You use your knife to turn the chocolate to dust.");
      player.getInventory().removeItem(new Item(1973));
      player.getInventory().addItem(new Item(1975));
      return;
    }
    player.getActionSender().sendMessage("Nothing interesting happens.");
  }