Run crafting task calculation async

This commit is contained in:
Raoul Van den Berge
2016-10-20 19:00:41 +02:00
parent 2e42544c92
commit 8f818312a3
2 changed files with 11 additions and 3 deletions

View File

@@ -123,9 +123,15 @@ public class ItemGridHandler implements IItemGridHandler {
ItemStack stack = network.getItemStorageCache().getList().get(hash);
if (stack != null) {
ICraftingTask task = new CraftingTask(network, stack, network.getPattern(stack), quantity);
task.calculate();
RS.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(task.getPreviewStacks(), hash, quantity), player);
Thread calculationThread = new Thread(() -> {
ICraftingTask task = new CraftingTask(network, stack, network.getPattern(stack), quantity);
task.calculate();
RS.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(task.getPreviewStacks(), hash, quantity), player);
}, "RS crafting calculation");
calculationThread.start();
}
}

View File

@@ -125,6 +125,8 @@ public class GuiCraftingStart extends GuiBase {
if (quantity != null && quantity > 0) {
RS.INSTANCE.network.sendToServer(new MessageGridCraftingPreview(stack.getHash(), quantity));
startButton.enabled = false;
}
}