use of com.minecolonies.coremod.colony.crafting.CustomRecipeManager in project minecolonies by ldtteam.
the class CrafterRecipeListener method apply.
@Override
protected void apply(@NotNull final Map<ResourceLocation, JsonElement> object, @NotNull final IResourceManager resourceManagerIn, @NotNull final IProfiler profilerIn) {
Log.getLogger().info("Beginning load of custom recipes for colony workers");
final CustomRecipeManager recipeManager = CustomRecipeManager.getInstance();
recipeManager.reset();
for (final Map.Entry<ResourceLocation, JsonElement> entry : object.entrySet()) {
final ResourceLocation key = entry.getKey();
try {
final JsonObject recipeJson = entry.getValue().getAsJsonObject();
switch(JSONUtils.getAsString(recipeJson, RECIPE_TYPE_PROP, "")) {
case RECIPE_TYPE_RECIPE:
case RECIPE_TYPE_RECIPE_MULT_OUT:
recipeManager.addRecipe(CustomRecipe.parse(key, recipeJson));
break;
case RECIPE_TYPE_REMOVE:
final ResourceLocation toRemove = new ResourceLocation(JSONUtils.getAsString(recipeJson, RECIPE_ID_TO_REMOVE_PROP, ""));
recipeManager.removeRecipe(toRemove);
break;
}
} catch (final JsonParseException e) {
Log.getLogger().error("Error parsing crafterrecipe " + key.toString(), e);
}
}
final int totalRecipes = recipeManager.getAllRecipes().values().stream().mapToInt(Map::size).sum();
Log.getLogger().info("Loaded " + totalRecipes + " recipes for " + recipeManager.getAllRecipes().size() + " crafters");
}
use of com.minecolonies.coremod.colony.crafting.CustomRecipeManager in project minecolonies by Minecolonies.
the class CrafterRecipeListener method apply.
@Override
protected void apply(@NotNull final Map<ResourceLocation, JsonElement> object, @NotNull final IResourceManager resourceManagerIn, @NotNull final IProfiler profilerIn) {
Log.getLogger().info("Beginning load of custom recipes for colony workers");
final CustomRecipeManager recipeManager = CustomRecipeManager.getInstance();
recipeManager.reset();
for (final Map.Entry<ResourceLocation, JsonElement> entry : object.entrySet()) {
final ResourceLocation key = entry.getKey();
try {
final JsonObject recipeJson = entry.getValue().getAsJsonObject();
switch(JSONUtils.getAsString(recipeJson, RECIPE_TYPE_PROP, "")) {
case RECIPE_TYPE_RECIPE:
case RECIPE_TYPE_RECIPE_MULT_OUT:
recipeManager.addRecipe(CustomRecipe.parse(key, recipeJson));
break;
case RECIPE_TYPE_REMOVE:
final ResourceLocation toRemove = new ResourceLocation(JSONUtils.getAsString(recipeJson, RECIPE_ID_TO_REMOVE_PROP, ""));
recipeManager.removeRecipe(toRemove);
break;
}
} catch (final JsonParseException e) {
Log.getLogger().error("Error parsing crafterrecipe " + key.toString(), e);
}
}
final int totalRecipes = recipeManager.getAllRecipes().values().stream().mapToInt(Map::size).sum();
Log.getLogger().info("Loaded " + totalRecipes + " recipes for " + recipeManager.getAllRecipes().size() + " crafters");
}
Aggregations