Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f6fcb25
Remove tiered chance boosting
DilithiumThoride Jun 17, 2026
62aab2b
missed one
DilithiumThoride Jun 17, 2026
ca59b8d
*now* it errors out
DilithiumThoride Jun 17, 2026
a0c769e
OUT OF DOLLS, ELF?
DilithiumThoride Jun 18, 2026
6407448
Remove tiered chance boosting
DilithiumThoride Jun 17, 2026
f52d2c8
missed one
DilithiumThoride Jun 17, 2026
c7947e0
*now* it errors out
DilithiumThoride Jun 17, 2026
6362dd5
OUT OF DOLLS, ELF?
DilithiumThoride Jun 18, 2026
ef708aa
Merge remote-tracking branch 'origin/dt/there-are-no-chance-boosters-…
DilithiumThoride Jun 21, 2026
f3d2568
MUI2 Merge Conflict Resolver
DilithiumThoride Jun 21, 2026
bc36ec1
spotl4ss
DilithiumThoride Jun 21, 2026
2b228e7
don't need to do that calc
DilithiumThoride Jun 21, 2026
f738c84
Merge branch '1.20.1' into dt/there-are-no-chance-boosters-in-ba-sing-se
DilithiumThoride Jun 21, 2026
096fac7
Merge branch '1.20.1' into dt/there-are-no-chance-boosters-in-ba-sing-se
DilithiumThoride Jun 22, 2026
70c6bfe
preset for range prerolls (stolen from chance prerolls)
DilithiumThoride Oct 7, 2025
e96d066
Merge remote-tracking branch 'origin/dt/there-are-no-chance-boosters-…
DilithiumThoride Jun 28, 2026
39aa123
Merge branch '1.20.1' into dt/there-are-no-chance-boosters-in-ba-sing-se
DilithiumThoride Jun 28, 2026
f548a63
Merge branch 'dt/there-are-no-chance-boosters-in-ba-sing-se' into dt/…
DilithiumThoride Jun 28, 2026
f39763f
Do Ranged Prerolls
DilithiumThoride Jun 28, 2026
9789752
Convert IPFI to use getAmount()
DilithiumThoride Jun 28, 2026
646a623
change external references to lastDisplayedRecipe
DilithiumThoride Jun 28, 2026
1ac7acb
changed
DilithiumThoride Jun 30, 2026
1a387ab
spotless
DilithiumThoride Jun 30, 2026
db5f537
add .getAmount() to IRangedIngredient
DilithiumThoride Jun 30, 2026
a4de2e3
singleblock test for prerolls
DilithiumThoride Jun 30, 2026
68530bb
multiblock test for prerolls
DilithiumThoride Jun 30, 2026
5e88272
spotless
DilithiumThoride Jun 30, 2026
e7dc6b9
Merge branch '1.20.1' into dt/ranged-prerolls
DilithiumThoride Jun 30, 2026
514c691
Make IPI.amount consistent with IPFI.amount. Parity of the IRangedIng…
DilithiumThoride Jul 1, 2026
0d05e5e
remove some unneeded checks
DilithiumThoride Jul 1, 2026
367417e
spotless
DilithiumThoride Jul 1, 2026
ada772f
anti-null
DilithiumThoride Jul 1, 2026
25727ff
review comments (1/2)
DilithiumThoride Jul 1, 2026
f2b036e
review comments (2/2)
DilithiumThoride Jul 1, 2026
930cafa
okay i just don't like seeing var there
DilithiumThoride Jul 1, 2026
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 @@ -179,9 +179,7 @@ public int getMaxParallelByInput(IRecipeCapabilityHolder holder, GTRecipe recipe
for (Content content : inputs) {
FluidIngredient ing = of(content.content());

int amount;
if (ing instanceof IRangedIngredient provider) amount = provider.getMaxRoll();
else amount = ing.getAmount();
int amount = ing.getAmount();

if (content.chance() == 0) {
nonConsumables.addTo(ing, amount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ public List<Object> compressIngredients(@Unmodifiable Collection<Object> ingredi
} else if (ingredient instanceof SizedIngredient sized &&
sized.getInner() instanceof IntCircuitIngredient) {
list.add(0, ingredient);
} else if (ingredient instanceof IntProviderIngredient intProvider &&
intProvider.getInner() instanceof IntCircuitIngredient) {
list.add(0, ingredient);
} else {
list.add(ingredient);
}
Expand Down Expand Up @@ -152,7 +149,7 @@ public int limitMaxParallelByOutput(IRecipeCapabilityHolder holder, GTRecipe rec

int count;
if (ing instanceof SizedIngredient sized) count = sized.getAmount();
else if (ing instanceof IntProviderIngredient provider) count = provider.getCountProvider().getMaxValue();
else if (ing instanceof IntProviderIngredient provider) count = provider.getMaxRoll();
else count = 1;

maxCount = Math.max(maxCount, count);
Expand Down Expand Up @@ -204,7 +201,7 @@ public int getMaxParallelByInput(IRecipeCapabilityHolder holder, GTRecipe recipe

int count;
if (ing instanceof SizedIngredient sized) count = sized.getAmount();
else if (ing instanceof IntProviderIngredient provider) count = provider.getCountProvider().getMaxValue();
else if (ing instanceof IntProviderIngredient provider) count = provider.getMaxRoll();
else count = 1;

if (content.chance() == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,8 @@ public void onContentsChanged() {

FluidStack[] fluids;

if (ingredient instanceof IntProviderFluidIngredient provider) {
provider.setFluidStacks(null);
provider.setSampledCount(-1);

if (simulate) {
fluids = new FluidStack[] { provider.getMaxSizeStack() };
} else {
fluids = provider.getStacks();
}
if (ingredient instanceof IntProviderFluidIngredient provider && simulate) {
fluids = new FluidStack[] { provider.getMaxSizeStack() };
} else {
fluids = ingredient.getStacks();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ public static List<Ingredient> handleRecipe(IO io, GTRecipe recipe, List<Ingredi
ItemStack[] items;
int amount;
if (ingredient instanceof IntProviderIngredient provider) {
provider.setItemStacks(null);
provider.setSampledCount(-1);

ItemStack output;
if (simulate) {
output = provider.getMaxSizeStack();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected List<Class<?>> validMachineClasses() {
public long getInputAmperage() {
var recipeLogic = getMachine().getTrait(RecipeLogic.TYPE);
if (recipeLogic == null) return 0;
var lastRecipe = recipeLogic.getLastRecipe();
var lastRecipe = recipeLogic.getLastDisplayedRecipe();
long amperage;
if (lastRecipe != null) {
amperage = lastRecipe.getInputEUt().amperage();
Expand All @@ -49,7 +49,7 @@ public long getInputAmperage() {
public long getOutputAmperage() {
var recipeLogic = getMachine().getTrait(RecipeLogic.TYPE);
if (recipeLogic == null) return 0;
var lastRecipe = recipeLogic.getLastRecipe();
var lastRecipe = recipeLogic.getLastDisplayedRecipe();
if (lastRecipe != null) {
return lastRecipe.getOutputEUt().amperage();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,12 @@ public enum Status implements StringRepresentable {
@Nullable
@Getter
@SaveField
@SyncToClient
protected GTRecipe lastRecipe;
@Nullable
@Getter
@SaveField
@SyncToClient
protected GTRecipe lastDisplayedRecipe;
@Getter
@SaveField
@SyncToClient
Expand Down Expand Up @@ -165,6 +169,7 @@ protected void onStatusSynced() {
public void resetRecipeLogic() {
recipeDirty = false;
lastRecipe = null;
lastDisplayedRecipe = null;
lastOriginRecipe = null;
consecutiveRecipes = 0;
progress = 0;
Expand Down Expand Up @@ -354,16 +359,18 @@ public void findAndHandleRecipe() {
if (!recipeDirty && lastRecipe != null && checkRecipe(lastRecipe).isSuccess()) {
GTRecipe recipe = lastRecipe;
lastRecipe = null;
lastDisplayedRecipe = null;
lastOriginRecipe = null;
setupRecipe(recipe);
} else {
// try to find and handle a new recipe
failureReasonMap.clear();
lastRecipe = null;
lastDisplayedRecipe = null;
lastOriginRecipe = null;
handleSearchingRecipes(searchRecipe());
}
syncDataHolder.markClientSyncFieldDirty("lastRecipe");
syncDataHolder.markClientSyncFieldDirty("lastDisplayedRecipe");
recipeDirty = false;
}

Expand Down Expand Up @@ -393,6 +400,8 @@ public ActionResult handleTickRecipe(GTRecipe recipe) {
var result = RecipeHelper.matchTickRecipe(getRLMachine(), recipe);
if (!result.isSuccess()) return result;

recipe.doTickPrerolls(this.chanceCaches);

result = handleTickRecipeIO(recipe, IO.IN);
if (!result.isSuccess()) return result;

Expand All @@ -410,6 +419,12 @@ public void setupRecipe(GTRecipe recipe) {
syncDataHolder.resyncAllFields();
return;
}
if (lastRecipe != null && !recipe.equals(lastRecipe)) {
chanceCaches.clear();
}
lastDisplayedRecipe = recipe.copy();
syncDataHolder.markClientSyncFieldDirty("lastDisplayedRecipe");
recipe.doPrerolls(this.chanceCaches);
var handledIO = handleRecipeIO(recipe, IO.IN);
if (handledIO.isSuccess()) {
if (lastRecipe != null && !recipe.equals(lastRecipe)) {
Expand All @@ -423,6 +438,8 @@ public void setupRecipe(GTRecipe recipe) {
duration = recipe.duration;
isActive = true;
syncDataHolder.resyncAllFields();
} else {
lastDisplayedRecipe = null;
}
}

Expand Down Expand Up @@ -541,6 +558,7 @@ public void onRecipeFinish() {
isActive = false;
// Force a recipe recheck.
lastRecipe = null;
lastDisplayedRecipe = null;
syncDataHolder.resyncAllFields();
return;
}
Expand All @@ -551,7 +569,6 @@ public void onRecipeFinish() {
markLastRecipeDirty();
} else {
lastRecipe = modified;
syncDataHolder.markClientSyncFieldDirty("lastRecipe");
}
} else {
markLastRecipeDirty();
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.gregtechceu.gtceu.api.recipe.content.Content;
import com.gregtechceu.gtceu.api.recipe.content.ContentModifier;
import com.gregtechceu.gtceu.api.recipe.ingredient.EnergyStack;
import com.gregtechceu.gtceu.api.recipe.ingredient.IRangedIngredient;

import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.RegistryAccess;
Expand All @@ -16,12 +17,14 @@
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.level.Level;

import it.unimi.dsi.fastutil.objects.Object2IntMap;
import lombok.Getter;
import lombok.Setter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.*;
import java.util.stream.Stream;

import javax.annotation.ParametersAreNonnullByDefault;

Expand Down Expand Up @@ -231,6 +234,36 @@ public ChanceLogic getChanceLogicForCapability(RecipeCapability<?> cap, IO io, b
return new EnergyStack(v, a);
}

public void doPrerolls(IdentityHashMap<RecipeCapability<?>, Object2IntMap<?>> chanceCaches) {
var rangedContents = getFullContents();
for (Content item : rangedContents) {
if (item.content() instanceof IRangedIngredient ranged)
ranged.rollSampledCount();
}
}

public void doTickPrerolls(IdentityHashMap<RecipeCapability<?>, Object2IntMap<?>> chanceCaches) {
var rangedContents = getFullTickContents();
for (Content item : rangedContents) {
if (item.content() instanceof IRangedIngredient ranged)
ranged.rollSampledCount();
}
Comment thread
DilithiumThoride marked this conversation as resolved.
}

public List<Content> getFullContents() {
return Stream
.concat(inputs.values().stream(), outputs.values().stream())
.flatMap(List::stream)
.toList();
}

public List<Content> getFullTickContents() {
return Stream
.concat(tickInputs.values().stream(), tickOutputs.values().stream())
.flatMap(List::stream)
.toList();
}

public int getTotalRuns() {
return parallels * subtickParallels * batchParallels;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.gregtechceu.gtceu.api.recipe.content.Content;
import com.gregtechceu.gtceu.api.recipe.ingredient.EnergyStack;
import com.gregtechceu.gtceu.api.recipe.ingredient.FluidIngredient;
import com.gregtechceu.gtceu.api.recipe.ingredient.IRangedIngredient;
import com.gregtechceu.gtceu.config.ConfigHolder;
import com.gregtechceu.gtceu.data.recipe.builder.GTRecipeBuilder;
import com.gregtechceu.gtceu.utils.GTUtil;
Expand Down Expand Up @@ -401,7 +400,6 @@ public static int getRatioForDistillery(FluidIngredient fluidInput, FluidIngredi
}

public static boolean isFluidStackDivisibleForDistillery(FluidIngredient fluidStack, int divisor) {
int amount = (fluidStack instanceof IRangedIngredient ranged ? ranged.getMaxRoll() : fluidStack.getAmount());
return amount % divisor == 0 && amount / divisor >= 25;
return fluidStack.getAmount() % divisor == 0 && fluidStack.getAmount() / divisor >= 25;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public double apply(double number) {
* @return A new Content map that is the modified version of the argument
*/
public Map<RecipeCapability<?>, List<Content>> applyContents(Map<RecipeCapability<?>, List<Content>> contents) {
Comment thread
DilithiumThoride marked this conversation as resolved.
if (this == IDENTITY) return new HashMap<>(contents);
// Prerolls require copying, even on IDENTITY
Map<RecipeCapability<?>, List<Content>> copyContents = new HashMap<>();
for (var entry : contents.entrySet()) {
var contentList = entry.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class FluidIngredient implements Predicate<FluidStack> {
@Nullable
public FluidStack[] stacks;
@Getter
protected int amount;
private int amount;
@Getter
protected CompoundTag nbt;
protected boolean changed = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ default int rollSampledCount() {

int rollSampledCount(@NotNull RandomSource random);

int getAmount();

/**
* @return the average roll of this ranged amount
*/
Expand Down
Loading
Loading