Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions CookingSkillRedux/Core/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ private static void AfterGiftGiven(object sender, EventArgsGiftGiven e)

private static void BetterCraftingPerformCraftEvent(IGlobalPerformCraftEvent @event)
{
if (@event.Recipe.CraftingRecipe is not null && @event.Recipe.CraftingRecipe.isCookingRecipe)
if ((@event.Recipe.CraftingRecipe is not null && @event.Recipe.CraftingRecipe.isCookingRecipe) ||
(@event.Recipe.Name is not null && CraftingRecipe.cookingRecipes.ContainsKey(@event.Recipe.Name)))
{
@event.Item = PreCook(@event.Recipe.CraftingRecipe, @event.Item, true);
@event.Item = PreCook(@event.Recipe.CraftingRecipe ?? new CraftingRecipe(@event.Recipe.Name, true), @event.Item, true);
@event.Complete();
}
@event.Complete();
Expand All @@ -73,7 +74,9 @@ private static void BetterCraftingPerformCraftEvent(IGlobalPerformCraftEvent @ev

private static void BetterCraftingPostCraftEvent(IPostCraftEvent @event)
{
if (@event.Recipe.CraftingRecipe is not null && @event.Recipe.CraftingRecipe.isCookingRecipe)
// SpaceCore override recipes don't have CraftingRecipe set. In this case compare against vanilla cooking recipes
if ((@event.Recipe.CraftingRecipe is not null && @event.Recipe.CraftingRecipe.isCookingRecipe) ||
(@event.Recipe.Name is not null && CraftingRecipe.cookingRecipes.ContainsKey(@event.Recipe.Name)))
{
//it's easier for me to use a dictionary to not override item stack sized
Dictionary<Item, int> consumed_items_dict = new Dictionary<Item, int>();
Expand All @@ -82,9 +85,9 @@ private static void BetterCraftingPostCraftEvent(IPostCraftEvent @event)
consumed_items_dict.Add(consumed, consumed.Stack);
}

@event.Item = PostCook(@event.Recipe.CraftingRecipe, @event.Item, consumed_items_dict, @event.Player, true);
@event.Item = PostCook(@event.Recipe.CraftingRecipe ?? new CraftingRecipe(@event.Recipe.Name, true), @event.Item, consumed_items_dict, @event.Player, true);
}

}

[SEvent.MenuChanged]
Expand Down Expand Up @@ -311,7 +314,7 @@ public static void OnItemEat(object sender, EventArgs e)
}
}
}


// If the player has the right profession, give them an extra buff
if (player.HasCustomProfession(Cooking_Skill.Cooking10b2))
Expand Down Expand Up @@ -454,7 +457,7 @@ public static Item PostCook(CraftingRecipe recipe, Item item, Dictionary<Item, i
{
item = Utilities.BetterCraftingTempItem;
ModEntry.Instance.Monitor.Log($"Using better crafting - retrived stashed item: {item.DisplayName}", LogLevel.Trace);

}

//Make sure the item coming out of the cooking recipe is an object
Expand Down