Initial framework for the item routing is completed
This commit is contained in:
parent
eaefd89287
commit
652b6a45fd
12 changed files with 256 additions and 47 deletions
|
@ -119,7 +119,7 @@ public class ContainerItemRoutingNode extends Container
|
|||
{
|
||||
if (slotStack != null)
|
||||
{
|
||||
GhostItemHelper.decrementGhostAmout(slotStack, 1);
|
||||
GhostItemHelper.decrementGhostAmount(slotStack, 1);
|
||||
if (GhostItemHelper.getItemGhostAmount(slotStack) < 0)
|
||||
{
|
||||
slot.putStack(null);
|
||||
|
|
|
@ -14,6 +14,18 @@ public class TileFilteredRoutingNode extends TileRoutingNode implements ISidedIn
|
|||
super(size, name);
|
||||
}
|
||||
|
||||
public ItemStack getFilterStack(EnumFacing side)
|
||||
{
|
||||
int index = side.getIndex();
|
||||
if (currentActiveSlot == index)
|
||||
{
|
||||
return getStackInSlot(0);
|
||||
} else
|
||||
{
|
||||
return getStackInSlot(index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
|
|
|
@ -1,9 +1,63 @@
|
|||
package WayofTime.bloodmagic.tile.routing;
|
||||
|
||||
public class TileInputRoutingNode extends TileFilteredRoutingNode
|
||||
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.IInputItemRoutingNode;
|
||||
import WayofTime.bloodmagic.routing.IItemFilter;
|
||||
import WayofTime.bloodmagic.routing.TestItemFilter;
|
||||
import WayofTime.bloodmagic.util.GhostItemHelper;
|
||||
|
||||
public class TileInputRoutingNode extends TileFilteredRoutingNode implements IInputItemRoutingNode
|
||||
{
|
||||
public TileInputRoutingNode()
|
||||
{
|
||||
super(7, "inputNode");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInput(EnumFacing side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemFilter getInputFilterForSide(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;
|
||||
}
|
||||
|
||||
filteredList.add(GhostItemHelper.getStackFromGhost(stack));
|
||||
}
|
||||
|
||||
testFilter.initializeFilter(filteredList, (IInventory) tile, side, false);
|
||||
|
||||
return testFilter;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,63 @@
|
|||
package WayofTime.bloodmagic.tile.routing;
|
||||
|
||||
public class TileOutputRoutingNode extends TileFilteredRoutingNode
|
||||
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
|
||||
{
|
||||
public TileOutputRoutingNode()
|
||||
{
|
||||
super(7, "outputNode");
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
filteredList.add(GhostItemHelper.getStackFromGhost(stack));
|
||||
}
|
||||
|
||||
testFilter.initializeFilter(filteredList, (IInventory) tile, side, true);
|
||||
|
||||
return testFilter;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import net.minecraft.util.BlockPos;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.routing.IItemFilter;
|
||||
import WayofTime.bloodmagic.routing.IItemRoutingNode;
|
||||
import WayofTime.bloodmagic.routing.IMasterRoutingNode;
|
||||
import WayofTime.bloodmagic.routing.IRoutingNode;
|
||||
|
@ -168,13 +167,12 @@ public class TileRoutingNode extends TileInventory implements IRoutingNode, IIte
|
|||
@Override
|
||||
public boolean isInventoryConnectedToSide(EnumFacing side)
|
||||
{
|
||||
//TODO: Implement connections for side
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemFilter generateFilterForSide(EnumFacing side)
|
||||
public int getPriority(EnumFacing side)
|
||||
{
|
||||
return null;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue