Skip to content

Commit

Permalink
Merge pull request #291 from Ricket/crafting-cache-fix
Browse files Browse the repository at this point in the history
Crafting Cache: check if recipe matches before returning
  • Loading branch information
ACGaming authored Oct 25, 2023
2 parents c34bd2f + 1fed471 commit a1e3b86
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,16 @@ public static IRecipe findMatchingRecipe(InventoryCrafting craftMatrix, World wo
if (isValid(craftMatrix) && Loader.instance().hasReachedState(LoaderState.SERVER_STARTING))
{
UTOptionalContent<IRecipe> optionalContent = getOrCreateCachedRecipe(craftMatrix);
if (!optionalContent.hasContent()) optionalContent.setContent(findMatchingRecipeDefault(craftMatrix, worldIn));
return optionalContent.getContent();

if (optionalContent.hasContent())
{
IRecipe recipe = optionalContent.getContent();
if (recipe == null || recipe.matches(craftMatrix, worldIn)) return recipe;
}

IRecipe recipe = findMatchingRecipeDefault(craftMatrix, worldIn);
optionalContent.setContent(recipe);
return recipe;
}
return findMatchingRecipeDefault(craftMatrix, worldIn);
}
Expand Down

0 comments on commit a1e3b86

Please sign in to comment.