Skip to content

Commit

Permalink
Merge pull request #625 from thatsIch/b-624-pickaxe
Browse files Browse the repository at this point in the history
Fixes #624 Missing check to disable features
  • Loading branch information
thatsIch committed Dec 27, 2014
2 parents 366d1a0 + 21b70d0 commit f732328
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/main/java/appeng/core/Registration.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
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;
Expand Down Expand Up @@ -506,26 +507,33 @@ private void registerSpatial( boolean force )

private AEItemDefinition addFeature( Class<? extends IAEFeature> featureClass, Object... args )
{
ClassInstantiation<IAEFeature> instantiation = new ClassInstantiation<IAEFeature>( featureClass, args );
Optional<IAEFeature> instance = instantiation.get();
final ClassInstantiation<IAEFeature> instantiation = new ClassInstantiation<IAEFeature>( featureClass, args );
final Optional<IAEFeature> 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 );
}

feature.handler().register();
feature.postInit();
handler.register();
feature.postInit();

return feature.handler().getDefinition();
return handler.getDefinition();
}
else
{
return null;
}
}
else
{
throw new RuntimeException( "Error with Feature: " + featureClass.getName() );
throw new RuntimeException( "Error upon Class Instantiation with Feature: " + featureClass.getName() );
}
}

Expand Down

0 comments on commit f732328

Please sign in to comment.