Don't merge stacks for AL recipes (#10)

* Don't merge stacks for AL recipes

* use WILDCARD_VALUE
This commit is contained in:
miozune authored and GitHub committed 2022-05-25 23:48:48 +02:00
1 parent 86ce155d07
commit 71bc78fa20
4 files changed
+19 -13

No files matched your search

@@ -19,6 +19,7 @@ import com.github.vfyjxf.nee.utils.ItemUtils;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.oredict.OreDictionary;
import java.util.*;
@@ -73,7 +74,7 @@ public class NEECraftingHandler implements IOverlayHandler {
List<PositionedStack> inputs = processor.getRecipeInput(recipe, recipeIndex, identifier);
List<PositionedStack> outputs = processor.getRecipeOutput(recipe, recipeIndex, identifier);
String recipeProcessorId = processor.getRecipeProcessorId();
List<PositionedStack> tInputs = new ArrayList<>();
List<PositionedStack> mergedInputs = new ArrayList<>();
if (!inputs.isEmpty() && !outputs.isEmpty()) {
NEECraftingHandler.ingredients.clear();
@@ -81,10 +82,10 @@ public class NEECraftingHandler implements IOverlayHandler {
ItemStack currentStack = positionedStack.items[0];
boolean find = false;
ItemCombination currentValue = ItemCombination.valueOf(NEEConfig.itemCombinationMode);
if (currentValue != ItemCombination.DISABLED) {
if (currentValue != ItemCombination.DISABLED && processor.mergeStacks(recipe, recipeIndex, identifier)) {
boolean isWhitelist = currentValue == ItemCombination.WHITELIST && Arrays.asList(NEEConfig.itemCombinationWhitelist).contains(identifier);
if (currentValue == ItemCombination.ENABLED || isWhitelist) {
for (PositionedStack storedStack : tInputs) {
for (PositionedStack storedStack : mergedInputs) {
ItemStack firstStack = storedStack.items[0];
boolean areItemStackEqual = firstStack.isItemEqual(currentStack) && ItemStack.areItemStackTagsEqual(firstStack, currentStack);
if (areItemStackEqual && (firstStack.stackSize + currentStack.stackSize) <= firstStack.getMaxStackSize()) {
@@ -95,10 +96,10 @@ public class NEECraftingHandler implements IOverlayHandler {
}
}
if (!find) {
tInputs.add(positionedStack.copy());
mergedInputs.add(positionedStack.copy());
}
}
for (PositionedStack positionedStack : tInputs) {
for (PositionedStack positionedStack : mergedInputs) {
ItemStack currentStack = positionedStack.items[0];
ItemStack preferModItem = ItemUtils.getPreferModItem(positionedStack.items);
@@ -118,8 +119,7 @@ public class NEECraftingHandler implements IOverlayHandler {
continue;
}
//Fix ItemStack with wrong meta
if (currentStack.getItemDamage() == 32767) {
if (currentStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
currentStack.setItemDamage(0);
}
@@ -134,8 +134,7 @@ public class NEECraftingHandler implements IOverlayHandler {
}
ItemStack outputStack = positionedStack.item.copy();
//Fix ItemStack with wrong meta(maybe ?)
if (outputStack.getItemDamage() == 32767) {
if (outputStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
outputStack.setItemDamage(0);
}
@@ -174,8 +173,7 @@ public class NEECraftingHandler implements IOverlayHandler {
ItemUtils.transformGTTool(stack);
//Fix ItemStack with wrong meta
if (stack.getItemDamage() == 32767) {
if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
stack.setItemDamage(0);
}
@@ -36,6 +36,7 @@ import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.oredict.OreDictionary;
import org.lwjgl.input.Keyboard;
import java.io.ByteArrayOutputStream;
@@ -109,8 +110,7 @@ public class NEECraftingHelper implements IOverlayHandler {
}
}
//Fix ItemStack with wrong meta
if (stack.getItemDamage() == 32767) {
if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
stack.setItemDamage(0);
}
@@ -106,4 +106,8 @@ public class GregTech5RecipeProcessor implements IRecipeProcessor {
return recipeOutputs;
}
@Override
public boolean mergeStacks(IRecipeHandler recipe, int recipeIndex, String identifier) {
return !"gt.recipe.fakeAssemblylineProcess".equals(identifier);
}
}
@@ -27,4 +27,8 @@ public interface IRecipeProcessor {
@Nonnull
List<PositionedStack> getRecipeOutput(IRecipeHandler recipe, int recipeIndex, String identifier);
default boolean mergeStacks(IRecipeHandler recipe, int recipeIndex, String identifier) {
return true;
}
}