Fixed a crash when dealing with large ore dictionary registrations.

This commit is contained in:
AlgorithmX2 2014-08-11 22:56:57 -05:00
parent feb7d7be95
commit f3a9a12e04
3 changed files with 22 additions and 18 deletions

View file

@ -207,16 +207,16 @@ public final class ItemList<StackType extends IAEStack> implements IItemList<Sta
if ( ais.isOre() ) if ( ais.isOre() )
{ {
OreRefrence or = ais.def.isOre; OreRefrence or = ais.def.isOre;
if ( or.aeotherOptions.size() == 1 ) if ( or.getAEEquivilients().size() == 1 )
{ {
IAEItemStack is = or.aeotherOptions.get( 0 ); IAEItemStack is = or.getAEEquivilients().get( 0 );
return findFuzzyDamage( (AEItemStack) is, fuzzy, is.getItemDamage() == OreDictionary.WILDCARD_VALUE ); return findFuzzyDamage( (AEItemStack) is, fuzzy, is.getItemDamage() == OreDictionary.WILDCARD_VALUE );
} }
else else
{ {
Collection<StackType> output = new LinkedList(); Collection<StackType> output = new LinkedList();
for (IAEItemStack is : or.aeotherOptions) for (IAEItemStack is : or.getAEEquivilients())
output.addAll( findFuzzyDamage( (AEItemStack) is, fuzzy, is.getItemDamage() == OreDictionary.WILDCARD_VALUE ) ); output.addAll( findFuzzyDamage( (AEItemStack) is, fuzzy, is.getItemDamage() == OreDictionary.WILDCARD_VALUE ) );
return output; return output;

View file

@ -68,7 +68,6 @@ public class OreHelper
OreRefrence ref = new OreRefrence(); OreRefrence ref = new OreRefrence();
Collection<Integer> ores = ref.getOres(); Collection<Integer> ores = ref.getOres();
Collection<ItemStack> set = ref.getEquivilients(); Collection<ItemStack> set = ref.getEquivilients();
Collection<IAEItemStack> aeset = ref.getAEEquivilients();
for (String ore : OreDictionary.getOreNames()) for (String ore : OreDictionary.getOreNames())
{ {
@ -93,14 +92,7 @@ public class OreHelper
} }
if ( !set.isEmpty() ) if ( !set.isEmpty() )
{
or.oreValue = ref; or.oreValue = ref;
// SUMMON AE STACKS!
for (ItemStack is : set)
if ( is.getItem() != null )
aeset.add( AEItemStack.create( is ) );
}
} }
return or.oreValue; return or.oreValue;
@ -118,7 +110,7 @@ public class OreHelper
return false; return false;
Collection<Integer> bOres = b.getOres(); Collection<Integer> bOres = b.getOres();
for (Integer ore : a.ores) for (Integer ore : a.getOres())
{ {
if ( bOres.contains( ore ) ) if ( bOres.contains( ore ) )
return true; return true;
@ -134,9 +126,9 @@ public class OreHelper
if ( a == b ) if ( a == b )
return true; return true;
Collection<Integer> bOres = b.getOres(); Collection<Integer> bOres = b.getOres();
for (Integer ore : a.ores) for (Integer ore : a.getOres())
{ {
if ( bOres.contains( ore ) ) if ( bOres.contains( ore ) )
return true; return true;

View file

@ -1,8 +1,10 @@
package appeng.util.item; package appeng.util.item;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
@ -10,17 +12,27 @@ import appeng.api.storage.data.IAEItemStack;
public class OreRefrence public class OreRefrence
{ {
LinkedList<ItemStack> otherOptions = new LinkedList(); private LinkedList<ItemStack> otherOptions = new LinkedList();
LinkedList<IAEItemStack> aeotherOptions = new LinkedList(); private ArrayList aeotherOptions = null;
HashSet<Integer> ores = new HashSet<Integer>(); private HashSet<Integer> ores = new HashSet<Integer>();
public Collection<ItemStack> getEquivilients() public Collection<ItemStack> getEquivilients()
{ {
return otherOptions; return otherOptions;
} }
public Collection<IAEItemStack> getAEEquivilients() public List<IAEItemStack> getAEEquivilients()
{ {
if ( aeotherOptions == null )
{
aeotherOptions = new ArrayList( otherOptions.size() );
// SUMMON AE STACKS!
for (ItemStack is : otherOptions)
if ( is.getItem() != null )
aeotherOptions.add( AEItemStack.create( is ) );
}
return aeotherOptions; return aeotherOptions;
} }