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()); }
private void handleClick1(Player player, Packet packet) { int interfaceID = packet.getIn().readShort(StreamBuffer.ValueType.A); player.setSlot(packet.getIn().readShort(StreamBuffer.ValueType.A)); int itemId = packet.getIn().readShort(StreamBuffer.ValueType.A); RSInterface inter = RSInterface.forId(interfaceID); switch (interfaceID) { case 4233: // make 1 ring crafting GemCrafting.startCrafter(player, GemData.getGemSlot()[player.getSlot()], 1, 0); break; case 4239: // make 1 neckalce crafting GemCrafting.startCrafter(player, GemData.getGemSlot()[player.getSlot()], 1, 1); break; case 4245: // make 1 amulet crafting GemCrafting.startCrafter(player, GemData.getGemSlot()[player.getSlot()], 1, 2); break; case 18821: // make 1 bracelet crafting GemCrafting.startCrafter(player, GemData.getGemSlot()[player.getSlot()], 1, 3); break; } if (!player.hasInterfaceOpen(inter)) { // player.getActionSender().removeInterfaces(); return; } if (interfaceID == 1119 || interfaceID == 1120 || interfaceID == 1121 || interfaceID == 1122 || interfaceID == 1123) { // player.getSmithing().smithItem(itemId, 1); SmithBars.startSmithing(player, itemId, 1); } if (interfaceID == 1688) { player.getEquipment().unequip(player.getSlot()); } else if (interfaceID == 5064 || interfaceID == 7423) { BankManager.bankItem(player, player.getSlot(), itemId, 1); } else if (interfaceID == 5382) { BankManager.withdrawItem(player, player.getSlot(), itemId, 1); } else if (interfaceID == 3900) { ShopManager.getBuyValue(player, itemId); } else if (interfaceID == 3823) { ShopManager.getSellValue(player, itemId); } else if (interfaceID == 3322) { if (player.getStatedInterface() == "duel") player.getDuelMainData().stakeItem(new Item(itemId, 1), player.getSlot()); else TradeManager.offerItem(player, player.getSlot(), itemId, 1); } else if (interfaceID == 3415) { TradeManager.removeTradeItem(player, player.getSlot(), itemId, 1); } else if (interfaceID == 15682 || interfaceID == 15683) { player.getFarmingTools().withdrawItems(itemId, 1); } else if (interfaceID == 15594 || interfaceID == 15595) { player.getFarmingTools().storeItems(itemId, 1); } else if (interfaceID == 6669) { player.getDuelMainData().removeStakedItem(new Item(itemId, 1)); } }
public static boolean cookedSuccessfully( Player player, int cookLevel, int burnStopLevelWith, int burnStopLevel) { /* * The burning formula by Clifton */ final double burnBonus = 3.0; double burn_chance = 50.0 - burnBonus; // 55.0 final double cook_level = player.getSkill().getLevel()[Skill.COOKING]; final double lev_needed = cookLevel; final double burn_stop = (player.getEquipment().getItemContainer().get(Constants.HANDS) != null && player.getEquipment().getItemContainer().get(Constants.HANDS).getId() == GAUNTLET) ? burnStopLevelWith : burnStopLevel; final double multi_a = burn_stop - lev_needed; final double burn_dec = burn_chance / multi_a; final double multi_b = cook_level - lev_needed; burn_chance -= multi_b * burn_dec; double randNum = new Random().nextDouble() * 100.0; return burn_chance <= randNum; }
private void handleDropItem(Player player, Packet packet) { int itemId = packet.getIn().readShort(StreamBuffer.ValueType.A); packet.getIn().readShort(); player.setSlot(packet.getIn().readShort(StreamBuffer.ValueType.A)); Item item = player.getInventory().getItemContainer().get(player.getSlot()); if (Puzzle.moveSlidingPiece(player, itemId)) return; if (item == null || item.getId() != itemId || !item.validItem()) return; if (item.getDefinition().isStackable()) { item.setCount(player.getInventory().getItemContainer().getCount(item.getId())); } else { item.setCount(1); } if (!player.getInventory().getItemContainer().contains(item.getId())) { return; } if (item.getId() == 530 && player.getPosition().getX() == 2780 && player.getPosition().getY() == 3515) { if (player.getInventory().playerHasItem(32)) { player.getInventory().removeItem(new Item(530)); MerlinsCrystal.summon(player); return; } else { player .getDialogue() .sendStatement("Nothing happens. Perhaps you should light the candle first."); return; } } if (WarriorsGuild.itemHandling(player, itemId)) { return; } if (item.getId() == 10592) { player.getActionSender().sendMessage("Play the bongos instead."); return; } if (item.getId() == 6541) { player.getActionSender().sendMessage("You don't want to destroy your pet!"); return; } for (int[] element : Pets.PET_IDS) { if (item.getDefinition().getId() == element[0]) { player.getPets().registerPet(element[0], element[1]); return; } } if (item.getDefinition().isUntradable() || item.getId() == 763 || item.getId() == 765 || item.getId() == 769 || item.getId() == 288 || item.getId() == 10498 || item.getId() == 10499) { if (BarrowsItems.notDroppable(BarrowsItems.getBarrowsItem(item), item)) { String[][] info = { {"Are you sure you want to drop this item?", "14174"}, {"Yes.", "14175"}, {"No.", "14176"}, {"", "14177"}, {"Dropping this item will make it break completely.", "14182"}, {"", "14183"}, {item.getDefinition().getName(), "14184"} }; for (String[] element : info) { player.getActionSender().sendString(element[0], Integer.parseInt(element[1])); } } else { String[][] info = { {"Are you sure you want to drop this item?", "14174"}, {"Yes.", "14175"}, {"No.", "14176"}, {"", "14177"}, {"Dropping this item will make you lose it forever.", "14182"}, {"", "14183"}, {item.getDefinition().getName(), "14184"} }; for (String[] element : info) { player.getActionSender().sendString(element[0], Integer.parseInt(element[1])); } } player.getActionSender().sendUpdateItem(item, 0, 14171, 1); player.setDestroyItem(item); player.getActionSender().sendChatInterface(14170); return; } if (player.getInventory().getItemContainer().contains(item.getId())) { player.getActionSender().sendSound(376, 1, 0); if (!Constants.ADMINS_CAN_INTERACT && player.getStaffRights() >= 2) { player .getActionSender() .sendMessage("Your item disappears because you're an administrator."); } else { GroundItemManager.getManager() .dropItem(new GroundItem(new Item(item.getId(), item.getCount()), player)); } if (!player.getInventory().removeItemSlot(item, player.getSlot())) { player.getInventory().removeItem(item); } player.getActionSender().removeInterfaces(); player.getDialogue().resetDialogue(); } player.getEquipment().updateWeight(); }