Skip to content

Commit

Permalink
Fix recipes with secondary usage per tick not working properly if the…
Browse files Browse the repository at this point in the history
… exact amount needed is supplied. #5596
  • Loading branch information
pupnewfster committed Feb 14, 2020
1 parent c807290 commit 038ce08
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/api/java/mekanism/api/recipes/cache/CachedRecipe.java
Expand Up @@ -106,12 +106,16 @@ public void process() {
int operations = canHolderFunction() ? postProcessOperations.applyAsInt(getOperationsThisTick(Integer.MAX_VALUE)) : 0;
if (operations > 0) {
setActive.accept(true);
useResources(operations);
//Always use energy, as that is a constant thing we can check
useEnergy(operations);
operatingTicks++;
if (operatingTicks >= getTicksRequired()) {
operatingTicks = 0;
finishProcessing(operations);
onFinish.run();
} else {
//If we still have ticks left required to operate, use the contents
useResources(operations);
}
//TODO: Do we want to make it so if required ticks is 1, that this isn't fired as it will be ++ -> 1 then set to zero again
operatingTicksChanged.accept(operatingTicks);
Expand Down Expand Up @@ -143,8 +147,10 @@ private int getTicksRequired() {
return requiredTicks.getAsInt();
}

//TODO: JavaDoc to mention that super should be called to ensure that the per tick energy is used
protected void useResources(int operations) {
}

protected void useEnergy(int operations) {
useEnergy.accept(operations * getEnergyPerTick());
}

Expand Down
Expand Up @@ -108,8 +108,7 @@ protected void finishProcessing(int operations) {
return;
}
itemInputHandler.use(recipeItem, operations);
//Note: We already extracted our gas so don't need to do so again here
//gasInputHandler.use(recipeGas, operations);
gasInputHandler.use(recipeGas, operations);
outputHandler.handleOutput(recipe.getOutput(recipeItem, recipeGas), operations);
}
}
Expand Up @@ -108,8 +108,7 @@ protected void finishProcessing(int operations) {
return;
}
itemInputHandler.use(recipeItem, operations);
//Note: We already extracted our gas so don't need to do so again here
//gasInputHandler.use(recipeGas, operations);
gasInputHandler.use(recipeGas, operations);
outputHandler.handleOutput(recipe.getOutput(recipeItem, recipeGas), operations);
}
}

0 comments on commit 038ce08

Please sign in to comment.