Task keeps going [Ruse/Necrotic base]
I'm trying to make a simple Task that combines all loops and teeth of ckeys automatically by using Task and TaskManager.
It works, but it keeps going no matter what I try to do to interrupt it. Walking, attacking mob, or anything else.
What am I doing wrong to make sure the task is interrupted/stopped.
This is my code in ItemForging.java
Code:
if (data == ItemForgeData.CRYSTAL_KEY) {
int keys = Math.min(p.getInventory().getAmount(item1), p.getInventory().getAmount(item2));
p.getPacketSender().sendMessage("You start creating crystal keys");
TaskManager.submit(new Task(2, p, true) {
int tick = 0;
@Override
public void execute() {
tick++;
for(Item reqItem : data.requiredItems) {
p.getInventory().delete(reqItem);
}
p.performGraphic(new Graphic(2010));
p.getInventory().add(data.product);
if(tick >= keys)
stop();
}
});
return;
}
Thanks in advance if I'm missing anything!