Skip to content

Commit

Permalink
Fix spilling effects improperly handling partial stacks at higher levels
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightMiner committed Dec 20, 2023
1 parent cf8828d commit bc582b5
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public boolean hasEffects() {
return !effects.isEmpty();
}

/** Gets the amount of fluid needed for a single level */
public int getAmount(FluidStack fluid) {
return ingredient.getAmount(fluid.getFluid());
}

/**
* Applies any effects for the given recipe
* @param fluid Fluid used to perform the recipe, safe to modify
Expand All @@ -38,11 +43,11 @@ public boolean hasEffects() {
* @return Fluid stack after applying this recipe
*/
public FluidStack applyEffects(FluidStack fluid, int level, ToolAttackContext context) {
int needed = ingredient.getAmount(fluid.getFluid());
int maxFluid = level * needed;
int amountPerLevel = getAmount(fluid);
int maxFluid = amountPerLevel * level;
float scale = level;
if (fluid.getAmount() < maxFluid) {
scale = fluid.getAmount() / (float)maxFluid;
scale = fluid.getAmount() / (float)amountPerLevel;
}
for (ISpillingEffect effect : effects) {
effect.applyEffects(fluid, scale, context);
Expand Down

0 comments on commit bc582b5

Please sign in to comment.