Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overload AbstractRecipeLogic functions #2311

Merged
merged 5 commits into from
Jan 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -432,34 +432,51 @@ protected boolean checkCleanroomRequirement(@NotNull Recipe recipe) {
* <ol>
* <li>The recipe is run in parallel if possible.</li>
* <li>The potentially parallel recipe is then checked to exist.</li>
* <li>If it exists, it checks if the recipe is runnable with the current inputs.</li>
* <li>If it exists, it checks if the recipe is runnable with the inputs provided.</li>
* </ol>
* If the above conditions are met, the recipe is engaged to be run
*
* @param recipe the recipe to prepare
* @param inputInventory the inventory to draw items from
* @param inputFluidInventory the fluid tanks to draw fluid from
* @return true if the recipe was successfully prepared, else false
*/
protected boolean prepareRecipe(Recipe recipe) {
protected boolean prepareRecipe(Recipe recipe, IItemHandlerModifiable inputInventory, IMultipleTankHandler inputFluidInventory) {
recipe = Recipe.trimRecipeOutputs(recipe, getRecipeMap(), metaTileEntity.getItemOutputLimit(),
metaTileEntity.getFluidOutputLimit());

// Pass in the trimmed recipe to the parallel logic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this comment? It is still accurate

recipe = findParallelRecipe(
recipe,
getInputInventory(),
getInputTank(),
inputInventory,
inputFluidInventory,
getOutputInventory(),
getOutputTank(),
getMaxParallelVoltage(),
getParallelLimit());

if (recipe != null && setupAndConsumeRecipeInputs(recipe, getInputInventory())) {
if (recipe != null && setupAndConsumeRecipeInputs(recipe, inputInventory, inputFluidInventory)) {
setupRecipe(recipe);
return true;
}
return false;
}

/**
* Prepares the recipe to be run.
* <ol>
* <li>The recipe is run in parallel if possible.</li>
* <li>The potentially parallel recipe is then checked to exist.</li>
* <li>If it exists, it checks if the recipe is runnable with the current inputs.</li>
* </ol>
* If the above conditions are met, the recipe is engaged to be run
*
* @param recipe the recipe to prepare
* @return true if the recipe was successfully prepared from the default inventory, else false
*/
protected boolean prepareRecipe(Recipe recipe) {
return prepareRecipe(recipe, getInputInventory(), getInputTank());
}

/**
* DO NOT use the parallelLimit field directly, EVER
*
Expand Down Expand Up @@ -549,11 +566,14 @@ protected static boolean areItemStacksEqual(@NotNull ItemStack stackA, @NotNull
* @param recipe - The Recipe that will be consumed from the inputs and ran in the machine
* @param importInventory - The inventory that the recipe should be consumed from.
* Used mainly for Distinct bus implementation for multiblocks to specify
* a specific bus
* a specific bus, or for addons to use external inventories.
* @param importFluids - The tanks that the recipe should be consumed from
* Used currently in addons to use external tanks.
* @return - true if the recipe is successful, false if the recipe is not successful
*/
protected boolean setupAndConsumeRecipeInputs(@NotNull Recipe recipe,
@NotNull IItemHandlerModifiable importInventory) {
@NotNull IItemHandlerModifiable importInventory,
@NotNull IMultipleTankHandler importFluids) {
this.overclockResults = calculateOverclock(recipe);

modifyOverclockPost(overclockResults, recipe.getRecipePropertyStorage());
Expand All @@ -563,7 +583,6 @@ protected boolean setupAndConsumeRecipeInputs(@NotNull Recipe recipe,
}

IItemHandlerModifiable exportInventory = getOutputInventory();
IMultipleTankHandler importFluids = getInputTank();
IMultipleTankHandler exportFluids = getOutputTank();

// We have already trimmed outputs and chanced outputs at this time
Expand All @@ -589,6 +608,25 @@ protected boolean setupAndConsumeRecipeInputs(@NotNull Recipe recipe,
return false;
}

/**
* Determines if the provided recipe is possible to run from the provided inventory, or if there is anything
* preventing
* the Recipe from being completed.
* <p>
* Will consume the inputs of the Recipe if it is possible to run.
*
* @param recipe - The Recipe that will be consumed from the inputs and ran in the machine
* @param importInventory - The inventory that the recipe should be consumed from.
* Used mainly for Distinct bus implementation for multiblocks to specify
* a specific bus
* @return - true if the recipe is successful, false if the recipe is not successful
*/
protected boolean setupAndConsumeRecipeInputs(@NotNull Recipe recipe,
@NotNull IItemHandlerModifiable importInventory) {
return setupAndConsumeRecipeInputs(recipe, importInventory, this.getInputTank());
}


/**
* @param resultOverclock the overclock data to use. Format: {@code [EUt, duration]}.
* @return true if there is enough energy to continue recipe progress
Expand Down
Loading