Got the routing working to a safe degree.

This commit is contained in:
WayofTime 2016-01-14 15:03:13 -05:00
parent 652b6a45fd
commit 6a6369d08e
6 changed files with 30 additions and 8 deletions

View file

@ -6,7 +6,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.routing.TileMasterRoutingNode; import WayofTime.bloodmagic.tile.routing.TileMasterRoutingNode;
public class BlockMasterRoutingNode extends BlockContainer public class BlockMasterRoutingNode extends BlockContainer
{ {

View file

@ -31,7 +31,6 @@ import WayofTime.bloodmagic.item.block.ItemBlockCrystal;
import WayofTime.bloodmagic.item.block.ItemBlockPedestal; import WayofTime.bloodmagic.item.block.ItemBlockPedestal;
import WayofTime.bloodmagic.item.block.ItemBlockRitualController; import WayofTime.bloodmagic.item.block.ItemBlockRitualController;
import WayofTime.bloodmagic.item.block.ItemBlockRitualStone; import WayofTime.bloodmagic.item.block.ItemBlockRitualStone;
import WayofTime.bloodmagic.routing.TileMasterRoutingNode;
import WayofTime.bloodmagic.tile.TileAlchemyArray; import WayofTime.bloodmagic.tile.TileAlchemyArray;
import WayofTime.bloodmagic.tile.TileAltar; import WayofTime.bloodmagic.tile.TileAltar;
import WayofTime.bloodmagic.tile.TileImperfectRitualStone; import WayofTime.bloodmagic.tile.TileImperfectRitualStone;
@ -42,6 +41,7 @@ import WayofTime.bloodmagic.tile.TileSoulForge;
import WayofTime.bloodmagic.tile.TileSpectralBlock; import WayofTime.bloodmagic.tile.TileSpectralBlock;
import WayofTime.bloodmagic.tile.TileTeleposer; import WayofTime.bloodmagic.tile.TileTeleposer;
import WayofTime.bloodmagic.tile.routing.TileInputRoutingNode; import WayofTime.bloodmagic.tile.routing.TileInputRoutingNode;
import WayofTime.bloodmagic.tile.routing.TileMasterRoutingNode;
import WayofTime.bloodmagic.tile.routing.TileOutputRoutingNode; import WayofTime.bloodmagic.tile.routing.TileOutputRoutingNode;
import WayofTime.bloodmagic.util.helper.InventoryRenderHelper; import WayofTime.bloodmagic.util.helper.InventoryRenderHelper;

View file

@ -182,9 +182,12 @@ public class TestItemFilter implements IItemFilter
ItemStack testStack = inputStack.copy(); ItemStack testStack = inputStack.copy();
testStack.stackSize = allowedAmount; testStack.stackSize = allowedAmount;
ItemStack remainderStack = Utils.insertStackIntoInventory(testStack, accessedInventory, accessedSide, allowedAmount); ItemStack remainderStack = Utils.insertStackIntoInventory(testStack, accessedInventory, accessedSide);
// System.out.println("Remaining stack size: " + (remainderStack != null ? remainderStack.stackSize : 0) + ", allowed amount: " + allowedAmount);
int changeAmount = inputStack.stackSize - (remainderStack == null ? 0 : remainderStack.stackSize); int changeAmount = allowedAmount - (remainderStack == null ? 0 : remainderStack.stackSize);
testStack = inputStack.copy();
testStack.stackSize -= changeAmount;
for (ItemStack filterStack : requestList) for (ItemStack filterStack : requestList)
{ {
@ -198,7 +201,7 @@ public class TestItemFilter implements IItemFilter
} }
} }
return remainderStack; return testStack;
} }
/** /**
@ -254,6 +257,8 @@ public class TestItemFilter implements IItemFilter
ItemStack testStack = inputStack.copy(); ItemStack testStack = inputStack.copy();
testStack.stackSize = allowedAmount; testStack.stackSize = allowedAmount;
ItemStack remainderStack = outputFilter.transferStackThroughOutputFilter(testStack); ItemStack remainderStack = outputFilter.transferStackThroughOutputFilter(testStack);
int changeAmount = allowedAmount - (remainderStack == null ? 0 : remainderStack.stackSize);
// System.out.println("Change amount: " + changeAmount);
if (remainderStack != null && remainderStack.stackSize == allowedAmount) if (remainderStack != null && remainderStack.stackSize == allowedAmount)
{ {
@ -261,9 +266,9 @@ public class TestItemFilter implements IItemFilter
continue; continue;
} }
accessedInventory.setInventorySlotContents(slot, remainderStack); //Sets the slot in the inventory inputStack.stackSize -= changeAmount;
int changeAmount = inputStack.stackSize - (remainderStack == null ? 0 : remainderStack.stackSize); accessedInventory.setInventorySlotContents(slot, inputStack.stackSize <= 0 ? null : inputStack); //Sets the slot in the inventory
for (ItemStack filterStack : requestList) for (ItemStack filterStack : requestList)
{ {

View file

@ -26,6 +26,12 @@ public class TileFilteredRoutingNode extends TileRoutingNode implements ISidedIn
} }
} }
@Override
public boolean isInventoryConnectedToSide(EnumFacing side)
{
return true;
}
@Override @Override
public void readFromNBT(NBTTagCompound tag) public void readFromNBT(NBTTagCompound tag)
{ {

View file

@ -1,4 +1,4 @@
package WayofTime.bloodmagic.routing; package WayofTime.bloodmagic.tile.routing;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
@ -14,6 +14,12 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable; import net.minecraft.util.ITickable;
import net.minecraft.world.World; import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.routing.IInputItemRoutingNode;
import WayofTime.bloodmagic.routing.IItemFilter;
import WayofTime.bloodmagic.routing.IMasterRoutingNode;
import WayofTime.bloodmagic.routing.IOutputItemRoutingNode;
import WayofTime.bloodmagic.routing.IRoutingNode;
import WayofTime.bloodmagic.routing.NodeHelper;
public class TileMasterRoutingNode extends TileEntity implements IMasterRoutingNode, ITickable public class TileMasterRoutingNode extends TileEntity implements IMasterRoutingNode, ITickable
{ {
@ -46,6 +52,7 @@ public class TileMasterRoutingNode extends TileEntity implements IMasterRoutingN
{ {
if (!outputNode.isInventoryConnectedToSide(facing) || !outputNode.isOutput(facing)) if (!outputNode.isInventoryConnectedToSide(facing) || !outputNode.isOutput(facing))
{ {
System.out.println("Hello");
continue; continue;
} }

View file

@ -55,6 +55,10 @@ public class GhostItemHelper
NBTTagCompound tag = newStack.getTagCompound(); NBTTagCompound tag = newStack.getTagCompound();
int amount = getItemGhostAmount(ghostStack); int amount = getItemGhostAmount(ghostStack);
tag.removeTag(Constants.NBT.GHOST_STACK_SIZE); tag.removeTag(Constants.NBT.GHOST_STACK_SIZE);
if (tag.hasNoTags())
{
newStack.setTagCompound(null);
}
newStack.stackSize = amount; newStack.stackSize = amount;
return newStack; return newStack;