[1.12.2] onPlayerItemCrafted lacks a cached map of which recipes returned hasRecipeAction true
PrototypeTrousers opened this issue ยท 3 comments
Issue Description:
Applied Energistics auto-crafting lagging with "expert" modpacks with "endgame" recipes
Every crafted event fired triggers the iteration of ALL recipes
Stream<IRecipe> recipeStream = StreamSupport.stream(Spliterators.spliteratorUnknownSize(CraftingManager.REGISTRY.iterator(), 0), false);
, to then filter then by craftweaker recipes Stream<MCRecipeBase> tweakedRecipeStream = recipeStream.filter(MCRecipeBase.class::isInstance).map(MCRecipeBase.class::cast);
and then by hasRecipeAction.
tweakedRecipeStream.filter(MCRecipeBase::hasRecipeAction)
.filter(recipe->recipe.getRecipeOutput().isItemEqual(ev.crafting)).filter(recipe -> recipe.matches((InventoryCrafting)ev.craftMatrix, ev.player.world))
.forEach(recipe->recipe.getRecipeAction().process(CraftTweakerMC.getIItemStack(ev.crafting), new CraftingInfo(new MCCraftingInventorySquared(ev.craftMatrix, iPlayer), iPlayer.getWorld()), iPlayer));`
What happens:
An "expert" modpack like Omnifactory has 17000 craftweaker recipes
A endgame item in that pack "Heart of Universe" fires around 7000 crafting events when requested by AE2 auto-crafting.
BUT Everytime a crafting event is fired these steps will repeat:
get all recipes
filter craftweaker recipes
get the recipes that return hasRecipeAction true.
So this would mean 119 million recipes looped
What you expected to happen:
cache these 3 steps as since recipes cant be added or removed, in 1.12.2, this part of the function should always return the same, saving processing.
Environment:
- Minecraft Version:1.12.2
- Forge Version: 14.23.5.2847
- CraftTweaker Version: CraftTweaker2-1.12-4.1.20.624
- Are you using a server: No
I searched the craftweaker discord and there was a mention from you that was like this event should not be fired by automated crafting mods ( but AE2 does it ) so i assumed it would not be useful . but in this case i am reopening for better discussion.