From 3a83b4ca8a07cc12fa2d0bd1476156021ecaacbb Mon Sep 17 00:00:00 2001 From: WayofTime Date: Sun, 4 Mar 2018 19:11:46 -0500 Subject: [PATCH] Increased the max number of items transferable by the Master Routing Node in its system to 64 per second. --- changelog.txt | 1 + .../tile/routing/TileMasterRoutingNode.java | 257 ++++++++++++------ 2 files changed, 172 insertions(+), 86 deletions(-) diff --git a/changelog.txt b/changelog.txt index 567608ca..775f13c4 100644 --- a/changelog.txt +++ b/changelog.txt @@ -5,6 +5,7 @@ Version 2.2.8 - It's a bright idea to fix this as soon as I can. - Changed the recipe of the Teleport Array: - Note from Scotty: Captain, I'll remind ya what happened last time you put an apple in her array! Use an Enderpearl and redstone dust next time! +- Increased the max number of items transferable by the Master Routing Node in its system to 64 per second. Will revisit this limit if I figure out a less silly upgrade system. ------------------------------------------------------ Version 2.2.7 diff --git a/src/main/java/WayofTime/bloodmagic/tile/routing/TileMasterRoutingNode.java b/src/main/java/WayofTime/bloodmagic/tile/routing/TileMasterRoutingNode.java index 250752bd..776901f4 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/routing/TileMasterRoutingNode.java +++ b/src/main/java/WayofTime/bloodmagic/tile/routing/TileMasterRoutingNode.java @@ -16,7 +16,8 @@ import net.minecraft.world.World; import java.util.*; import java.util.Map.Entry; -public class TileMasterRoutingNode extends TileInventory implements IMasterRoutingNode, ITickable { +public class TileMasterRoutingNode extends TileInventory implements IMasterRoutingNode, ITickable +{ public static final int tickRate = 20; private int currentInput; // A list of connections @@ -25,13 +26,16 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti private List outputNodeList = new LinkedList<>(); private List inputNodeList = new LinkedList<>(); - public TileMasterRoutingNode() { + public TileMasterRoutingNode() + { super(0, "masterRoutingNode"); } @Override - public void update() { - if (!getWorld().isRemote) { + public void update() + { + if (!getWorld().isRemote) + { // currentInput = getWorld().isBlockIndirectlyGettingPowered(pos); currentInput = getWorld().getStrongPower(pos); @@ -46,23 +50,31 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti Map> outputMap = new TreeMap<>(); Map> outputFluidMap = new TreeMap<>(); - for (BlockPos outputPos : outputNodeList) { + for (BlockPos outputPos : outputNodeList) + { TileEntity outputTile = getWorld().getTileEntity(outputPos); - if (this.isConnected(new LinkedList<>(), outputPos)) { - if (outputTile instanceof IOutputItemRoutingNode) { + if (this.isConnected(new LinkedList<>(), outputPos)) + { + if (outputTile instanceof IOutputItemRoutingNode) + { IOutputItemRoutingNode outputNode = (IOutputItemRoutingNode) outputTile; - for (EnumFacing facing : EnumFacing.VALUES) { - if (!outputNode.isInventoryConnectedToSide(facing) || !outputNode.isOutput(facing)) { + for (EnumFacing facing : EnumFacing.VALUES) + { + if (!outputNode.isInventoryConnectedToSide(facing) || !outputNode.isOutput(facing)) + { continue; } IItemFilter filter = outputNode.getOutputFilterForSide(facing); - if (filter != null) { + if (filter != null) + { int priority = outputNode.getPriority(facing); - if (outputMap.containsKey(priority)) { + if (outputMap.containsKey(priority)) + { outputMap.get(priority).add(filter); - } else { + } else + { List filterList = new LinkedList<>(); filterList.add(filter); outputMap.put(priority, filterList); @@ -71,20 +83,26 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti } } - if (outputTile instanceof IOutputFluidRoutingNode) { + if (outputTile instanceof IOutputFluidRoutingNode) + { IOutputFluidRoutingNode outputNode = (IOutputFluidRoutingNode) outputTile; - for (EnumFacing facing : EnumFacing.VALUES) { - if (!outputNode.isTankConnectedToSide(facing) || !outputNode.isFluidOutput(facing)) { + for (EnumFacing facing : EnumFacing.VALUES) + { + if (!outputNode.isTankConnectedToSide(facing) || !outputNode.isFluidOutput(facing)) + { continue; } IFluidFilter filter = outputNode.getOutputFluidFilterForSide(facing); - if (filter != null) { + if (filter != null) + { int priority = outputNode.getPriority(facing); - if (outputMap.containsKey(priority)) { + if (outputMap.containsKey(priority)) + { outputFluidMap.get(priority).add(filter); - } else { + } else + { List filterList = new LinkedList<>(); filterList.add(filter); outputFluidMap.put(priority, filterList); @@ -98,23 +116,31 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti Map> inputMap = new TreeMap<>(); Map> inputFluidMap = new TreeMap<>(); - for (BlockPos inputPos : inputNodeList) { + for (BlockPos inputPos : inputNodeList) + { TileEntity inputTile = getWorld().getTileEntity(inputPos); - if (this.isConnected(new LinkedList<>(), inputPos)) { - if (inputTile instanceof IInputItemRoutingNode) { + if (this.isConnected(new LinkedList<>(), inputPos)) + { + if (inputTile instanceof IInputItemRoutingNode) + { IInputItemRoutingNode inputNode = (IInputItemRoutingNode) inputTile; - for (EnumFacing facing : EnumFacing.VALUES) { - if (!inputNode.isInventoryConnectedToSide(facing) || !inputNode.isInput(facing)) { + for (EnumFacing facing : EnumFacing.VALUES) + { + if (!inputNode.isInventoryConnectedToSide(facing) || !inputNode.isInput(facing)) + { continue; } IItemFilter filter = inputNode.getInputFilterForSide(facing); - if (filter != null) { + if (filter != null) + { int priority = inputNode.getPriority(facing); - if (inputMap.containsKey(priority)) { + if (inputMap.containsKey(priority)) + { inputMap.get(priority).add(filter); - } else { + } else + { List filterList = new LinkedList<>(); filterList.add(filter); inputMap.put(priority, filterList); @@ -123,20 +149,26 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti } } - if (inputTile instanceof IInputFluidRoutingNode) { + if (inputTile instanceof IInputFluidRoutingNode) + { IInputFluidRoutingNode inputNode = (IInputFluidRoutingNode) inputTile; - for (EnumFacing facing : EnumFacing.VALUES) { - if (!inputNode.isTankConnectedToSide(facing) || !inputNode.isFluidInput(facing)) { + for (EnumFacing facing : EnumFacing.VALUES) + { + if (!inputNode.isTankConnectedToSide(facing) || !inputNode.isFluidInput(facing)) + { continue; } IFluidFilter filter = inputNode.getInputFluidFilterForSide(facing); - if (filter != null) { + if (filter != null) + { int priority = inputNode.getPriority(facing); - if (inputMap.containsKey(priority)) { + if (inputMap.containsKey(priority)) + { inputFluidMap.get(priority).add(filter); - } else { + } else + { List filterList = new LinkedList<>(); filterList.add(filter); inputFluidMap.put(priority, filterList); @@ -150,14 +182,19 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti int maxTransfer = this.getMaxTransferForDemonWill(WorldDemonWillHandler.getCurrentWill(getWorld(), pos, EnumDemonWillType.DEFAULT)); int maxFluidTransfer = 1000; - for (Entry> outputEntry : outputMap.entrySet()) { + for (Entry> outputEntry : outputMap.entrySet()) + { List outputList = outputEntry.getValue(); - for (IItemFilter outputFilter : outputList) { - for (Entry> inputEntry : inputMap.entrySet()) { + for (IItemFilter outputFilter : outputList) + { + for (Entry> inputEntry : inputMap.entrySet()) + { List inputList = inputEntry.getValue(); - for (IItemFilter inputFilter : inputList) { + for (IItemFilter inputFilter : inputList) + { maxTransfer -= inputFilter.transferThroughInputFilter(outputFilter, maxTransfer); - if (maxTransfer <= 0) { + if (maxTransfer <= 0) + { return; } } @@ -165,14 +202,19 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti } } - for (Entry> outputEntry : outputFluidMap.entrySet()) { + for (Entry> outputEntry : outputFluidMap.entrySet()) + { List outputList = outputEntry.getValue(); - for (IFluidFilter outputFilter : outputList) { - for (Entry> inputEntry : inputFluidMap.entrySet()) { + for (IFluidFilter outputFilter : outputList) + { + for (Entry> inputEntry : inputFluidMap.entrySet()) + { List inputList = inputEntry.getValue(); - for (IFluidFilter inputFilter : inputList) { + for (IFluidFilter inputFilter : inputList) + { maxFluidTransfer -= inputFilter.transferThroughInputFilter(outputFilter, maxFluidTransfer); - if (maxFluidTransfer <= 0) { + if (maxFluidTransfer <= 0) + { return; } } @@ -181,15 +223,18 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti } } - public int getMaxTransferForDemonWill(double will) { - return 8; + public int getMaxTransferForDemonWill(double will) + { + return 64; } @Override - public NBTTagCompound serialize(NBTTagCompound tag) { + public NBTTagCompound serialize(NBTTagCompound tag) + { super.serialize(tag); NBTTagList tags = new NBTTagList(); - for (BlockPos pos : generalNodeList) { + for (BlockPos pos : generalNodeList) + { NBTTagCompound posTag = new NBTTagCompound(); posTag.setInteger(Constants.NBT.X_COORD, pos.getX()); posTag.setInteger(Constants.NBT.Y_COORD, pos.getY()); @@ -199,7 +244,8 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti tag.setTag(Constants.NBT.ROUTING_MASTER_GENERAL, tags); tags = new NBTTagList(); - for (BlockPos pos : inputNodeList) { + for (BlockPos pos : inputNodeList) + { NBTTagCompound posTag = new NBTTagCompound(); posTag.setInteger(Constants.NBT.X_COORD, pos.getX()); posTag.setInteger(Constants.NBT.Y_COORD, pos.getY()); @@ -209,7 +255,8 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti tag.setTag(Constants.NBT.ROUTING_MASTER_INPUT, tags); tags = new NBTTagList(); - for (BlockPos pos : outputNodeList) { + for (BlockPos pos : outputNodeList) + { NBTTagCompound posTag = new NBTTagCompound(); posTag.setInteger(Constants.NBT.X_COORD, pos.getX()); posTag.setInteger(Constants.NBT.Y_COORD, pos.getY()); @@ -221,25 +268,29 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti } @Override - public void deserialize(NBTTagCompound tag) { + public void deserialize(NBTTagCompound tag) + { super.deserialize(tag); NBTTagList tags = tag.getTagList(Constants.NBT.ROUTING_MASTER_GENERAL, 10); - for (int i = 0; i < tags.tagCount(); i++) { + for (int i = 0; i < tags.tagCount(); i++) + { NBTTagCompound blockTag = tags.getCompoundTagAt(i); BlockPos newPos = new BlockPos(blockTag.getInteger(Constants.NBT.X_COORD), blockTag.getInteger(Constants.NBT.Y_COORD), blockTag.getInteger(Constants.NBT.Z_COORD)); generalNodeList.add(newPos); } tags = tag.getTagList(Constants.NBT.ROUTING_MASTER_INPUT, 10); - for (int i = 0; i < tags.tagCount(); i++) { + for (int i = 0; i < tags.tagCount(); i++) + { NBTTagCompound blockTag = tags.getCompoundTagAt(i); BlockPos newPos = new BlockPos(blockTag.getInteger(Constants.NBT.X_COORD), blockTag.getInteger(Constants.NBT.Y_COORD), blockTag.getInteger(Constants.NBT.Z_COORD)); inputNodeList.add(newPos); } tags = tag.getTagList(Constants.NBT.ROUTING_MASTER_OUTPUT, 10); - for (int i = 0; i < tags.tagCount(); i++) { + for (int i = 0; i < tags.tagCount(); i++) + { NBTTagCompound blockTag = tags.getCompoundTagAt(i); BlockPos newPos = new BlockPos(blockTag.getInteger(Constants.NBT.X_COORD), blockTag.getInteger(Constants.NBT.Y_COORD), blockTag.getInteger(Constants.NBT.Z_COORD)); outputNodeList.add(newPos); @@ -247,14 +298,16 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti } @Override - public boolean isConnected(List path, BlockPos nodePos) { + public boolean isConnected(List path, BlockPos nodePos) + { //TODO: Figure out how to make it so the path is obtained // if (!connectionMap.containsKey(nodePos)) // { // return false; // } TileEntity tile = getWorld().getTileEntity(nodePos); - if (!(tile instanceof IRoutingNode)) { + if (!(tile instanceof IRoutingNode)) + { // connectionMap.remove(nodePos); return false; } @@ -263,17 +316,22 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti List connectionList = node.getConnected(); // List testPath = path.subList(0, path.size()); path.add(nodePos); - for (BlockPos testPos : connectionList) { - if (path.contains(testPos)) { + for (BlockPos testPos : connectionList) + { + if (path.contains(testPos)) + { continue; } - if (testPos.equals(this.getPos()) && node.isConnectionEnabled(testPos)) { + if (testPos.equals(this.getPos()) && node.isConnectionEnabled(testPos)) + { // path.clear(); // path.addAll(testPath); return true; - } else if (NodeHelper.isNodeConnectionEnabled(getWorld(), node, testPos)) { - if (isConnected(path, testPos)) { + } else if (NodeHelper.isNodeConnectionEnabled(getWorld(), node, testPos)) + { + if (isConnected(path, testPos)) + { // path.clear(); // path.addAll(testPath); return true; @@ -285,44 +343,56 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti } @Override - public boolean isConnectionEnabled(BlockPos testPos) { + public boolean isConnectionEnabled(BlockPos testPos) + { return currentInput <= 0; } @Override - public void addNodeToList(IRoutingNode node) { + public void addNodeToList(IRoutingNode node) + { BlockPos newPos = node.getBlockPos(); - if (!generalNodeList.contains(newPos)) { + if (!generalNodeList.contains(newPos)) + { generalNodeList.add(newPos); } - if (node instanceof IInputItemRoutingNode && !inputNodeList.contains(newPos)) { + if (node instanceof IInputItemRoutingNode && !inputNodeList.contains(newPos)) + { inputNodeList.add(newPos); } - if (node instanceof IOutputItemRoutingNode && !outputNodeList.contains(newPos)) { + if (node instanceof IOutputItemRoutingNode && !outputNodeList.contains(newPos)) + { outputNodeList.add(newPos); } } @Override - public void addConnections(BlockPos pos, List connectionList) { - for (BlockPos testPos : connectionList) { + public void addConnections(BlockPos pos, List connectionList) + { + for (BlockPos testPos : connectionList) + { addConnection(pos, testPos); } } @Override - public void addConnection(BlockPos pos1, BlockPos pos2) { - if (connectionMap.containsKey(pos1) && !connectionMap.get(pos1).contains(pos2)) { + public void addConnection(BlockPos pos1, BlockPos pos2) + { + if (connectionMap.containsKey(pos1) && !connectionMap.get(pos1).contains(pos2)) + { connectionMap.get(pos1).add(pos2); - } else { + } else + { List list = new LinkedList<>(); list.add(pos2); connectionMap.put(pos1, list); } - if (connectionMap.containsKey(pos2) && !connectionMap.get(pos2).contains(pos1)) { + if (connectionMap.containsKey(pos2) && !connectionMap.get(pos2).contains(pos1)) + { connectionMap.get(pos2).add(pos1); - } else { + } else + { List list = new LinkedList<>(); list.add(pos1); connectionMap.put(pos2, list); @@ -330,69 +400,84 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti } @Override - public void removeConnection(BlockPos pos1, BlockPos pos2) { - if (connectionMap.containsKey(pos1)) { + public void removeConnection(BlockPos pos1, BlockPos pos2) + { + if (connectionMap.containsKey(pos1)) + { List posList = connectionMap.get(pos1); posList.remove(pos2); - if (posList.isEmpty()) { + if (posList.isEmpty()) + { connectionMap.remove(pos1); } } - if (connectionMap.containsKey(pos2)) { + if (connectionMap.containsKey(pos2)) + { List posList = connectionMap.get(pos2); posList.remove(pos1); - if (posList.isEmpty()) { + if (posList.isEmpty()) + { connectionMap.remove(pos2); } } } @Override - public void connectMasterToRemainingNode(World world, List alreadyChecked, IMasterRoutingNode master) { + public void connectMasterToRemainingNode(World world, List alreadyChecked, IMasterRoutingNode master) + { return; } @Override - public BlockPos getBlockPos() { + public BlockPos getBlockPos() + { return this.getPos(); } @Override - public List getConnected() { + public List getConnected() + { return new LinkedList<>(); } @Override - public BlockPos getMasterPos() { + public BlockPos getMasterPos() + { return this.getPos(); } @Override - public boolean isMaster(IMasterRoutingNode master) { + public boolean isMaster(IMasterRoutingNode master) + { return false; } @Override - public void addConnection(BlockPos pos1) { + public void addConnection(BlockPos pos1) + { // Empty } @Override - public void removeConnection(BlockPos pos1) { + public void removeConnection(BlockPos pos1) + { generalNodeList.remove(pos1); inputNodeList.remove(pos1); outputNodeList.remove(pos1); } @Override - public void removeAllConnections() { + public void removeAllConnections() + { List list = generalNodeList.subList(0, generalNodeList.size()); Iterator itr = list.iterator(); - while (itr.hasNext()) { + while (itr.hasNext()) + { BlockPos testPos = itr.next(); TileEntity tile = getWorld().getTileEntity(testPos); - if (tile instanceof IRoutingNode) { + if (tile instanceof IRoutingNode) + { ((IRoutingNode) tile).removeConnection(pos); getWorld().notifyBlockUpdate(getPos(), getWorld().getBlockState(testPos), getWorld().getBlockState(testPos), 3); }