Cache Part Constructor.

This commit is contained in:
AlgorithmX2
2014-08-28 03:37:43 -05:00
parent 16c7369589
commit cdaac3baa0
2 changed files with 9 additions and 1 deletions
+6 -1
View File
@@ -191,7 +191,12 @@ public class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup
{ {
PartType t = getTypeByStack( is ); PartType t = getTypeByStack( is );
if ( t != null ) if ( t != null )
return t.getPart().getConstructor( ItemStack.class ).newInstance( is ); {
if ( t.constructor == null )
t.constructor = t.getPart().getConstructor( ItemStack.class );
return t.constructor.newInstance( is );
}
} }
catch (Throwable e) catch (Throwable e)
{ {
+3
View File
@@ -1,5 +1,6 @@
package appeng.items.parts; package appeng.items.parts;
import java.lang.reflect.Constructor;
import java.util.EnumSet; import java.util.EnumSet;
import appeng.api.parts.IPart; import appeng.api.parts.IPart;
@@ -112,6 +113,8 @@ public enum PartType
private final GuiText extraName; private final GuiText extraName;
public final int baseDamage; public final int baseDamage;
public Constructor<? extends IPart> constructor;
PartType(int baseMetaValue, AEFeature part, Class<? extends IPart> c) { PartType(int baseMetaValue, AEFeature part, Class<? extends IPart> c) {
this( baseMetaValue, part, c, null ); this( baseMetaValue, part, c, null );
} }