|
2 | 2 |
|
3 | 3 | import gregtech.api.capability.IMultipleTankHandler; |
4 | 4 | import gregtech.api.recipes.category.GTRecipeCategory; |
5 | | -import gregtech.api.recipes.chance.boost.ChanceBoostFunction; |
6 | 5 | import gregtech.api.recipes.chance.output.ChancedOutputList; |
7 | 6 | import gregtech.api.recipes.chance.output.ChancedOutputLogic; |
8 | 7 | import gregtech.api.recipes.chance.output.impl.ChancedFluidOutput; |
|
18 | 17 | import net.minecraft.item.ItemStack; |
19 | 18 | import net.minecraftforge.fluids.FluidStack; |
20 | 19 | import net.minecraftforge.items.IItemHandlerModifiable; |
21 | | -import net.minecraftforge.items.ItemHandlerHelper; |
22 | 20 | import net.minecraftforge.oredict.OreDictionary; |
23 | 21 |
|
24 | 22 | import com.google.common.collect.ImmutableList; |
@@ -464,49 +462,41 @@ public List<ItemStack> getOutputs() { |
464 | 462 | * The Recipe should be trimmed by calling {@link Recipe#getItemAndChanceOutputs(int)} before calling this method, |
465 | 463 | * if trimming is required. |
466 | 464 | * |
467 | | - * @param recipeTier The Voltage Tier of the Recipe, used for chanced output calculation |
468 | | - * @param machineTier The Voltage Tier of the Machine, used for chanced output calculation |
469 | | - * @param recipeMap The RecipeMap that the recipe is being performed upon, used for chanced output calculation |
| 465 | + * @param context Context containing machine and recipe tier, the boost function, and the chance cache |
470 | 466 | * @return A list of all resulting ItemStacks from the recipe, after chance has been applied to any chanced outputs |
471 | 467 | */ |
472 | | - public List<ItemStack> getResultItemOutputs(int recipeTier, int machineTier, RecipeMap<?> recipeMap, |
473 | | - Map<ItemStack, Integer> cache) { |
| 468 | + public List<ItemStack> getResultItemOutputs(RecipeContext<ItemStack> context) { |
474 | 469 | List<ItemStack> outputs = new ArrayList<>(getOutputs()); |
475 | | - ChanceBoostFunction function = recipeMap.getChanceFunction(); |
476 | | - List<ChancedItemOutput> chancedOutputsList = getChancedOutputs().roll(function, recipeTier, machineTier, cache); |
| 470 | + var chancedOutputsList = getChancedOutputs().roll(context); |
477 | 471 |
|
478 | 472 | if (chancedOutputsList == null) return outputs; |
479 | 473 |
|
480 | 474 | Collection<ItemStack> resultChanced = new ArrayList<>(); |
481 | | - for (ChancedItemOutput chancedOutput : chancedOutputsList) { |
482 | | - ItemStack stackToAdd = chancedOutput.getIngredient().copy(); |
483 | | - for (ItemStack stackInList : resultChanced) { |
484 | | - int insertable = stackInList.getMaxStackSize() - stackInList.getCount(); |
485 | | - if (insertable > 0 && ItemHandlerHelper.canItemStacksStack(stackInList, stackToAdd)) { |
486 | | - if (insertable >= stackToAdd.getCount()) { |
487 | | - stackInList.grow(stackToAdd.getCount()); |
488 | | - stackToAdd = ItemStack.EMPTY; |
489 | | - break; |
490 | | - } else { |
491 | | - stackInList.grow(insertable); |
492 | | - stackToAdd.shrink(insertable); |
493 | | - } |
494 | | - } |
495 | | - } |
496 | | - if (!stackToAdd.isEmpty()) { |
497 | | - resultChanced.add(stackToAdd); |
498 | | - } |
| 475 | + for (var chancedOutput : chancedOutputsList) { |
| 476 | + ItemStack stackToAdd = chancedOutput.createStack((output, count) -> GTUtility.copy(count, output)); |
| 477 | + // for (ItemStack stackInList : resultChanced) { |
| 478 | + // int insertable = stackInList.getMaxStackSize() - stackInList.getCount(); |
| 479 | + // if (insertable > 0 && ItemHandlerHelper.canItemStacksStack(stackInList, stackToAdd)) { |
| 480 | + // if (insertable >= stackToAdd.getCount()) { |
| 481 | + // stackInList.grow(stackToAdd.getCount()); |
| 482 | + // stackToAdd = ItemStack.EMPTY; |
| 483 | + // break; |
| 484 | + // } else { |
| 485 | + // stackInList.grow(insertable); |
| 486 | + // stackToAdd.shrink(insertable); |
| 487 | + // } |
| 488 | + // } |
| 489 | + // } |
| 490 | + // if (!stackToAdd.isEmpty()) { |
| 491 | + // } |
| 492 | + resultChanced.add(stackToAdd); |
499 | 493 | } |
500 | 494 |
|
501 | 495 | outputs.addAll(resultChanced); |
502 | 496 |
|
503 | 497 | return outputs; |
504 | 498 | } |
505 | 499 |
|
506 | | - public List<ItemStack> getResultItemOutputs(int recipeTier, int machineTier, RecipeMap<?> recipeMap) { |
507 | | - return getResultItemOutputs(recipeTier, machineTier, recipeMap, null); |
508 | | - } |
509 | | - |
510 | 500 | /** |
511 | 501 | * Returns the maximum possible recipe outputs from a recipe, divided into regular and chanced outputs |
512 | 502 | * Takes into account any specific output limiters, ie macerator slots, to trim down the output list |
@@ -664,24 +654,19 @@ public List<FluidStack> getAllFluidOutputs() { |
664 | 654 | * The Recipe should be trimmed by calling {@link Recipe#getFluidAndChanceOutputs(int)} before calling this method, |
665 | 655 | * if trimming is required. |
666 | 656 | * |
667 | | - * @param recipeTier The Voltage Tier of the Recipe, used for chanced output calculation |
668 | | - * @param machineTier The Voltage Tier of the Machine, used for chanced output calculation |
669 | | - * @param recipeMap The RecipeMap that the recipe is being performed upon, used for chanced output calculation |
| 657 | + * @param context Context containing machine and recipe tier, the boost function, and the chance cache |
670 | 658 | * @return A list of all resulting ItemStacks from the recipe, after chance has been applied to any chanced outputs |
671 | 659 | */ |
672 | | - public List<FluidStack> getResultFluidOutputs(int recipeTier, int machineTier, RecipeMap<?> recipeMap, |
673 | | - Map<FluidStack, Integer> cache) { |
| 660 | + public List<FluidStack> getResultFluidOutputs(RecipeContext<FluidStack> context) { |
674 | 661 | List<FluidStack> outputs = new ArrayList<>(GTUtility.copyFluidList(getFluidOutputs())); |
675 | 662 |
|
676 | | - ChanceBoostFunction function = recipeMap.getChanceFunction(); |
677 | | - List<ChancedFluidOutput> chancedOutputsList = getChancedFluidOutputs().roll(function, recipeTier, machineTier, |
678 | | - cache); |
| 663 | + var chancedOutputsList = getChancedFluidOutputs().roll(context); |
679 | 664 |
|
680 | 665 | if (chancedOutputsList == null) return outputs; |
681 | 666 |
|
682 | 667 | Collection<FluidStack> resultChanced = new ArrayList<>(); |
683 | | - for (ChancedFluidOutput chancedOutput : chancedOutputsList) { |
684 | | - FluidStack stackToAdd = chancedOutput.getIngredient().copy(); |
| 668 | + for (var chancedOutput : chancedOutputsList) { |
| 669 | + FluidStack stackToAdd = chancedOutput.createStack(FluidStack::new); |
685 | 670 | for (FluidStack stackInList : resultChanced) { |
686 | 671 | int insertable = stackInList.amount; |
687 | 672 | if (insertable > 0 && stackInList.getFluid() == stackToAdd.getFluid()) { |
|
0 commit comments