Skip to content

Commit

Permalink
fix issues with chance passing
Browse files Browse the repository at this point in the history
  • Loading branch information
ghzdude committed Nov 16, 2024
1 parent 2cb3f2a commit cfb212f
Showing 1 changed file with 4 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,12 @@ default <I, T extends ChancedOutput<I>> boolean passesChance(int chance, T entry
@NotNull RecipeContext<I> context) {
if (context.getCachedChance(entry) == -1) {
int initial = GTValues.RNG.nextInt(entry.getMaxChance());
context.updateCachedChance(entry, chance);
return initial <= entry.getChance();
}

boolean roll = false;
int fullChance = context.getChance(entry);
if (fullChance >= entry.getMaxChance()) {
roll = true;
context.updateCachedChance(entry, initial);
return initial <= chance;
}

context.updateCachedChance(entry, fullChance);
return roll;
context.updateCachedChance(entry, chance);
return chance >= entry.getMaxChance();
}

/**
Expand All @@ -185,39 +179,6 @@ static int getMaxChancedValue() {
return 10_000;
}

// /**
// * Roll the chance and attempt to produce the output
// *
// * @param chancedEntries the list of entries to roll
// * @param boostFunction the function to boost the entries' chances
// * @param baseTier the base tier of the recipe
// * @param machineTier the tier the recipe is run at
// * @param cache the cache of previously rolled chances, can be null
// * @return a list of the produced outputs, or null if failed
// */
// <I, T extends ChancedOutput<I>> @Nullable @Unmodifiable List<@NotNull T> roll(
// @NotNull @Unmodifiable List<@NotNull T> chancedEntries,
// @NotNull ChanceBoostFunction boostFunction,
// int baseTier, int machineTier,
// @Nullable Map<I, Integer> cache);

// /**
// * Roll the chance and attempt to produce the output
// *
// * @param chancedEntries the list of entries to roll
// * @param boostFunction the function to boost the entries' chances
// * @param baseTier the base tier of the recipe
// * @param machineTier the tier the recipe is run at
// * @return a list of the produced outputs
// */
// default <I, T extends ChancedOutput<I>> @Nullable @Unmodifiable List<@NotNull T> roll(
// @NotNull @Unmodifiable List<@NotNull T> chancedEntries,
// @NotNull ChanceBoostFunction boostFunction,
// int baseTier,
// int machineTier) {
// return roll(chancedEntries, boostFunction, baseTier, machineTier, null);
// }

<I, T extends ChancedOutput<I>> @Nullable @Unmodifiable List<@NotNull CalculatedOutput<I>> roll(
@NotNull @Unmodifiable List<@NotNull T> chancedEntries,
@NotNull RecipeContext<I> context);
Expand Down

0 comments on commit cfb212f

Please sign in to comment.