Skip to content

Commit

Permalink
Fix Parallelization of Recipes with Uncached Inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit committed Aug 20, 2024
1 parent 9bf4a80 commit 1c35289
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import com.cleanroommc.groovyscript.api.GroovyLog;
import com.cleanroommc.groovyscript.api.IIngredient;
Expand All @@ -32,6 +34,9 @@
import gregtech.api.recipes.ingredients.nbtmatch.NBTMatcher;
import gregtech.api.util.EnumValidationResult;

/**
* Adds some util functions to Recipe Builders. Also fixes an issue with parallelizing recipes with non-cached inputs.
*/
@SuppressWarnings({ "unchecked", "DataFlowIssue" })
@Mixin(value = RecipeBuilder.class, remap = false)
public abstract class RecipeBuilderMixin<R extends RecipeBuilder<R>> {
Expand Down Expand Up @@ -76,6 +81,20 @@ private static GTRecipeInput ofGroovyIngredient(IIngredient ingredient) {
@Shadow
protected GTRecipeCategory category;

@Redirect(method = "lambda$multiplyInputsAndOutputs$1",
at = @At(value = "INVOKE",
target = "Lgregtech/api/recipes/ingredients/GTRecipeInput;withAmount(I)Lgregtech/api/recipes/ingredients/GTRecipeInput;"))
private static GTRecipeInput fixCopyingInputs(GTRecipeInput instance, int amount) {
return instance.copyWithAmount(amount);
}

@Redirect(method = "lambda$multiplyInputsAndOutputs$2",
at = @At(value = "INVOKE",
target = "Lgregtech/api/recipes/ingredients/GTRecipeInput;withAmount(I)Lgregtech/api/recipes/ingredients/GTRecipeInput;"))
private static GTRecipeInput fixCopyingFluidInputs(GTRecipeInput instance, int amount) {
return instance.copyWithAmount(amount);
}

@Unique
@SuppressWarnings("unused")
public R changeRecycling() {
Expand Down

0 comments on commit 1c35289

Please sign in to comment.