* 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:
@@ -24,6 +24,7 @@ import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
@@ -149,7 +150,7 @@ public class AppEngCraftingSlot extends AppEngSlot
|
||||
ic.setInventorySlotContents( x, this.craftMatrix.getStackInSlot( x ) );
|
||||
}
|
||||
|
||||
final NonNullList<ItemStack> aitemstack = CraftingManager.getRemainingItems( ic, playerIn.world );
|
||||
final NonNullList<ItemStack> aitemstack = this.getRemainingItems( ic, playerIn.world );
|
||||
|
||||
ItemHandlerUtil.copy( ic, this.craftMatrix, false );
|
||||
|
||||
@@ -195,4 +196,10 @@ public class AppEngCraftingSlot extends AppEngSlot
|
||||
|
||||
return super.decrStackSize( par1 );
|
||||
}
|
||||
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring.
|
||||
protected NonNullList<ItemStack> getRemainingItems( InventoryCrafting ic, World world )
|
||||
{
|
||||
return CraftingManager.getRemainingItems( ic, world );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user