Replace Non created materials/parts with null item definitions instead of null.

This commit is contained in:
AlgorithmX2
2014-01-28 14:20:19 -06:00
parent 1a95fb5b0e
commit c40d6937d6
2 changed files with 49 additions and 1 deletions
+6
View File
@@ -67,6 +67,7 @@ import appeng.core.features.AEFeatureHandler;
import appeng.core.features.ColoredItemDefinition; import appeng.core.features.ColoredItemDefinition;
import appeng.core.features.DamagedItemDefinition; import appeng.core.features.DamagedItemDefinition;
import appeng.core.features.IAEFeature; import appeng.core.features.IAEFeature;
import appeng.core.features.NullItemDefinition;
import appeng.core.features.registries.P2PTunnelRegistry; import appeng.core.features.registries.P2PTunnelRegistry;
import appeng.core.features.registries.entries.BasicCellHandler; import appeng.core.features.registries.entries.BasicCellHandler;
import appeng.core.features.registries.entries.CreativeCellHandler; import appeng.core.features.registries.entries.CreativeCellHandler;
@@ -156,7 +157,10 @@ public class Registration
{ {
Field f = materialClass.getField( "material" + mat.name() ); Field f = materialClass.getField( "material" + mat.name() );
ItemStack is = ((ItemMaterial) materialItem.item()).createMaterial( mat ); ItemStack is = ((ItemMaterial) materialItem.item()).createMaterial( mat );
if ( is != null )
f.set( materials, new DamagedItemDefinition( is ) ); f.set( materials, new DamagedItemDefinition( is ) );
else
f.set( parts, new NullItemDefinition() );
} }
catch (Throwable err) catch (Throwable err)
{ {
@@ -179,6 +183,8 @@ public class Registration
ItemStack is = ((ItemPart) partItem.item()).createPart( type, null ); ItemStack is = ((ItemPart) partItem.item()).createPart( type, null );
if ( is != null ) if ( is != null )
f.set( parts, new DamagedItemDefinition( is ) ); f.set( parts, new DamagedItemDefinition( is ) );
else
f.set( parts, new NullItemDefinition() );
} }
else else
{ {
+42
View File
@@ -0,0 +1,42 @@
package appeng.core.features;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import appeng.api.util.AEItemDefinition;
public class NullItemDefinition implements AEItemDefinition
{
@Override
public Block block()
{
return null;
}
@Override
public Item item()
{
return null;
}
@Override
public Class<? extends TileEntity> entity()
{
return null;
}
@Override
public ItemStack stack(int stackSize)
{
return null;
}
@Override
public boolean sameAs(ItemStack comparableItem)
{
return false;
}
}