should fix ICraftingStep#onReceiveOutput, #528

This commit is contained in:
way2muchnoise
2016-10-27 17:21:15 +02:00
parent d363b928cf
commit 411c912387
3 changed files with 12 additions and 4 deletions

View File

@@ -72,8 +72,11 @@ public interface ICraftingStep {
boolean hasReceivedOutput(ItemStack stack);
/**
* The {@link ItemStack} given to it will be changed and contain the remainder
* The return value will only be true if the stack size is zero
*
* @param stack the stack that was inserted in the storage system
* @return true if this item belonged to the processable item, false otherwise
* @return true if this item belonged to the processable item and was fully used, false otherwise
*/
boolean onReceiveOutput(ItemStack stack);

View File

@@ -123,14 +123,18 @@ public abstract class CraftingStep implements ICraftingStep {
}
if (API.instance().getComparer().isEqual(stack, output, CraftingTask.DEFAULT_COMPARE | (getPattern().isOredict() ? IComparer.COMPARE_OREDICT : 0))) {
if (received < output.stackSize) {
satisfied.put(hashcode, received + stack.stackSize);
int toReceive = Math.min(output.stackSize - received, stack.stackSize);
satisfied.put(hashcode, received + toReceive);
stack.stackSize -= toReceive;
network.sendCraftingMonitorUpdate();
if (stack.stackSize == 0) {
return true;
}
}
}
}
return false;
}

View File

@@ -553,10 +553,11 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
if (!simulate && inserted > 0 && accessType != AccessType.WRITE) {
itemStorage.add(ItemHandlerHelper.copyStackWithSize(stack, inserted), false);
ItemStack checkSteps = ItemHandlerHelper.copyStackWithSize(stack, inserted);
for (ICraftingTask task : craftingTasks) {
for (ICraftingStep processable : task.getSteps()) {
if (processable.onReceiveOutput(stack)) {
if (processable.onReceiveOutput(checkSteps)) {
return remainder; // All done
}
}