Fixes #3040: Cache recipe and revalidate it (#3042)

* Fixes #3040: Cache recipe and revalidate it

This caches the last used recipe instead of only the result. Which
allows to revalidate the crafting grid against the recipe itself before
hitting the CraftingManager again. Therefore avoiding a high performance
hit for recipe lookups, just find the potential same recipe again.

* Remove old recipe lookup as forge provides it now.

* Further optimizations.

These are a bit quick'n'dirty and need a better solution with a full
container/gui refactoring. But for now they provide some great benefits
in terms of performance.
This commit is contained in:
yueh
2017-08-20 21:31:30 +02:00
committed by GitHub
parent d84500c5b7
commit b8e685b1b6
7 changed files with 75 additions and 26 deletions
-19
View File
@@ -432,25 +432,6 @@ public class Platform
}
}
/*
* The usual version of this returns an ItemStack, this version returns the recipe.
*/
public static IRecipe findMatchingRecipe( final InventoryCrafting inventoryCrafting, final World par2World )
{
IForgeRegistry<IRecipe> recipes = ForgeRegistries.RECIPES;
final List<IRecipe> rl = recipes.getValues();
for( final IRecipe r : rl )
{
if( r.matches( inventoryCrafting, par2World ) )
{
return r;
}
}
return null;
}
public static ItemStack[] getBlockDrops( final World w, final BlockPos pos )
{
List<ItemStack> out = new ArrayList<>();