Add resistance to MultiItems to prevent crashes from invalid stacks.
This commit is contained in:
+34
-24
@@ -209,12 +209,17 @@ public class Registration
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Field f = materialClass.getField( "material" + mat.name() );
|
if ( mat == MaterialType.InvalidType )
|
||||||
ItemStackSrc is = ((ItemMultiMaterial) materialItem.item()).createMaterial( mat );
|
((ItemMultiMaterial) materialItem.item()).createMaterial( mat );
|
||||||
if ( is != null )
|
|
||||||
f.set( materials, new DamagedItemDefinition( is ) );
|
|
||||||
else
|
else
|
||||||
f.set( materials, new NullItemDefinition() );
|
{
|
||||||
|
Field f = materialClass.getField( "material" + mat.name() );
|
||||||
|
ItemStackSrc is = ((ItemMultiMaterial) materialItem.item()).createMaterial( mat );
|
||||||
|
if ( is != null )
|
||||||
|
f.set( materials, new DamagedItemDefinition( is ) );
|
||||||
|
else
|
||||||
|
f.set( materials, new NullItemDefinition() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Throwable err)
|
catch (Throwable err)
|
||||||
{
|
{
|
||||||
@@ -230,30 +235,35 @@ public class Registration
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Field f = partClass.getField( "part" + type.name() );
|
if ( type == PartType.InvalidType )
|
||||||
Enum varients[] = type.getVarients();
|
((ItemMultiPart) partItem.item()).createPart( type, null );
|
||||||
if ( varients == null )
|
|
||||||
{
|
|
||||||
ItemStackSrc is = ((ItemMultiPart) partItem.item()).createPart( type, null );
|
|
||||||
if ( is != null )
|
|
||||||
f.set( parts, new DamagedItemDefinition( is ) );
|
|
||||||
else
|
|
||||||
f.set( parts, new NullItemDefinition() );
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( varients[0] instanceof AEColor )
|
Field f = partClass.getField( "part" + type.name() );
|
||||||
|
Enum varients[] = type.getVarients();
|
||||||
|
if ( varients == null )
|
||||||
{
|
{
|
||||||
ColoredItemDefinition def = new ColoredItemDefinition();
|
ItemStackSrc is = ((ItemMultiPart) partItem.item()).createPart( type, null );
|
||||||
|
if ( is != null )
|
||||||
for (Enum v : varients)
|
f.set( parts, new DamagedItemDefinition( is ) );
|
||||||
|
else
|
||||||
|
f.set( parts, new NullItemDefinition() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( varients[0] instanceof AEColor )
|
||||||
{
|
{
|
||||||
ItemStackSrc is = ((ItemMultiPart) partItem.item()).createPart( type, v );
|
ColoredItemDefinition def = new ColoredItemDefinition();
|
||||||
if ( is != null )
|
|
||||||
def.add( (AEColor) v, is );
|
|
||||||
}
|
|
||||||
|
|
||||||
f.set( parts, def );
|
for (Enum v : varients)
|
||||||
|
{
|
||||||
|
ItemStackSrc is = ((ItemMultiPart) partItem.item()).createPart( type, v );
|
||||||
|
if ( is != null )
|
||||||
|
def.add( (AEColor) v, is );
|
||||||
|
}
|
||||||
|
|
||||||
|
f.set( parts, def );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
|||||||
{
|
{
|
||||||
if ( dmgToMaterial.containsKey( is.getItemDamage() ) )
|
if ( dmgToMaterial.containsKey( is.getItemDamage() ) )
|
||||||
return dmgToMaterial.get( is.getItemDamage() );
|
return dmgToMaterial.get( is.getItemDamage() );
|
||||||
return null;
|
return MaterialType.InvalidType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||||||
|
|
||||||
public enum MaterialType
|
public enum MaterialType
|
||||||
{
|
{
|
||||||
|
InvalidType(-1, AEFeature.Core),
|
||||||
|
|
||||||
CertusQuartzCrystal(0, AEFeature.Core, "crystalCertusQuartz"), CertusQuartzCrystalCharged(1, AEFeature.Core, EntityChargedQuartz.class),
|
CertusQuartzCrystal(0, AEFeature.Core, "crystalCertusQuartz"), CertusQuartzCrystalCharged(1, AEFeature.Core, EntityChargedQuartz.class),
|
||||||
|
|
||||||
CertusQuartzDust(2, AEFeature.Core, "dustCertusQuartz"), NetherQuartzDust(3, AEFeature.Core, "dustNetherQuartz"), Flour(4, AEFeature.Flour, "dustWheat"), GoldDust(
|
CertusQuartzDust(2, AEFeature.Core, "dustCertusQuartz"), NetherQuartzDust(3, AEFeature.Core, "dustNetherQuartz"), Flour(4, AEFeature.Flour, "dustWheat"), GoldDust(
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ import appeng.parts.reporting.PartTerminal;
|
|||||||
|
|
||||||
public enum PartType
|
public enum PartType
|
||||||
{
|
{
|
||||||
|
InvalidType(-1, AEFeature.Core, null),
|
||||||
|
|
||||||
CableGlass(0, AEFeature.Core, PartCableGlass.class),
|
CableGlass(0, AEFeature.Core, PartCableGlass.class),
|
||||||
|
|
||||||
CableCovered(20, AEFeature.Core, PartCableCovered.class),
|
CableCovered(20, AEFeature.Core, PartCableCovered.class),
|
||||||
|
|||||||
Reference in New Issue
Block a user