61 public Herblore(
int level,
double experience) {
62 super(
Skill.HERBLORE, level, experience);
66 protected double modifier() {
71 protected boolean clickItem(
Player player, ItemInteractionEvent event) {
72 final int slot =
event.getSlot();
73 final Item item = player.inventory.
get(slot);
83 GrimyHerb herb = GrimyHerb.forId(item.getId()).get();
86 final String name = herb.getGrimy().getName();
91 player.inventory.
remove(item);
92 player.inventory.
add(herb.getClean());
94 RandomEventHandler.trigger(player);
99 protected boolean useItem(Player player, ItemOnItemInteractionEvent e) {
100 final int useSlot = e.getFirstSlot();
101 final int withSlot = e.getSecondSlot();
102 final Item use = player.inventory.get(useSlot);
103 final Item with = player.inventory.get(withSlot);
105 if (use ==
null || with ==
null) {
109 final Potion potion = UnfinishedPotion.get(use, with) ==
null ? FinishedPotion.get(use, with) : UnfinishedPotion.get(use, with);
111 if (potion ==
null) {
115 if (
getLevel() < potion.getLevel()) {
116 final String name = potion.getProduct().getName();
117 player.dialogueFactory.sendStatement(
"<col=369>You need a Herblore level of " + potion.getLevel() +
" to make " + StringUtils.getAOrAn(name) +
" " + name +
" potion.").execute();
121 if (player.inventory.computeAmountForId(use.getId()) == 1 || player.inventory.computeAmountForId(with.getId()) == 1) {
122 player.inventory.set(useSlot > withSlot ? withSlot : useSlot, potion.getProduct(),
true);
123 player.inventory.set(useSlot < withSlot ? withSlot : useSlot,
null,
true);
124 player.animate(
new Animation(potion.getAnimation()));
126 ChatBoxItemDialogue.sendInterface(player, 1746, potion.getProduct(), 170);
127 player.chatBoxItemDialogue =
new ChatBoxItemDialogue(player) {
129 public void firstOption(Player player) {
130 player.action.execute(mix(player, potion, 1),
true);
134 public void secondOption(Player player) {
135 player.action.execute(mix(player, potion, 5),
true);
139 public void thirdOption(Player player) {
140 player.send(
new SendInputAmount(
"Enter amount", 10, input -> player.action.execute(mix(player, potion, Integer.parseInt(input)),
true)));
144 public void fourthOption(Player player) {
145 player.action.execute(mix(player, potion, 14),
true);
153 private Action<Player> mix(Player player, Potion potion,
int amount) {
154 return new Action<Player>(player, 2) {
158 public void execute() {
159 if (!player.inventory.containsAll(potion.getIngredients())) {
164 player.animate(
new Animation(potion.getAnimation()));
165 final boolean saveIngredient = SkillCape.isEquipped(player, SkillCape.HERBLORE) && Utility.random(1, 3) == 1;
166 if (!saveIngredient) {
167 player.inventory.removeAll(potion.getIngredients());
169 player.inventory.addOrDrop(potion.getProduct());
170 player.skills.addExperience(
Skill.HERBLORE, potion.getExperience() * modifier());
171 player.playerAssistant.activateSkilling(1);
172 AchievementHandler.activate(player, AchievementKey.HERBLORE, 1);
173 RandomEventHandler.trigger(player);
175 if (potion == FinishedPotion.SUPER_RESTORE) {
176 getMob().forClan(channel -> channel.activateTask(ClanTaskKey.SUPER_RESTORE_POTION, getMob().
getName()));
179 if (++ticks == amount) {
186 return "Herblore mix";
190 public boolean prioritized() {
195 public WalkablePolicy getWalkablePolicy() {
196 return WalkablePolicy.NON_WALKABLE;