From ba761aaa298090d0244c6e07a590aae9a47a6487 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Wed, 4 Jun 2014 00:02:57 -0500 Subject: [PATCH 1/3] Improved Part API Errors. --- core/api/ApiPart.java | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/core/api/ApiPart.java b/core/api/ApiPart.java index a40740268..25db2945f 100644 --- a/core/api/ApiPart.java +++ b/core/api/ApiPart.java @@ -97,13 +97,20 @@ public class ApiPart implements IPartHelper public ClassNode getReader(String name) throws IOException { - ClassReader cr; - String path = "/" + name.replace( ".", "/" ) + ".class"; - InputStream is = getClass().getResourceAsStream( path ); - cr = new ClassReader( is ); - ClassNode cn = new ClassNode(); - cr.accept( cn, ClassReader.EXPAND_FRAMES ); - return cn; + try + { + ClassReader cr; + String path = "/" + name.replace( ".", "/" ) + ".class"; + InputStream is = getClass().getResourceAsStream( path ); + cr = new ClassReader( is ); + ClassNode cn = new ClassNode(); + cr.accept( cn, ClassReader.EXPAND_FRAMES ); + return cn; + } + catch (Throwable t) + { + throw new RuntimeException( "Error loading " + name, t ); + } } public Class getCombinedInstance(String base) @@ -167,6 +174,7 @@ public class ApiPart implements IPartHelper } catch (Throwable t) { + AELog.warning( "Error loading " + name ); AELog.error( t ); // throw new RuntimeException( t ); } From 286baaa0a57d457cdbd8df222b4d33c9af4f29f8 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Wed, 4 Jun 2014 00:06:20 -0500 Subject: [PATCH 2/3] Fied Bug: #0482 - Class not found (asm) on build 16 & 17 --- integration/modules/BC.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/modules/BC.java b/integration/modules/BC.java index 020079bd6..0e0f9f6c6 100644 --- a/integration/modules/BC.java +++ b/integration/modules/BC.java @@ -205,7 +205,7 @@ public class BC extends BaseModule implements IBC @Override public void Init() { - AEApi.instance().partHelper().registerNewLayer( "appeng.api.parts.layers.LayerIPipeConnection", "buildcraft.api.transport.IPipeConnection" ); + AEApi.instance().partHelper().registerNewLayer( "appeng.parts.layers.LayerIPipeConnection", "buildcraft.api.transport.IPipeConnection" ); AEApi.instance().registries().externalStorage().addExternalStorageInterface( new BCPipeHandler() ); Blocks b = AEApi.instance().blocks(); From f894d483286086a9486ad2b8249331fea2fe156d Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Wed, 4 Jun 2014 00:07:36 -0500 Subject: [PATCH 3/3] Add resistance to MultiItems to prevent crashes from invalid stacks. --- core/Registration.java | 58 +++++++++++++++----------- items/materials/ItemMultiMaterial.java | 2 +- items/materials/MaterialType.java | 2 + items/parts/PartType.java | 2 + 4 files changed, 39 insertions(+), 25 deletions(-) diff --git a/core/Registration.java b/core/Registration.java index 6401a32e8..2b0d42396 100644 --- a/core/Registration.java +++ b/core/Registration.java @@ -209,12 +209,17 @@ public class Registration { try { - Field f = materialClass.getField( "material" + mat.name() ); - ItemStackSrc is = ((ItemMultiMaterial) materialItem.item()).createMaterial( mat ); - if ( is != null ) - f.set( materials, new DamagedItemDefinition( is ) ); + if ( mat == MaterialType.InvalidType ) + ((ItemMultiMaterial) materialItem.item()).createMaterial( mat ); 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) { @@ -230,30 +235,35 @@ public class Registration { try { - Field f = partClass.getField( "part" + type.name() ); - Enum varients[] = type.getVarients(); - 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() ); - } + if ( type == PartType.InvalidType ) + ((ItemMultiPart) partItem.item()).createPart( type, null ); else { - if ( varients[0] instanceof AEColor ) + Field f = partClass.getField( "part" + type.name() ); + Enum varients[] = type.getVarients(); + if ( varients == null ) { - ColoredItemDefinition def = new ColoredItemDefinition(); - - for (Enum v : varients) + ItemStackSrc is = ((ItemMultiPart) partItem.item()).createPart( type, null ); + if ( is != null ) + 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 ); - if ( is != null ) - def.add( (AEColor) v, is ); - } + ColoredItemDefinition def = new ColoredItemDefinition(); - 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 ); + } } } } diff --git a/items/materials/ItemMultiMaterial.java b/items/materials/ItemMultiMaterial.java index dd11c3428..5fe0a45aa 100644 --- a/items/materials/ItemMultiMaterial.java +++ b/items/materials/ItemMultiMaterial.java @@ -166,7 +166,7 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, { if ( dmgToMaterial.containsKey( is.getItemDamage() ) ) return dmgToMaterial.get( is.getItemDamage() ); - return null; + return MaterialType.InvalidType; } @Override diff --git a/items/materials/MaterialType.java b/items/materials/MaterialType.java index af1a9acf5..4cd82688c 100644 --- a/items/materials/MaterialType.java +++ b/items/materials/MaterialType.java @@ -17,6 +17,8 @@ import cpw.mods.fml.relauncher.SideOnly; public enum MaterialType { + InvalidType(-1, AEFeature.Core), + 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( diff --git a/items/parts/PartType.java b/items/parts/PartType.java index 5a17dbebd..503401f8c 100644 --- a/items/parts/PartType.java +++ b/items/parts/PartType.java @@ -39,6 +39,8 @@ import appeng.parts.reporting.PartTerminal; public enum PartType { + InvalidType(-1, AEFeature.Core, null), + CableGlass(0, AEFeature.Core, PartCableGlass.class), CableCovered(20, AEFeature.Core, PartCableCovered.class),