Search in sources :

Example 1 with RecipeStorage

use of com.minecolonies.api.crafting.RecipeStorage in project minecolonies by Minecolonies.

the class FurnaceRecipes method loadRecipes.

/**
 * Load all the recipes in the recipe storage.
 *
 * @param recipeManager  The recipe manager to parse.
 */
public void loadRecipes(final RecipeManager recipeManager) {
    recipes.clear();
    reverseRecipes.clear();
    loadUtilityPredicates();
    recipeManager.byType(IRecipeType.SMELTING).values().forEach(recipe -> {
        final NonNullList<Ingredient> list = recipe.getIngredients();
        if (list.size() == 1) {
            for (final ItemStack smeltable : list.get(0).getItems()) {
                if (!smeltable.isEmpty()) {
                    final RecipeStorage storage = StandardFactoryController.getInstance().getNewInstance(TypeConstants.RECIPE, StandardFactoryController.getInstance().getNewInstance(TypeConstants.ITOKEN), ImmutableList.of(new ItemStorage(smeltable)), 1, recipe.getResultItem(), Blocks.FURNACE, recipe.getId());
                    recipes.put(storage.getCleanedInput().get(0), storage);
                    final ItemStack output = recipe.getResultItem().copy();
                    output.setCount(1);
                    reverseRecipes.put(new ItemStorage(output), storage);
                }
            }
        }
    });
}
Also used : RecipeStorage(com.minecolonies.api.crafting.RecipeStorage) Ingredient(net.minecraft.item.crafting.Ingredient) FoodIngredient(com.minecolonies.coremod.recipes.FoodIngredient) ItemStack(net.minecraft.item.ItemStack) ItemStorage(com.minecolonies.api.crafting.ItemStorage)

Example 2 with RecipeStorage

use of com.minecolonies.api.crafting.RecipeStorage in project minecolonies by Minecolonies.

the class UpdateClientWithRecipesMessage method fromBytes.

@Override
public void fromBytes(@NotNull final PacketBuffer buf) {
    recipes = new HashMap<>();
    final int size = buf.readInt();
    for (int i = 0; i < size; i++) {
        final ItemStack result = buf.readItem();
        final RecipeStorage storage = StandardFactoryController.getInstance().deserialize(buf.readNbt());
        recipes.put(new ItemStorage(result), storage);
    }
}
Also used : RecipeStorage(com.minecolonies.api.crafting.RecipeStorage) ItemStack(net.minecraft.item.ItemStack) ItemStorage(com.minecolonies.api.crafting.ItemStorage)

Example 3 with RecipeStorage

use of com.minecolonies.api.crafting.RecipeStorage in project minecolonies by ldtteam.

the class FurnaceRecipes method loadRecipes.

/**
 * Load all the recipes in the recipe storage.
 *
 * @param recipeManager  The recipe manager to parse.
 */
public void loadRecipes(final RecipeManager recipeManager) {
    recipes.clear();
    reverseRecipes.clear();
    loadUtilityPredicates();
    recipeManager.byType(IRecipeType.SMELTING).values().forEach(recipe -> {
        final NonNullList<Ingredient> list = recipe.getIngredients();
        if (list.size() == 1) {
            for (final ItemStack smeltable : list.get(0).getItems()) {
                if (!smeltable.isEmpty()) {
                    final RecipeStorage storage = StandardFactoryController.getInstance().getNewInstance(TypeConstants.RECIPE, StandardFactoryController.getInstance().getNewInstance(TypeConstants.ITOKEN), ImmutableList.of(new ItemStorage(smeltable)), 1, recipe.getResultItem(), Blocks.FURNACE, recipe.getId());
                    recipes.put(storage.getCleanedInput().get(0), storage);
                    final ItemStack output = recipe.getResultItem().copy();
                    output.setCount(1);
                    reverseRecipes.put(new ItemStorage(output), storage);
                }
            }
        }
    });
}
Also used : RecipeStorage(com.minecolonies.api.crafting.RecipeStorage) Ingredient(net.minecraft.item.crafting.Ingredient) FoodIngredient(com.minecolonies.coremod.recipes.FoodIngredient) ItemStack(net.minecraft.item.ItemStack) ItemStorage(com.minecolonies.api.crafting.ItemStorage)

Example 4 with RecipeStorage

use of com.minecolonies.api.crafting.RecipeStorage in project minecolonies by ldtteam.

the class UpdateClientWithRecipesMessage method fromBytes.

@Override
public void fromBytes(@NotNull final PacketBuffer buf) {
    recipes = new HashMap<>();
    final int size = buf.readInt();
    for (int i = 0; i < size; i++) {
        final ItemStack result = buf.readItem();
        final RecipeStorage storage = StandardFactoryController.getInstance().deserialize(buf.readNbt());
        recipes.put(new ItemStorage(result), storage);
    }
}
Also used : RecipeStorage(com.minecolonies.api.crafting.RecipeStorage) ItemStack(net.minecraft.item.ItemStack) ItemStorage(com.minecolonies.api.crafting.ItemStorage)

Aggregations

ItemStorage (com.minecolonies.api.crafting.ItemStorage)4 RecipeStorage (com.minecolonies.api.crafting.RecipeStorage)4 ItemStack (net.minecraft.item.ItemStack)4 FoodIngredient (com.minecolonies.coremod.recipes.FoodIngredient)2 Ingredient (net.minecraft.item.crafting.Ingredient)2