From 2f8013a49b961564bb1f99a129ac6055b22ba07b Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Wed, 2 Nov 2016 23:32:20 +0100 Subject: [PATCH] Fixes registration of recipes when one of the recipes throws an unexpected unchecked exception during registration. Before, the registration would simply cancel and not log any errors in this case. Fixes issues with outdated IC2 integration (Macerator recipes) causing certain recipes to become non-functional. --- .../java/appeng/recipes/RecipeHandler.java | 74 ++++++++----------- 1 file changed, 30 insertions(+), 44 deletions(-) diff --git a/src/main/java/appeng/recipes/RecipeHandler.java b/src/main/java/appeng/recipes/RecipeHandler.java index bf005aacc..9abc69816 100644 --- a/src/main/java/appeng/recipes/RecipeHandler.java +++ b/src/main/java/appeng/recipes/RecipeHandler.java @@ -32,7 +32,6 @@ import java.util.Map.Entry; import java.util.Optional; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; - import javax.annotation.Nonnull; import com.google.common.base.Preconditions; @@ -371,65 +370,52 @@ public class RecipeHandler implements IRecipeHandler } final Map processed = new HashMap(); - try + for( final ICraftHandler ch : this.data.handlers ) { - for( final ICraftHandler ch : this.data.handlers ) + try { - try - { - ch.register(); + ch.register(); - final Class clz = ch.getClass(); - final Integer i = processed.get( clz ); - if( i == null ) - { - processed.put( clz, 1 ); - } - else - { - processed.put( clz, i + 1 ); - } - } - catch( final RegistrationError e ) + final Class clz = ch.getClass(); + final Integer i = processed.get( clz ); + if( i == null ) { - AELog.warn( "Unable to register a recipe: " + e.getMessage() ); + processed.put( clz, 1 ); + } + else + { + processed.put( clz, i + 1 ); + } + } + catch( final MissingIngredientError e ) + { + if( this.data.errorOnMissing ) + { + AELog.warn( "Unable to register a recipe:" + e.getMessage() ); if( this.data.exceptions ) { AELog.debug( e ); } if( this.data.crash ) { - throw e; + throw new IllegalStateException( e ); } } - catch( final MissingIngredientError e ) + } + catch( final Throwable e ) + { + AELog.warn( "Unable to register a recipe: " + e.getMessage() ); + if( this.data.exceptions ) { - if( this.data.errorOnMissing ) - { - AELog.warn( "Unable to register a recipe:" + e.getMessage() ); - if( this.data.exceptions ) - { - AELog.debug( e ); - } - if( this.data.crash ) - { - throw e; - } - } + AELog.debug( e ); + } + if( this.data.crash ) + { + throw new IllegalStateException( e ); } } } - catch( final Throwable e ) - { - if( this.data.exceptions ) - { - AELog.debug( e ); - } - if( this.data.crash ) - { - throw new IllegalStateException( e ); - } - } + for( final Entry e : processed.entrySet() ) {