Fix crash when splitting inventories

This commit is contained in:
Aidan Brady 2013-08-04 19:21:59 -04:00
parent c95031de2e
commit b4028d8fcb
3 changed files with 11 additions and 13 deletions

View file

@ -70,7 +70,12 @@ public class SetUtil
int remain = set.size()%divide;
int size = (set.size()/divide)-remain;
ArrayList<Set<V>> toReturn = new ArrayList<Set<V>>(divide);
ArrayList<Set<V>> toReturn = new ArrayList<Set<V>>();
for(int i = 0; i < divide; i++)
{
toReturn.add(i, new HashSet<V>());
}
for(Set<V> iterSet : toReturn)
{
@ -105,8 +110,8 @@ public class SetUtil
return toReturn;
}
public static <V> ArrayList<V> asList(Set<V> set)
public static <V> List<V> asList(Set<V> set)
{
return (ArrayList<V>)Arrays.asList(set.toArray());
return (List<V>)Arrays.asList(set.toArray());
}
}

View file

@ -2,6 +2,7 @@ package resonantinduction.battery;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.minecraft.item.ItemStack;
@ -217,7 +218,7 @@ public class BatteryUpdateProtocol
if(oldStructure != null)
{
ArrayList<Set<ItemStack>> inventories = SetUtil.split(oldStructure.inventory, iteratedNodes.size());
ArrayList<TileEntityBattery> iterList = SetUtil.asList(iteratedNodes);
List<TileEntityBattery> iterList = SetUtil.asList(iteratedNodes);
for(int i = 0; i < iterList.size(); i++)
{

View file

@ -39,17 +39,9 @@ public class TileEntityBattery extends TileEntityBase implements IPacketReceiver
ticks++;
if(worldObj.isRemote)
{
if(structure == null)
{
structure = new SynchronizedBatteryData();
}
}
if(!worldObj.isRemote)
{
if(ticks == 5)
if(ticks == 5 && !structure.isMultiblock)
{
update();
}