Fix inputs null stuff

This commit is contained in:
Raoul Van den Berge
2016-10-16 22:35:48 +02:00
parent a6fcf79917
commit 25017ddc62
5 changed files with 24 additions and 24 deletions

View File

@@ -26,6 +26,7 @@
- Fixed when shift clicking crafting recipe and inventory is full items are dropping on the ground instead of going in the system (raoulvdberge) - Fixed when shift clicking crafting recipe and inventory is full items are dropping on the ground instead of going in the system (raoulvdberge)
- Fixed glitchy rendering of cable parts in item form (raoulvdberge) - Fixed glitchy rendering of cable parts in item form (raoulvdberge)
- Fixed Destructor being able to break bedrock (InusualZ) - Fixed Destructor being able to break bedrock (InusualZ)
- Fixed External Storage thinking that items are inserted in Extra Utilities Trash Cans (InusualZ)
- Updated Storage Drawers API (raoulvdberge) - Updated Storage Drawers API (raoulvdberge)
### 1.1.3 ### 1.1.3

View File

@@ -3,6 +3,8 @@ package refinedstorage.api.autocrafting.task;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import refinedstorage.api.autocrafting.ICraftingPattern; import refinedstorage.api.autocrafting.ICraftingPattern;
import java.util.Deque;
/** /**
* Represents a item in a crafting task that can be processed. * Represents a item in a crafting task that can be processed.
*/ */
@@ -13,14 +15,9 @@ public interface IProcessable {
ICraftingPattern getPattern(); ICraftingPattern getPattern();
/** /**
* @return the first stack to attempt inserting * @return the stacks to insert
*/ */
ItemStack getStackToInsert(); Deque<ItemStack> getToInsert();
/**
* Moves to the next stack to insert.
*/
void nextStack();
/** /**
* @return true if we received all outputs, false otherwise * @return true if we received all outputs, false otherwise

View File

@@ -213,13 +213,13 @@ public class CraftingTask implements ICraftingTask {
for (IProcessable processable : toProcess) { for (IProcessable processable : toProcess) {
IItemHandler inventory = processable.getPattern().getContainer().getFacingInventory(); IItemHandler inventory = processable.getPattern().getContainer().getFacingInventory();
if (inventory != null && processable.getStackToInsert() != null) { if (inventory != null && !processable.getToInsert().isEmpty()) {
ItemStack toInsert = network.extractItem(processable.getStackToInsert(), 1, compare); ItemStack toInsert = network.extractItem(processable.getToInsert().peek(), 1, compare);
if (ItemHandlerHelper.insertItem(inventory, toInsert, true) == null) { if (ItemHandlerHelper.insertItem(inventory, toInsert, true) == null) {
ItemHandlerHelper.insertItem(inventory, toInsert, false); ItemHandlerHelper.insertItem(inventory, toInsert, false);
processable.nextStack(); processable.getToInsert().pop();
} }
} }
} }

View File

@@ -5,14 +5,23 @@ import refinedstorage.api.autocrafting.ICraftingPattern;
import refinedstorage.api.autocrafting.task.IProcessable; import refinedstorage.api.autocrafting.task.IProcessable;
import refinedstorage.apiimpl.API; import refinedstorage.apiimpl.API;
import java.util.ArrayDeque;
import java.util.Deque;
public class Processable implements IProcessable { public class Processable implements IProcessable {
private ICraftingPattern pattern; private ICraftingPattern pattern;
private int pos; private Deque<ItemStack> toInsert = new ArrayDeque<>();
private boolean satisfied[]; private boolean satisfied[];
public Processable(ICraftingPattern pattern) { public Processable(ICraftingPattern pattern) {
this.pattern = pattern; this.pattern = pattern;
this.satisfied = new boolean[pattern.getOutputs().size()]; this.satisfied = new boolean[pattern.getOutputs().size()];
for (ItemStack input : pattern.getInputs()) {
if (input != null) {
toInsert.add(input.copy());
}
}
} }
@Override @Override
@@ -21,17 +30,8 @@ public class Processable implements IProcessable {
} }
@Override @Override
public void nextStack() { public Deque<ItemStack> getToInsert() {
++pos; return toInsert;
}
@Override
public ItemStack getStackToInsert() {
if (pos > pattern.getInputs().size() - 1) {
return null;
}
return pattern.getInputs().get(pos);
} }
@Override @Override

View File

@@ -448,10 +448,12 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
int score = 0; int score = 0;
for (ItemStack input : patterns.get(i).getInputs()) { for (ItemStack input : patterns.get(i).getInputs()) {
if (input != null) {
ItemStack stored = itemStorage.getList().get(input, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT); 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) { if (score > highestScore) {
highestScore = score; highestScore = score;