From f3a9a12e04a2104eda1d6dec7f440debb2aa020b Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Mon, 11 Aug 2014 22:56:57 -0500 Subject: [PATCH] Fixed a crash when dealing with large ore dictionary registrations. --- util/item/ItemList.java | 6 +++--- util/item/OreHelper.java | 14 +++----------- util/item/OreRefrence.java | 20 ++++++++++++++++---- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/util/item/ItemList.java b/util/item/ItemList.java index e74f7b624..31b3b4114 100644 --- a/util/item/ItemList.java +++ b/util/item/ItemList.java @@ -207,16 +207,16 @@ public final class ItemList implements IItemList output = new LinkedList(); - for (IAEItemStack is : or.aeotherOptions) + for (IAEItemStack is : or.getAEEquivilients()) output.addAll( findFuzzyDamage( (AEItemStack) is, fuzzy, is.getItemDamage() == OreDictionary.WILDCARD_VALUE ) ); return output; diff --git a/util/item/OreHelper.java b/util/item/OreHelper.java index dcc05341a..1d8494f58 100644 --- a/util/item/OreHelper.java +++ b/util/item/OreHelper.java @@ -68,7 +68,6 @@ public class OreHelper OreRefrence ref = new OreRefrence(); Collection ores = ref.getOres(); Collection set = ref.getEquivilients(); - Collection aeset = ref.getAEEquivilients(); for (String ore : OreDictionary.getOreNames()) { @@ -93,14 +92,7 @@ public class OreHelper } if ( !set.isEmpty() ) - { or.oreValue = ref; - - // SUMMON AE STACKS! - for (ItemStack is : set) - if ( is.getItem() != null ) - aeset.add( AEItemStack.create( is ) ); - } } return or.oreValue; @@ -118,7 +110,7 @@ public class OreHelper return false; Collection bOres = b.getOres(); - for (Integer ore : a.ores) + for (Integer ore : a.getOres()) { if ( bOres.contains( ore ) ) return true; @@ -134,9 +126,9 @@ public class OreHelper if ( a == b ) return true; - + Collection bOres = b.getOres(); - for (Integer ore : a.ores) + for (Integer ore : a.getOres()) { if ( bOres.contains( ore ) ) return true; diff --git a/util/item/OreRefrence.java b/util/item/OreRefrence.java index c0fe8b0a2..44ff451a7 100644 --- a/util/item/OreRefrence.java +++ b/util/item/OreRefrence.java @@ -1,8 +1,10 @@ package appeng.util.item; +import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.LinkedList; +import java.util.List; import net.minecraft.item.ItemStack; import appeng.api.storage.data.IAEItemStack; @@ -10,17 +12,27 @@ import appeng.api.storage.data.IAEItemStack; public class OreRefrence { - LinkedList otherOptions = new LinkedList(); - LinkedList aeotherOptions = new LinkedList(); - HashSet ores = new HashSet(); + private LinkedList otherOptions = new LinkedList(); + private ArrayList aeotherOptions = null; + private HashSet ores = new HashSet(); public Collection getEquivilients() { return otherOptions; } - public Collection getAEEquivilients() + public List 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; }