2016-01-12 12:38:51 -05:00
|
|
|
package WayofTime.bloodmagic.tile.routing;
|
|
|
|
|
2016-01-14 14:11:16 -05:00
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import net.minecraft.inventory.IInventory;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
|
|
|
import WayofTime.bloodmagic.item.inventory.ItemInventory;
|
|
|
|
import WayofTime.bloodmagic.routing.IItemFilter;
|
|
|
|
import WayofTime.bloodmagic.routing.IOutputItemRoutingNode;
|
|
|
|
import WayofTime.bloodmagic.routing.TestItemFilter;
|
|
|
|
import WayofTime.bloodmagic.util.GhostItemHelper;
|
|
|
|
|
|
|
|
public class TileOutputRoutingNode extends TileFilteredRoutingNode implements IOutputItemRoutingNode
|
2016-01-12 12:38:51 -05:00
|
|
|
{
|
2016-01-14 08:27:09 -05:00
|
|
|
public TileOutputRoutingNode()
|
|
|
|
{
|
2016-01-14 11:06:50 -05:00
|
|
|
super(7, "outputNode");
|
2016-01-14 08:27:09 -05:00
|
|
|
}
|
2016-01-14 14:11:16 -05:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isOutput(EnumFacing side)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IItemFilter getOutputFilterForSide(EnumFacing side)
|
|
|
|
{
|
|
|
|
ItemStack filterStack = this.getFilterStack(side);
|
|
|
|
|
|
|
|
if (filterStack == null)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
TileEntity tile = worldObj.getTileEntity(pos.offset(side));
|
|
|
|
if (tile instanceof IInventory)
|
|
|
|
{
|
|
|
|
IItemFilter testFilter = new TestItemFilter();
|
|
|
|
List<ItemStack> filteredList = new LinkedList<ItemStack>();
|
|
|
|
ItemInventory inv = new ItemInventory(filterStack, 9, ""); //TODO: Change to grab the filter from the Item later.
|
|
|
|
for (int i = 0; i < inv.getSizeInventory(); i++)
|
|
|
|
{
|
|
|
|
ItemStack stack = inv.getStackInSlot(i);
|
|
|
|
if (stack == null)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-01-15 06:24:10 -05:00
|
|
|
ItemStack ghostStack = GhostItemHelper.getStackFromGhost(stack);
|
|
|
|
if (ghostStack.stackSize == 0)
|
|
|
|
{
|
2016-01-15 06:44:26 -05:00
|
|
|
ghostStack.stackSize = Integer.MAX_VALUE;
|
2016-01-15 06:24:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
filteredList.add(ghostStack);
|
2016-01-14 14:11:16 -05:00
|
|
|
}
|
|
|
|
|
2016-01-15 06:24:10 -05:00
|
|
|
testFilter.initializeFilter(filteredList, (IInventory) tile, side.getOpposite(), true);
|
2016-01-14 14:11:16 -05:00
|
|
|
|
|
|
|
return testFilter;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2016-01-12 12:38:51 -05:00
|
|
|
}
|