fix pressing recipe inconsistency (closes #1296)

This commit is contained in:
zelophed 2021-03-25 03:58:24 +01:00
parent b18993ed26
commit 8c79174904
2 changed files with 37 additions and 29 deletions

View file

@ -1,18 +1,16 @@
package com.simibubi.create.content.contraptions.components.press;
import static com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour.ProcessingResult.HOLD;
import static com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour.ProcessingResult.PASS;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import com.simibubi.create.content.contraptions.components.press.MechanicalPressTileEntity.Mode;
import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack;
import com.simibubi.create.foundation.item.ItemHelper;
import com.simibubi.create.content.logistics.InWorldProcessing;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour.ProcessingResult;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour;
import net.minecraft.item.ItemStack;
import static com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour.ProcessingResult.HOLD;
import static com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour.ProcessingResult.PASS;
public class BeltPressingCallbacks {
@ -45,13 +43,25 @@ public class BeltPressingCallbacks {
if (!recipe.isPresent())
return PASS;
ItemStack out = recipe.get()
List<TransportedItemStack> collect = InWorldProcessing.applyRecipeOn(transported.stack, recipe.get())
.stream()
.map(stack -> {
TransportedItemStack copy = transported.copy();
copy.stack = stack;
return copy;
}).collect(Collectors.toList());
if (collect.isEmpty())
handler.handleProcessingOnItem(transported, TransportedItemStackHandlerBehaviour.TransportedResult.removeItem());
else
handler.handleProcessingOnItem(transported, TransportedItemStackHandlerBehaviour.TransportedResult.convertTo(collect));
/*ItemStack out = recipe.get()
.getRecipeOutput()
.copy();
List<ItemStack> multipliedOutput = ItemHelper.multipliedOutput(transported.stack, out);
if (multipliedOutput.isEmpty())
transported.stack = ItemStack.EMPTY;
transported.stack = multipliedOutput.get(0);
transported.stack = multipliedOutput.get(0);*/
pressTe.sendData();
return HOLD;
}

View file

@ -1,25 +1,5 @@
package com.simibubi.create.content.logistics;
import static com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.getHeatLevelOf;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllRecipeTypes;
import com.simibubi.create.content.contraptions.components.fan.SplashingRecipe;
import com.simibubi.create.content.contraptions.processing.ProcessingRecipe;
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock;
import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.item.ItemHelper;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult;
import com.simibubi.create.foundation.utility.ColorHelper;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -47,6 +27,24 @@ import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.items.ItemStackHandler;
import net.minecraftforge.items.wrapper.RecipeWrapper;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllRecipeTypes;
import com.simibubi.create.content.contraptions.components.fan.SplashingRecipe;
import com.simibubi.create.content.contraptions.processing.ProcessingRecipe;
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock;
import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.item.ItemHelper;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult;
import com.simibubi.create.foundation.utility.ColorHelper;
import static com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.getHeatLevelOf;
public class InWorldProcessing {
public static class SplashingInv extends RecipeWrapper {
@ -265,7 +263,7 @@ public class InWorldProcessing {
}
}
private static List<ItemStack> applyRecipeOn(ItemStack stackIn, IRecipe<?> recipe) {
public static List<ItemStack> applyRecipeOn(ItemStack stackIn, IRecipe<?> recipe) {
List<ItemStack> stacks;
if (recipe instanceof ProcessingRecipe) {