Fixes #1331: Happened on deactivating features for intermediate crafting components

If a feature dependency of ItemMultiMaterial was disabled, the returned value was never assigned with the constructed. Pulling out the construction and setting it before checking it, prevents the NPE and also matches the behaviour in ItemMultiPart, where parts are constructed, but never registered.
This commit is contained in:
thatsIch
2015-04-26 09:57:42 +02:00
parent ee431b3269
commit 03f9436ef9
11 changed files with 108 additions and 58 deletions
@@ -63,6 +63,8 @@ import appeng.items.AEBaseItem;
public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup
{
private static final Comparator<Entry<Integer, PartTypeWithVariant>> REGISTERED_COMPARATOR = new RegisteredComparator();
public static ItemMultiPart instance;
private final NameResolver nameResolver;
private final Map<Integer, PartTypeWithVariant> registered;
@@ -216,15 +218,7 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG
public void getSubItems( Item number, CreativeTabs tab, List cList )
{
List<Entry<Integer, PartTypeWithVariant>> types = new ArrayList<Entry<Integer, PartTypeWithVariant>>( this.registered.entrySet() );
Collections.sort( types, new Comparator<Entry<Integer, PartTypeWithVariant>>()
{
@Override
public int compare( Entry<Integer, PartTypeWithVariant> o1, Entry<Integer, PartTypeWithVariant> o2 )
{
return o1.getValue().part.name().compareTo( o2.getValue().part.name() );
}
} );
Collections.sort( types, REGISTERED_COMPARATOR );
for( Entry<Integer, PartTypeWithVariant> part : types )
{
@@ -375,4 +369,13 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG
this.variant = variant;
}
}
private static final class RegisteredComparator implements Comparator<Entry<Integer, PartTypeWithVariant>>
{
@Override
public int compare( Entry<Integer, PartTypeWithVariant> o1, Entry<Integer, PartTypeWithVariant> o2 )
{
return o1.getValue().part.name().compareTo( o2.getValue().part.name() );
}
}
}