diff --git a/src/main/java/appeng/core/Registration.java b/src/main/java/appeng/core/Registration.java index 6181a231..cb910226 100644 --- a/src/main/java/appeng/core/Registration.java +++ b/src/main/java/appeng/core/Registration.java @@ -118,6 +118,7 @@ import appeng.core.features.AEFeature; import appeng.core.features.ColoredItemDefinition; import appeng.core.features.DamagedItemDefinition; import appeng.core.features.IAEFeature; +import appeng.core.features.IFeatureHandler; import appeng.core.features.IStackSrc; import appeng.core.features.ItemStackSrc; import appeng.core.features.NullItemDefinition; @@ -506,26 +507,33 @@ public class Registration private AEItemDefinition addFeature( Class featureClass, Object... args ) { - ClassInstantiation instantiation = new ClassInstantiation( featureClass, args ); - Optional instance = instantiation.get(); + final ClassInstantiation instantiation = new ClassInstantiation( featureClass, args ); + final Optional instance = instantiation.get(); if ( instance.isPresent() ) { - IAEFeature feature = instance.get(); - - for ( AEFeature f : feature.handler().getFeatures() ) + final IAEFeature feature = instance.get(); + final IFeatureHandler handler = feature.handler(); + if ( handler.isFeatureAvailable() ) { - this.featuresToEntities.put( f, featureClass ); + for ( AEFeature f : handler.getFeatures() ) + { + this.featuresToEntities.put( f, featureClass ); + } + + handler.register(); + feature.postInit(); + + return handler.getDefinition(); + } + else + { + return null; } - - feature.handler().register(); - feature.postInit(); - - return feature.handler().getDefinition(); } else { - throw new RuntimeException( "Error with Feature: " + featureClass.getName() ); + throw new RuntimeException( "Error upon Class Instantiation with Feature: " + featureClass.getName() ); } }