Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use actual remaining items to calculate remainders for basin recipes #7076

Open
wants to merge 1 commit into
base: mc1.20.1/dev
Choose a base branch
from
Open
Changes from all commits
Commits
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 @@ -22,6 +22,8 @@
import com.simibubi.create.foundation.utility.Iterate;

import net.minecraft.client.Minecraft;
import net.minecraft.world.Container;
import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.CraftingRecipe;
import net.minecraft.world.item.crafting.Ingredient;
Expand All @@ -32,7 +34,7 @@
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.items.IItemHandler;

public class BasinRecipe extends ProcessingRecipe<SmartInventory> {
public class BasinRecipe extends ProcessingRecipe<Container> {

public static boolean match(BasinBlockEntity basin, Recipe<?> recipe) {
FilteringBehaviour filter = basin.getFilter();
Expand Down Expand Up @@ -148,23 +150,24 @@ private static boolean apply(BasinBlockEntity basin, Recipe<?> recipe, boolean t
}

if (simulate) {
CraftingContainer remainderContainer = new DummyCraftingContainer(availableItems, extractedItemsFromSlot);

if (recipe instanceof BasinRecipe basinRecipe) {
recipeOutputItems.addAll(basinRecipe.rollResults());

for (FluidStack fluidStack : basinRecipe.getFluidResults())
if (!fluidStack.isEmpty())
recipeOutputFluids.add(fluidStack);
for (ItemStack stack : basinRecipe.getRemainingItems(basin.getInputInventory()))
for (ItemStack stack : basinRecipe.getRemainingItems(remainderContainer))
if (!stack.isEmpty())
recipeOutputItems.add(stack);

} else {
recipeOutputItems.add(recipe.getResultItem(basin.getLevel()
.registryAccess()));

if (recipe instanceof CraftingRecipe craftingRecipe) {
for (ItemStack stack : craftingRecipe
.getRemainingItems(new DummyCraftingContainer(availableItems, extractedItemsFromSlot)))
for (ItemStack stack : craftingRecipe.getRemainingItems(remainderContainer))
if (!stack.isEmpty())
recipeOutputItems.add(stack);
}
Expand Down Expand Up @@ -225,7 +228,7 @@ protected boolean canSpecifyDuration() {
}

@Override
public boolean matches(SmartInventory inv, @Nonnull Level worldIn) {
public boolean matches(Container inv, @Nonnull Level worldIn) {
return false;
}

Expand Down