-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecipeActionLinks.cs
More file actions
31 lines (27 loc) · 942 Bytes
/
Copy pathRecipeActionLinks.cs
File metadata and controls
31 lines (27 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Vintagestory.API.Client;
using Vintagestory.API.Config;
namespace QuickCraft;
internal static class RecipeActionLinks
{
public static RichTextComponentBase Create(ICoreClientAPI api, string label, string langCode, double[] color, Action action)
{
return new RecipeActionButtonComponent(api, label, langCode, color, () => RunSafely(api, action));
}
private static void RunSafely(ICoreClientAPI api, Action action)
{
if (!HandbookSpaceCrafting.CanUseCraftingActions(api))
{
return;
}
try
{
action();
}
catch (Exception exception)
{
api.Logger.Error("Quick Craft action failed: {0}", exception);
api.Gui.PlaySound("menubutton_wood", false, 1f);
api.TriggerIngameError(typeof(RecipeActionLinks), "quickcraft-actionfailed", Lang.Get(ModIds.ModId + ":actionfailed"));
}
}
}