Skip to content

Commit a4116fd

Browse files
committed
Conduit support for interfaces
1 parent a87f898 commit a4116fd

File tree

3 files changed

+43
-16
lines changed

3 files changed

+43
-16
lines changed

gradle/scripts/dependencies.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ dependencies {
133133
compileOnly "codechicken:CodeChickenCore:${minecraft_version}-${code_chicken_core_version}:dev"
134134
compileOnly "codechicken:NotEnoughItems:${minecraft_version}-${nei_version}:dev"
135135
compileOnly "com.gregoriust.gregtech:gregtech:${gt_version}:dev"
136+
136137

138+
compile files("lib/CoFHLib-[1.7.10]1.2.1-185-dev.jar")
137139
compile files("lib/buildcraft-${bc_version}-dev.jar")
138140
compile files("lib/PneumaticCraft-${minecraft_version}-${pneumaticcraft_version}-api.jar")
139141

lib/CoFHLib-[1.7.10]1.2.1-185-dev.jar

293 KB
Binary file not shown.

src/main/java/appeng/helpers/DualityInterface.java

+41-16
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
import net.minecraft.util.Vec3;
8888
import net.minecraft.world.World;
8989
import net.minecraftforge.common.util.ForgeDirection;
90+
import cofh.api.transport.IItemDuct;
9091

9192
import java.util.*;
9293

@@ -598,23 +599,27 @@ private void pushItemsOut( final EnumSet<ForgeDirection> possibleDirections )
598599
}
599600

600601
final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() );
602+
ItemStack Result = whatToSend;
601603
if( ad != null )
602604
{
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+
}
613619

614-
if( whatToSend == null )
615-
{
616-
break;
617-
}
620+
if( whatToSend == null )
621+
{
622+
break;
618623
}
619624
}
620625

@@ -950,14 +955,34 @@ public boolean pushPattern( final ICraftingPatternDetails patternDetails, final
950955
final ItemStack is = table.getStackInSlot( x );
951956
if( is != null )
952957
{
953-
final ItemStack added = ad.addItems( is );
954-
this.addToSendList( added );
958+
this.addToSendList( ad.addItems( is ) );
955959
}
956960
}
957961
this.pushItemsOut( possibleDirections );
958962
return true;
959963
}
960964
}
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+
}
961986
}
962987

963988
return false;

0 commit comments

Comments
 (0)