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); 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 * @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); boolean onReceiveOutput(ItemStack stack);

View File

@@ -123,11 +123,15 @@ public abstract class CraftingStep implements ICraftingStep {
} }
if (API.instance().getComparer().isEqual(stack, output, CraftingTask.DEFAULT_COMPARE | (getPattern().isOredict() ? IComparer.COMPARE_OREDICT : 0))) { if (API.instance().getComparer().isEqual(stack, output, CraftingTask.DEFAULT_COMPARE | (getPattern().isOredict() ? IComparer.COMPARE_OREDICT : 0))) {
if (received < output.stackSize) { 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(); network.sendCraftingMonitorUpdate();
return true; if (stack.stackSize == 0) {
return true;
}
} }
} }
} }

View File

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