A bit of work on logistics

This commit is contained in:
Aidan Brady 2013-08-04 22:05:35 -04:00
parent ab02a09159
commit a26a698b4b
2 changed files with 31 additions and 0 deletions

View file

@ -98,6 +98,36 @@ public class SetUtil
return newSet;
}
public static <V> Set<V> capRemains(Set<V> set, int cap)
{
Set<V> toReturn = new HashSet<V>();
if(set.size() <= cap)
{
return toReturn;
}
else {
Set<V> 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.

View file

@ -219,6 +219,7 @@ public class BatteryUpdateProtocol
{
ArrayList<Set<ItemStack>> inventories = SetUtil.split(oldStructure.inventory, iteratedNodes.size());
List<TileEntityBattery> iterList = SetUtil.asList(iteratedNodes);
boolean didVisibleInventory = false;
for(int i = 0; i < iterList.size(); i++)