From 93940c151d8b670f436001acc158848ac8a39961 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Fri, 11 Jul 2014 18:59:55 -0500 Subject: [PATCH] Fixed a bug where interfaces would try to send items into cables ( or other IInv implementations that can't accept items. ) --- helpers/DualityInterface.java | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/helpers/DualityInterface.java b/helpers/DualityInterface.java index 4ed4960d..d394ea8c 100644 --- a/helpers/DualityInterface.java +++ b/helpers/DualityInterface.java @@ -778,24 +778,40 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() ); if ( ad != null ) { - - for (int x = 0; x < table.getSizeInventory(); x++) + if ( acceptsItems( ad, table ) ) { - ItemStack is = table.getStackInSlot( x ); - if ( is != null ) + for (int x = 0; x < table.getSizeInventory(); x++) { - addToSendList( ad.addItems( is ) ); + ItemStack is = table.getStackInSlot( x ); + if ( is != null ) + { + addToSendList( ad.addItems( is ) ); + } } + pushItemsOut( possibleDirections ); + return true; } - - pushItemsOut( possibleDirections ); - return true; } } return false; } + private boolean acceptsItems(InventoryAdaptor ad, InventoryCrafting table) + { + for (int x = 0; x < table.getSizeInventory(); x++) + { + ItemStack is = table.getStackInSlot( x ); + if ( is == null ) + continue; + + if ( ad.simulateAdd( is.copy() ) != null ) + return false; + } + + return true; + } + private void pushItemsOut(EnumSet possibleDirections) { if ( !hasItemsToSend() ) @@ -826,8 +842,6 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt if ( whatToSend == null ) i.remove(); - else - whatToSend.stackSize = whatToSend.stackSize; } if ( waitingToSend.isEmpty() )