Added routing filters as well as recipes and temp textures.
This commit is contained in:
parent
76dceb3534
commit
815faa2ced
13 changed files with 187 additions and 70 deletions
|
@ -7,6 +7,7 @@ import net.minecraft.inventory.IInventory;
|
|||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import WayofTime.bloodmagic.item.inventory.ItemInventory;
|
||||
import WayofTime.bloodmagic.item.routing.IItemFilterProvider;
|
||||
import WayofTime.bloodmagic.util.GhostItemHelper;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
|
||||
|
@ -169,7 +170,7 @@ public class ContainerItemRoutingNode extends Container
|
|||
} else if (index > 0)
|
||||
{
|
||||
// return null;
|
||||
if (true) // Change to check item is a filter
|
||||
if (itemstack1.getItem() instanceof IItemFilterProvider) // Change to check item is a filter
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 0, 1, false))
|
||||
{
|
||||
|
@ -219,7 +220,7 @@ public class ContainerItemRoutingNode extends Container
|
|||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack)
|
||||
{
|
||||
return true; //TODO: Create a new Item that holds the filter.
|
||||
return itemStack.getItem() instanceof IItemFilterProvider; //TODO: Create a new Item that holds the filter.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
package WayofTime.bloodmagic.tile.routing;
|
||||
|
||||
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.item.routing.IItemFilterProvider;
|
||||
import WayofTime.bloodmagic.routing.IInputItemRoutingNode;
|
||||
import WayofTime.bloodmagic.routing.IItemFilter;
|
||||
import WayofTime.bloodmagic.routing.TestItemFilter;
|
||||
import WayofTime.bloodmagic.util.GhostItemHelper;
|
||||
|
||||
public class TileInputRoutingNode extends TileFilteredRoutingNode implements IInputItemRoutingNode
|
||||
{
|
||||
|
@ -31,37 +26,17 @@ public class TileInputRoutingNode extends TileFilteredRoutingNode implements IIn
|
|||
{
|
||||
ItemStack filterStack = this.getFilterStack(side);
|
||||
|
||||
if (filterStack == null)
|
||||
if (filterStack == null || !(filterStack.getItem() instanceof IItemFilterProvider))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
IItemFilterProvider filter = (IItemFilterProvider) filterStack.getItem();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
ItemStack ghostResult = GhostItemHelper.getStackFromGhost(stack);
|
||||
// if (ghostResult.stackSize == 0)
|
||||
// {
|
||||
// ghostResult.stackSize = Int.MaxValue();
|
||||
// }
|
||||
|
||||
filteredList.add(ghostResult);
|
||||
}
|
||||
|
||||
testFilter.initializeFilter(filteredList, (IInventory) tile, side.getOpposite(), false);
|
||||
|
||||
return testFilter;
|
||||
return filter.getInputItemFilter(filterStack, (IInventory) tile, side.getOpposite());
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
package WayofTime.bloodmagic.tile.routing;
|
||||
|
||||
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.item.routing.IItemFilterProvider;
|
||||
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
|
||||
{
|
||||
|
@ -31,37 +26,17 @@ public class TileOutputRoutingNode extends TileFilteredRoutingNode implements IO
|
|||
{
|
||||
ItemStack filterStack = this.getFilterStack(side);
|
||||
|
||||
if (filterStack == null)
|
||||
if (filterStack == null || !(filterStack.getItem() instanceof IItemFilterProvider))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
IItemFilterProvider filter = (IItemFilterProvider) filterStack.getItem();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
ItemStack ghostStack = GhostItemHelper.getStackFromGhost(stack);
|
||||
if (ghostStack.stackSize == 0)
|
||||
{
|
||||
ghostStack.stackSize = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
filteredList.add(ghostStack);
|
||||
}
|
||||
|
||||
testFilter.initializeFilter(filteredList, (IInventory) tile, side.getOpposite(), true);
|
||||
|
||||
return testFilter;
|
||||
return filter.getOutputItemFilter(filterStack, (IInventory) tile, side.getOpposite());
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue