mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-02-20 17:15: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())
|
if (!capability.isPresent())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
var existingFluidHandler = capability.orElse(null);
|
||||||
|
int numTanks = existingFluidHandler.getTanks();
|
||||||
|
FluidStack existingFluid = numTanks == 1 ? existingFluidHandler.getFluidInTank(0) : FluidStack.EMPTY;
|
||||||
|
|
||||||
for (FluidStack fluidStack : fluidStacks) {
|
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();
|
ItemStack copy = stack.copy();
|
||||||
copy.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM)
|
copy.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM)
|
||||||
.ifPresent(fhi -> {
|
.ifPresent(fhi -> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue