diff --git a/src/resonantinduction/base/SetUtil.java b/src/resonantinduction/base/SetUtil.java index 740ff1ec..b9dce3c9 100644 --- a/src/resonantinduction/base/SetUtil.java +++ b/src/resonantinduction/base/SetUtil.java @@ -98,6 +98,36 @@ public class SetUtil return newSet; } + + public static Set capRemains(Set set, int cap) + { + Set toReturn = new HashSet(); + + if(set.size() <= cap) + { + return toReturn; + } + else { + Set inverse = inverse(set); + + int iterNeeded = set.size()-cap; + int count = 0; + + for(V obj : set) + { + count++; + + toReturn.add(obj); + + if(count == iterNeeded) + { + break; + } + } + + return toReturn; + } + } /** * Splits a set into the defined amount of new sets, and returns them in an ArrayList. diff --git a/src/resonantinduction/battery/BatteryUpdateProtocol.java b/src/resonantinduction/battery/BatteryUpdateProtocol.java index a30c459c..221f084b 100644 --- a/src/resonantinduction/battery/BatteryUpdateProtocol.java +++ b/src/resonantinduction/battery/BatteryUpdateProtocol.java @@ -219,6 +219,7 @@ public class BatteryUpdateProtocol { ArrayList> inventories = SetUtil.split(oldStructure.inventory, iteratedNodes.size()); List iterList = SetUtil.asList(iteratedNodes); + boolean didVisibleInventory = false; for(int i = 0; i < iterList.size(); i++)