diff --git a/src/main/java/appeng/me/storage/CellInventory.java b/src/main/java/appeng/me/storage/CellInventory.java index e0a6292c1..e766f2962 100644 --- a/src/main/java/appeng/me/storage/CellInventory.java +++ b/src/main/java/appeng/me/storage/CellInventory.java @@ -27,6 +27,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.oredict.OreDictionary; + import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.config.FuzzyMode; @@ -418,7 +419,7 @@ public class CellInventory implements ICellInventory } // clean any old crusty stuff... - for(; x < oldStoredItems && x < this.maxItemTypes; x++ ) + for( ; x < oldStoredItems && x < this.maxItemTypes; x++ ) { this.tagCompound.removeTag( itemSlots[x] ); this.tagCompound.removeTag( itemSlotCount[x] ); diff --git a/src/main/java/appeng/util/item/ItemList.java b/src/main/java/appeng/util/item/ItemList.java index 4feb5c68c..640d2d8f0 100644 --- a/src/main/java/appeng/util/item/ItemList.java +++ b/src/main/java/appeng/util/item/ItemList.java @@ -21,14 +21,11 @@ package appeng.util.item; import java.util.Collection; import java.util.Collections; -import java.util.IdentityHashMap; import java.util.Iterator; import java.util.LinkedList; -import java.util.Map; import java.util.NavigableMap; import java.util.concurrent.ConcurrentSkipListMap; -import net.minecraft.item.Item; import net.minecraftforge.oredict.OreDictionary; import appeng.api.config.FuzzyMode; import appeng.api.storage.data.IAEItemStack; @@ -40,7 +37,7 @@ import com.google.common.collect.Lists; public final class ItemList implements IItemList { - private final Map> records = new IdentityHashMap>(); + private final NavigableMap records = new ConcurrentSkipListMap(); @Override public void add( final IAEItemStack option ) @@ -50,7 +47,7 @@ public final class ItemList implements IItemList return; } - final IAEItemStack st = this.getItemRecord( option.getItem() ).get( option ); + final IAEItemStack st = this.records.get( option ); if( st != null ) { @@ -71,7 +68,7 @@ public final class ItemList implements IItemList return null; } - return this.getItemRecord( itemStack.getItem() ).get( itemStack ); + return this.records.get( itemStack ); } @Override @@ -124,7 +121,7 @@ public final class ItemList implements IItemList return; } - final IAEItemStack st = this.getItemRecord( option.getItem() ).get( option ); + final IAEItemStack st = this.records.get( option ); if( st != null ) { @@ -150,7 +147,7 @@ public final class ItemList implements IItemList return; } - final IAEItemStack st = this.getItemRecord( option.getItem() ).get( option ); + final IAEItemStack st = this.records.get( option ); if( st != null ) { @@ -173,7 +170,7 @@ public final class ItemList implements IItemList return; } - final IAEItemStack st = this.getItemRecord( option.getItem() ).get( option ); + final IAEItemStack st = this.records.get( option ); if( st != null ) { @@ -203,14 +200,7 @@ public final class ItemList implements IItemList @Override public int size() { - int size = 0; - - for( final Map element : this.records.values() ) - { - size += element.size(); - } - - return size; + return this.records.size(); } @Override @@ -228,22 +218,9 @@ public final class ItemList implements IItemList } } - private NavigableMap getItemRecord( final Item item ) - { - NavigableMap itemRecords = this.records.get( item ); - - if( itemRecords == null ) - { - itemRecords = new ConcurrentSkipListMap(); - this.records.put( item, itemRecords ); - } - - return itemRecords; - } - private IAEItemStack putItemRecord( final IAEItemStack itemStack ) { - return this.getItemRecord( itemStack.getItem() ).put( itemStack, itemStack ); + return this.records.put( itemStack, itemStack ); } private Collection findFuzzyDamage( final AEItemStack filter, final FuzzyMode fuzzy, final boolean ignoreMeta ) @@ -251,6 +228,6 @@ public final class ItemList implements IItemList final IAEItemStack low = filter.getLow( fuzzy, ignoreMeta ); final IAEItemStack high = filter.getHigh( fuzzy, ignoreMeta ); - return this.getItemRecord( filter.getItem() ).subMap( low, true, high, true ).descendingMap().values(); + return this.records.subMap( low, true, high, true ).descendingMap().values(); } } diff --git a/src/main/java/appeng/util/item/MeaningfulItemIterator.java b/src/main/java/appeng/util/item/MeaningfulItemIterator.java index 94d389cbe..7d7c8b016 100644 --- a/src/main/java/appeng/util/item/MeaningfulItemIterator.java +++ b/src/main/java/appeng/util/item/MeaningfulItemIterator.java @@ -20,7 +20,6 @@ package appeng.util.item; import java.util.Iterator; -import java.util.NavigableMap; import java.util.NoSuchElementException; import appeng.api.storage.data.IAEItemStack; @@ -29,47 +28,28 @@ import appeng.api.storage.data.IAEItemStack; public class MeaningfulItemIterator implements Iterator { - private final Iterator> parent; - private Iterator innerIterater = null; + private final Iterator parent; private T next; - public MeaningfulItemIterator( final Iterator> iterator ) + public MeaningfulItemIterator( final Iterator iterator ) { this.parent = iterator; - - if( this.parent.hasNext() ) - { - this.innerIterater = this.parent.next().values().iterator(); - } } @Override public boolean hasNext() { - if( this.innerIterater == null ) + while( this.parent.hasNext() ) { - return false; - } + this.next = this.parent.next(); - while( this.innerIterater.hasNext() || this.parent.hasNext() ) - { - if( this.innerIterater.hasNext() ) + if( this.next.isMeaningful() ) { - this.next = this.innerIterater.next(); - - if( this.next.isMeaningful() ) - { - return true; - } - else - { - this.innerIterater.remove(); // self cleaning :3 - } + return true; } - - if( this.parent.hasNext() ) + else { - this.innerIterater = this.parent.next().values().iterator(); + this.parent.remove(); // self cleaning :3 } }