|
87 | 87 | import net.minecraft.util.Vec3;
|
88 | 88 | import net.minecraft.world.World;
|
89 | 89 | import net.minecraftforge.common.util.ForgeDirection;
|
| 90 | +import cofh.api.transport.IItemDuct; |
90 | 91 |
|
91 | 92 | import java.util.*;
|
92 | 93 |
|
@@ -598,23 +599,27 @@ private void pushItemsOut( final EnumSet<ForgeDirection> possibleDirections )
|
598 | 599 | }
|
599 | 600 |
|
600 | 601 | final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() );
|
| 602 | + ItemStack Result = whatToSend; |
601 | 603 | if( ad != null )
|
602 | 604 | {
|
603 |
| - final ItemStack Result = ad.addItems( whatToSend ); |
604 |
| - |
605 |
| - if( Result == null ) |
606 |
| - { |
607 |
| - whatToSend = null; |
608 |
| - } |
609 |
| - else |
610 |
| - { |
611 |
| - whatToSend.stackSize -= whatToSend.stackSize - Result.stackSize; |
612 |
| - } |
| 605 | + Result = ad.addItems( whatToSend ); |
| 606 | + } |
| 607 | + else if (te instanceof IItemDuct) |
| 608 | + { |
| 609 | + Result = ((IItemDuct)te).insertItem(s.getOpposite(), whatToSend); |
| 610 | + } |
| 611 | + if( Result == null ) |
| 612 | + { |
| 613 | + whatToSend = null; |
| 614 | + } |
| 615 | + else |
| 616 | + { |
| 617 | + whatToSend.stackSize -= whatToSend.stackSize - Result.stackSize; |
| 618 | + } |
613 | 619 |
|
614 |
| - if( whatToSend == null ) |
615 |
| - { |
616 |
| - break; |
617 |
| - } |
| 620 | + if( whatToSend == null ) |
| 621 | + { |
| 622 | + break; |
618 | 623 | }
|
619 | 624 | }
|
620 | 625 |
|
@@ -950,14 +955,34 @@ public boolean pushPattern( final ICraftingPatternDetails patternDetails, final
|
950 | 955 | final ItemStack is = table.getStackInSlot( x );
|
951 | 956 | if( is != null )
|
952 | 957 | {
|
953 |
| - final ItemStack added = ad.addItems( is ); |
954 |
| - this.addToSendList( added ); |
| 958 | + this.addToSendList( ad.addItems( is ) ); |
955 | 959 | }
|
956 | 960 | }
|
957 | 961 | this.pushItemsOut( possibleDirections );
|
958 | 962 | return true;
|
959 | 963 | }
|
960 | 964 | }
|
| 965 | + else if (te instanceof IItemDuct) |
| 966 | + { |
| 967 | + boolean hadAcceptedSome = false; |
| 968 | + for( int x = 0; x < table.getSizeInventory(); x++ ) |
| 969 | + { |
| 970 | + final ItemStack is = table.getStackInSlot( x ); |
| 971 | + if (is != null) |
| 972 | + { |
| 973 | + final ItemStack rest = ((IItemDuct)te).insertItem(s.getOpposite(), is); |
| 974 | + if (!hadAcceptedSome && rest != null && rest.stackSize == is.stackSize) |
| 975 | + break; // conduit should accept all the pattern or nothing. |
| 976 | + hadAcceptedSome = true; |
| 977 | + this.addToSendList(rest); |
| 978 | + } |
| 979 | + } |
| 980 | + if (hadAcceptedSome) |
| 981 | + { |
| 982 | + this.pushItemsOut(possibleDirections); |
| 983 | + return true; |
| 984 | + } |
| 985 | + } |
961 | 986 | }
|
962 | 987 |
|
963 | 988 | return false;
|
|
0 commit comments