fixes #851
This commit is contained in:
@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.api.autocrafting;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -102,6 +103,23 @@ public interface ICraftingManager {
|
||||
return chain == null ? null : chain.cycle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a crafting pattern for an item stack.
|
||||
* This returns a single crafting pattern, as opposed to {@link ICraftingManager#getPatterns(ItemStack, int)}.
|
||||
* Internally, this makes a selection out of the available patterns.
|
||||
* It makes this selection based on the item count of the pattern outputs in the {@link IStackList<ItemStack>} provided.
|
||||
*
|
||||
* @param pattern the stack to get a pattern for
|
||||
* @param flags the flags to compare on, see {@link IComparer}
|
||||
* @param itemList the {@link IStackList<ItemStack>} used to calculate the best fitting pattern
|
||||
* @return the pattern, or null if the pattern is not found
|
||||
*/
|
||||
@Nullable
|
||||
default ICraftingPattern getPattern(ItemStack pattern, int flags, IStackList<ItemStack> itemList) {
|
||||
ICraftingPatternChain chain = getPatternChain(pattern, flags, itemList);
|
||||
return chain == null ? null : chain.cycle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a crafting pattern for an item stack.
|
||||
* This returns a single crafting pattern, as opposed to {@link ICraftingManager#getPatterns(ItemStack, int)}.
|
||||
@@ -129,6 +147,20 @@ public interface ICraftingManager {
|
||||
@Nullable
|
||||
ICraftingPatternChain getPatternChain(ItemStack pattern, int flags);
|
||||
|
||||
/**
|
||||
* Returns a crafting pattern chain for an item stack.
|
||||
* This returns a single crafting pattern, as opposed to {@link ICraftingManager#getPatterns(ItemStack, int)}.
|
||||
* Internally, this makes a selection out of the available patterns.
|
||||
* It makes this selection based on the item count of the pattern outputs in the {@link IStackList<ItemStack>} provided.
|
||||
*
|
||||
* @param pattern the stack to get a pattern for
|
||||
* @param flags the flags to compare on, see {@link IComparer}
|
||||
* @param itemList the {@link IStackList<ItemStack>} used to calculate the best fitting pattern
|
||||
* @return the pattern chain, or null if the pattern chain is not found
|
||||
*/
|
||||
@Nullable
|
||||
ICraftingPatternChain getPatternChain(ItemStack pattern, int flags, IStackList<ItemStack> itemList);
|
||||
|
||||
/**
|
||||
* Returns a crafting pattern for an item stack.
|
||||
* This returns a single crafting pattern, as opposed to {@link ICraftingManager#getPatterns(ItemStack, int)}.
|
||||
|
||||
@@ -113,6 +113,11 @@ public class CraftingManager implements ICraftingManager {
|
||||
|
||||
@Override
|
||||
public ICraftingPatternChain getPatternChain(ItemStack pattern, int flags) {
|
||||
return getPatternChain(pattern, flags, network.getItemStorageCache().getList().getOredicted());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftingPatternChain getPatternChain(ItemStack pattern, int flags, IStackList<ItemStack> itemList) {
|
||||
List<ICraftingPatternChain> patternChains = getPatternChains(pattern, flags);
|
||||
|
||||
if (patternChains.isEmpty()) {
|
||||
@@ -124,8 +129,6 @@ public class CraftingManager implements ICraftingManager {
|
||||
int highestScore = 0;
|
||||
int highestPattern = 0;
|
||||
|
||||
IStackList<ItemStack> itemList = network.getItemStorageCache().getList().getOredicted();
|
||||
|
||||
for (int i = 0; i < patternChains.size(); ++i) {
|
||||
int score = 0;
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ public class CraftingTask implements ICraftingTask {
|
||||
ICraftingPattern inputPattern = null;
|
||||
int available = (extraStack == null ? 0 : extraStack.getCount()) + (networkStack == null ? 0 : networkStack.getCount());
|
||||
if (available < input.getCount()) {
|
||||
inputPattern = network.getCraftingManager().getPattern(input, compare);
|
||||
inputPattern = network.getCraftingManager().getPattern(input, compare, networkList);
|
||||
if (inputPattern != null) {
|
||||
if (inputPattern.getInputs().stream().anyMatch(s -> API.instance().getComparer().isEqual(s, lambdaInput, lambdaCompare))) {
|
||||
int craftQuantity = inputPattern.getQuantityPerRequest(input, compare);
|
||||
@@ -199,7 +199,7 @@ public class CraftingTask implements ICraftingTask {
|
||||
} else {
|
||||
int oreDictedCompare = compare | (pattern.isOredict() ? IComparer.COMPARE_OREDICT : 0);
|
||||
if (inputPattern == null) {
|
||||
inputPattern = network.getCraftingManager().getPattern(input, oreDictedCompare);
|
||||
inputPattern = network.getCraftingManager().getPattern(input, oreDictedCompare, networkList);
|
||||
}
|
||||
|
||||
if (inputPattern != null) {
|
||||
|
||||
Reference in New Issue
Block a user