mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-02-19 00:25:34 +01:00
Optimize spout recipe generation by avoiding filling non-empty items (#7274)
This commit is contained in:
parent
76668d9f9b
commit
abf0633ae6
1 changed files with 9 additions and 0 deletions
|
@ -63,7 +63,16 @@ public class SpoutCategory extends CreateRecipeCategory<FillingRecipe> {
|
|||
if (!capability.isPresent())
|
||||
continue;
|
||||
|
||||
var existingFluidHandler = capability.orElse(null);
|
||||
int numTanks = existingFluidHandler.getTanks();
|
||||
FluidStack existingFluid = numTanks == 1 ? existingFluidHandler.getFluidInTank(0) : FluidStack.EMPTY;
|
||||
|
||||
for (FluidStack fluidStack : fluidStacks) {
|
||||
// Hoist the fluid equality check to avoid the work of copying the stack + populating capabilities
|
||||
// when most fluids will not match
|
||||
if (numTanks == 1 && (!existingFluid.isEmpty() && !existingFluid.isFluidEqual(fluidStack))) {
|
||||
continue;
|
||||
}
|
||||
ItemStack copy = stack.copy();
|
||||
copy.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM)
|
||||
.ifPresent(fhi -> {
|
||||
|
|
Loading…
Add table
Reference in a new issue