Fix inputs null stuff
This commit is contained in:
@@ -3,6 +3,8 @@ package refinedstorage.api.autocrafting.task;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
|
||||
import java.util.Deque;
|
||||
|
||||
/**
|
||||
* Represents a item in a crafting task that can be processed.
|
||||
*/
|
||||
@@ -13,14 +15,9 @@ public interface IProcessable {
|
||||
ICraftingPattern getPattern();
|
||||
|
||||
/**
|
||||
* @return the first stack to attempt inserting
|
||||
* @return the stacks to insert
|
||||
*/
|
||||
ItemStack getStackToInsert();
|
||||
|
||||
/**
|
||||
* Moves to the next stack to insert.
|
||||
*/
|
||||
void nextStack();
|
||||
Deque<ItemStack> getToInsert();
|
||||
|
||||
/**
|
||||
* @return true if we received all outputs, false otherwise
|
||||
|
||||
@@ -213,13 +213,13 @@ public class CraftingTask implements ICraftingTask {
|
||||
for (IProcessable processable : toProcess) {
|
||||
IItemHandler inventory = processable.getPattern().getContainer().getFacingInventory();
|
||||
|
||||
if (inventory != null && processable.getStackToInsert() != null) {
|
||||
ItemStack toInsert = network.extractItem(processable.getStackToInsert(), 1, compare);
|
||||
if (inventory != null && !processable.getToInsert().isEmpty()) {
|
||||
ItemStack toInsert = network.extractItem(processable.getToInsert().peek(), 1, compare);
|
||||
|
||||
if (ItemHandlerHelper.insertItem(inventory, toInsert, true) == null) {
|
||||
ItemHandlerHelper.insertItem(inventory, toInsert, false);
|
||||
|
||||
processable.nextStack();
|
||||
processable.getToInsert().pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,14 +5,23 @@ import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import refinedstorage.api.autocrafting.task.IProcessable;
|
||||
import refinedstorage.apiimpl.API;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
|
||||
public class Processable implements IProcessable {
|
||||
private ICraftingPattern pattern;
|
||||
private int pos;
|
||||
private Deque<ItemStack> toInsert = new ArrayDeque<>();
|
||||
private boolean satisfied[];
|
||||
|
||||
public Processable(ICraftingPattern pattern) {
|
||||
this.pattern = pattern;
|
||||
this.satisfied = new boolean[pattern.getOutputs().size()];
|
||||
|
||||
for (ItemStack input : pattern.getInputs()) {
|
||||
if (input != null) {
|
||||
toInsert.add(input.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -21,17 +30,8 @@ public class Processable implements IProcessable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nextStack() {
|
||||
++pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackToInsert() {
|
||||
if (pos > pattern.getInputs().size() - 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return pattern.getInputs().get(pos);
|
||||
public Deque<ItemStack> getToInsert() {
|
||||
return toInsert;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -448,9 +448,11 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
int score = 0;
|
||||
|
||||
for (ItemStack input : patterns.get(i).getInputs()) {
|
||||
ItemStack stored = itemStorage.getList().get(input, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT);
|
||||
if (input != null) {
|
||||
ItemStack stored = itemStorage.getList().get(input, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT);
|
||||
|
||||
score += stored != null ? stored.stackSize : 0;
|
||||
score += stored != null ? stored.stackSize : 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (score > highestScore) {
|
||||
|
||||
Reference in New Issue
Block a user