Skip to content

Preroll Ranged Ingredients on Recipe Start (1.20.1)#5015

Open
DilithiumThoride wants to merge 35 commits into
1.20.1from
dt/ranged-prerolls
Open

Preroll Ranged Ingredients on Recipe Start (1.20.1)#5015
DilithiumThoride wants to merge 35 commits into
1.20.1from
dt/ranged-prerolls

Conversation

@DilithiumThoride

@DilithiumThoride DilithiumThoride commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

What

Ranged Ingredients have their values rolled at the time when the ingredients are consumed/produced. This works but it results in some messy code flows around the "amount" a ranged ingredient is holding, which in the past has lead to bugs and undefined behavior. #4992 added checks for this behavior. This PR largely reverts #4992 in favor of overhauling the ranged ingredient logic to make those checks unnecessary.

Implementation Details

1: This is the first PR out of three related to ingredient prerolls. The second PR will be a copy of this but ported to the 1.21 branch (#5048). The third PR will do ingredient prerolls on Chanced Ingredients as well; however that third PR is blocked by #4320 which is why I'm splitting it up to do this part first.

2: An additional field is added to RecipeLogic, lastDisplayedRecipe. This field represent a copy of a recipe the moment before it is executed, after batch/parallel modifications have been applied but before ingredients are pre-rolled. Among other things that means this is the version of the recipe that should be displayed by Jade and multiblock UIs, because after prerolls ingredients may or may not be zeroed out.

3: IRangedIngredient.getAmount() is now a method. IRangedIngredients should now as a whole act as holders similar to SizedIngredients, but in which the amount and the sampledCount roll value are actually independent such that RecipeLogic can still set amounts on them for splitting output stacks between busses.

AI Usage

  • [ X ] No AI driven tools were used for this pull request.

Outcome

No change to user experience in 1.20.

However, this sets the stage to remove an incongruity between the 1.20 and 1.21 branches, work towards fixing several bugs with Ranged Fluids in 1.21; and it is an incremental step required for the distant future #4321

How Was This Tested

Four additional automated tests have been added to validate the prerolling behavior.

Additional Information

Temporarily flagged [DO NOT MERGE] as #5015 and #5048 should be merged at the same time.

Potential Compatibility Issues

Probably breaks mixins that modify recipelogic, and may interfere with addon mods that have recipelogic that does not call the standard setupRecipe()

…in-ba-sing-se' into dt/there-are-no-chance-boosters-in-ba-sing-se

# Conflicts:
#	src/main/java/com/gregtechceu/gtceu/api/capability/recipe/FluidRecipeCapability.java
#	src/main/java/com/gregtechceu/gtceu/api/capability/recipe/ItemRecipeCapability.java
#	src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/MultiblockDisplayText.java
#	src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeType.java
#	src/main/java/com/gregtechceu/gtceu/api/recipe/RecipeRunner.java
#	src/main/java/com/gregtechceu/gtceu/api/recipe/chance/logic/ChanceLogic.java
#	src/main/java/com/gregtechceu/gtceu/api/recipe/content/Content.java
#	src/main/java/com/gregtechceu/gtceu/api/recipe/content/IContentSerializer.java
#	src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java
#	src/main/java/com/gregtechceu/gtceu/integration/jade/provider/RecipeOutputProvider.java
#	src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/ContentJS.java
#	src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/GTOreByProduct.java
#	src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTOreByProductWidget.java
#	src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTRecipeWidget.java
…in-ba-sing-se' into dt/there-are-no-chance-boosters-in-ba-sing-se
…ranged-prerolls

# Conflicts:
#	src/main/java/com/gregtechceu/gtceu/api/recipe/RecipeRunner.java
@DilithiumThoride DilithiumThoride requested a review from a team as a code owner June 28, 2026 23:14
@DilithiumThoride DilithiumThoride added type: refactor Suggestion to refactor a section of code 1.20.1 Release: API - X.0.0 Major Breaking Refactors that MUST be in a API-Breaking Release labels Jun 28, 2026
@github-actions github-actions Bot added the Tests: Passed Game Tests have passed on this PR label Jun 28, 2026
@DilithiumThoride DilithiumThoride marked this pull request as draft July 1, 2026 00:19
@DilithiumThoride DilithiumThoride marked this pull request as ready for review July 1, 2026 04:00

@jurrejelle jurrejelle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Few (AI-assisted, disclosure) nits, but apart from that this looks good :D Way nicer to just do this at a static point and have a value present

Comment thread src/main/java/com/gregtechceu/gtceu/api/recipe/content/ContentModifier.java Outdated
Comment thread src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipe.java
@DilithiumThoride DilithiumThoride changed the title Preroll Ranged Ingredients on Recipe Start Preroll Ranged Ingredients on Recipe Start (1.20.1) Jul 1, 2026
@DilithiumThoride DilithiumThoride added the Do Not Merge DO NOT MERGE THIS PR YET! label Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.20.1 Do Not Merge DO NOT MERGE THIS PR YET! Release: API - X.0.0 Major Breaking Refactors that MUST be in a API-Breaking Release Tests: Passed Game Tests have passed on this PR type: refactor Suggestion to refactor a section of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants