Run crafting task calculation async
This commit is contained in:
@@ -123,9 +123,15 @@ public class ItemGridHandler implements IItemGridHandler {
|
|||||||
ItemStack stack = network.getItemStorageCache().getList().get(hash);
|
ItemStack stack = network.getItemStorageCache().getList().get(hash);
|
||||||
|
|
||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
ICraftingTask task = new CraftingTask(network, stack, network.getPattern(stack), quantity);
|
Thread calculationThread = new Thread(() -> {
|
||||||
task.calculate();
|
ICraftingTask task = new CraftingTask(network, stack, network.getPattern(stack), quantity);
|
||||||
RS.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(task.getPreviewStacks(), hash, quantity), player);
|
|
||||||
|
task.calculate();
|
||||||
|
|
||||||
|
RS.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(task.getPreviewStacks(), hash, quantity), player);
|
||||||
|
}, "RS crafting calculation");
|
||||||
|
|
||||||
|
calculationThread.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -125,6 +125,8 @@ public class GuiCraftingStart extends GuiBase {
|
|||||||
|
|
||||||
if (quantity != null && quantity > 0) {
|
if (quantity != null && quantity > 0) {
|
||||||
RS.INSTANCE.network.sendToServer(new MessageGridCraftingPreview(stack.getHash(), quantity));
|
RS.INSTANCE.network.sendToServer(new MessageGridCraftingPreview(stack.getHash(), quantity));
|
||||||
|
|
||||||
|
startButton.enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user