use of com.codetaylor.mc.artisanworktables.api.internal.recipe.RecipeBuilderException in project artisan-worktables by codetaylor.
the class IZenRecipeBuilderCopyStrategy method byRecipe.
@ZenMethod
static IZenRecipeBuilderCopyStrategy byRecipe(ICraftingRecipe recipe) {
try {
String registryName = recipe.getFullResourceName();
IRecipe iRecipe = ForgeRegistries.RECIPES.getValue(new ResourceLocation(registryName));
return new ZenRecipeBuilderCopyStrategy(RecipeBuilderInternal.Copy.byRecipe(iRecipe));
} catch (RecipeBuilderException e) {
CTLogHelper.logErrorFromZenMethod(e.getMessage());
return ZenRecipeBuilderCopyStrategyNoOp.INSTANCE;
}
}
use of com.codetaylor.mc.artisanworktables.api.internal.recipe.RecipeBuilderException in project artisan-worktables by codetaylor.
the class RecipeBuilderCopyStrategyByOutput method apply.
@Override
public void apply(RecipeBuilderInternal recipeBuilder, List<RecipeBuilderInternal> resultList) throws RecipeBuilderException {
Collection<IRecipe> recipes = ForgeRegistries.RECIPES.getValuesCollection();
Set<IRecipe> toCopy = new HashSet<>();
for (IRecipe recipe : recipes) {
for (IArtisanIngredient copyRecipe : this.toCopy) {
if (!recipe.getRecipeOutput().isEmpty() && copyRecipe.matches(recipe.getRecipeOutput())) {
toCopy.add(recipe);
}
}
}
for (IRecipe recipe : toCopy) {
try {
this.doCopy(recipe, recipeBuilder.copy(), resultList);
} catch (Exception e) {
throw new RecipeBuilderException("Unable to copy recipe by output: " + recipe.getRegistryName(), e);
}
}
}
use of com.codetaylor.mc.artisanworktables.api.internal.recipe.RecipeBuilderException in project artisan-worktables by codetaylor.
the class RecipeAdditionQueue method onRegisterRecipesEvent.
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onRegisterRecipesEvent(RegistryEvent.Register<IRecipe> event) {
for (RecipeBuilderInternal builder : this.recipeBuilderWithCopyList) {
IRecipeBuilderCopyStrategyInternal recipeCopyStrategy = builder.getRecipeCopyStrategy();
if (recipeCopyStrategy != null) {
try {
recipeCopyStrategy.apply(builder, this.recipeBuilderList);
} catch (Exception e) {
ModuleWorktables.LOG.error("", e);
}
}
}
for (RecipeBuilderInternal builder : this.recipeBuilderList) {
try {
builder.apply(LOGGER);
} catch (RecipeBuilderException e) {
ModuleWorktables.LOG.error("", e);
}
}
this.recipeBuilderList.clear();
this.recipeBuilderWithCopyList.clear();
}
Aggregations