diff --git a/src/main/java/forestry/core/inventory/InvTools.java b/src/main/java/forestry/core/inventory/InvTools.java index bedc8b679..e4774954b 100755 --- a/src/main/java/forestry/core/inventory/InvTools.java +++ b/src/main/java/forestry/core/inventory/InvTools.java @@ -13,6 +13,7 @@ package forestry.core.inventory; import java.util.AbstractMap; import java.util.ArrayList; import java.util.Collection; +import java.util.EnumSet; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -758,15 +759,19 @@ public abstract class InvTools { * @return true if an item was inserted, otherwise false. */ public static boolean moveOneItemToPipe(IInventory source, AdjacentTileCache tileCache) { + return moveOneItemToPipe(source, tileCache, ForgeDirection.VALID_DIRECTIONS); + } + + public static boolean moveOneItemToPipe(IInventory source, AdjacentTileCache tileCache, ForgeDirection[] directions) { if (PluginManager.Module.BUILDCRAFT_TRANSPORT.isEnabled()) { - return internal_moveOneItemToPipe(source, tileCache); + return internal_moveOneItemToPipe(source, tileCache, directions); } return false; } @Optional.Method(modid = "BuildCraftAPI|transport") - private static boolean internal_moveOneItemToPipe(IInventory source, AdjacentTileCache tileCache) { + private static boolean internal_moveOneItemToPipe(IInventory source, AdjacentTileCache tileCache, ForgeDirection[] directions) { IInventory invClone = new InventoryCopy(source); ItemStack stackToMove = removeOneItem(invClone); if (stackToMove == null) @@ -776,7 +781,7 @@ public abstract class InvTools { List> pipes = new ArrayList>(); boolean foundPipe = false; - for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + for (ForgeDirection side : directions) { TileEntity tile = tileCache.getTileOnSide(side); if (tile instanceof IPipeTile) { IPipeTile pipe = (IPipeTile) tile; diff --git a/src/main/java/forestry/farming/gadgets/TileHatch.java b/src/main/java/forestry/farming/gadgets/TileHatch.java index b06fae332..96570fcff 100755 --- a/src/main/java/forestry/farming/gadgets/TileHatch.java +++ b/src/main/java/forestry/farming/gadgets/TileHatch.java @@ -13,10 +13,8 @@ package forestry.farming.gadgets; import java.util.Collection; import java.util.LinkedList; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; @@ -35,11 +33,13 @@ import buildcraft.api.statements.ITriggerExternal; public class TileHatch extends TileFarm implements ISidedInventory { + private static final ForgeDirection[] dumpDirections = new ForgeDirection[] { ForgeDirection.DOWN }; + private final AdjacentInventoryCache inventoryCache = new AdjacentInventoryCache(this, getTileCache(), new ITileFilter() { @Override public boolean matches(TileEntity tile) { - return !(tile instanceof TileFarm); + return !(tile instanceof TileFarm) && tile.yCoord < yCoord; } }, null); @@ -69,7 +69,7 @@ public class TileHatch extends TileFarm implements ISidedInventory { if (productInventory == null) return; - if (!InvTools.moveOneItemToPipe(productInventory, tileCache)) { + if (!InvTools.moveOneItemToPipe(productInventory, tileCache, dumpDirections)) { InvTools.moveItemStack(productInventory, inventoryCache.getAdjacentInventories()); } }