<commit_before>package airbreather.mods.airbreathercore.recipe;

import java.util.ArrayList;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.registry.GameRegistry;
import airbreather.mods.airbreathercore.item.ItemDefinition;
import airbreather.mods.airbreathercore.item.ItemRegistry;

// Implements RecipeRegistrar using the FML GameRegistry.
public final class FmlRecipeRegistrar implements RecipeRegistrar
{
    // register the given recipes with the underlying system.
    public void RegisterRecipes(RecipeConfiguration recipeConfiguration, ItemRegistry itemRegistry)
    {
        for (Recipe recipe : recipeConfiguration.GetRecipes())
        {
            switch (recipe.GetRecipeType())
            {
                case Smelting:
                    RegisterSmeltingRecipe(recipe, itemRegistry);
                    break;

                case ShapedCrafting:
                    RegisterShapedCraftingRecipe(recipe, itemRegistry);
                    break;
            }
        }
    }

    private static void RegisterSmeltingRecipe(Recipe recipe, ItemRegistry itemRegistry)
    {
        SmeltingRecipe smeltingRecipe = (SmeltingRecipe)recipe;

        ItemDefinition input = smeltingRecipe.GetInput();

        RecipeResult result = smeltingRecipe.GetResult();
        ItemStack resultItemStack = GetResultItemStack(result, itemRegistry);

        int inputID = input.GetItemID();
        float experience = smeltingRecipe.GetExperience();

        GameRegistry.addSmelting(inputID, resultItemStack, experience);
    }

    private static void RegisterShapedCraftingRecipe(Recipe recipe, ItemRegistry itemRegistry)
    {
        ShapedCraftingRecipe shapedCraftingRecipe = (ShapedCraftingRecipe)recipe;

        // Gotta convert ItemDefinition to their Item.
        Object[] weakInputs = shapedCraftingRecipe.GetInputs();
        ArrayList<Object> strongInputs = new ArrayList<Object>(weakInputs.length);
        for (Object weakInput : weakInputs)
        {
            if (weakInput instanceof ItemDefinition)
            {
                ItemDefinition definition = (ItemDefinition)weakInput;
                Item strongInput = itemRegistry.FetchItem(definition);
                strongInputs.add(strongInput);<commit_msg>Fixing the off-by-256 bug smelting recipes.<commit_after>package airbreather.mods.airbreathercore.recipe;

import java.util.ArrayList;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.registry.GameRegistry;
import airbreather.mods.airbreathercore.item.ItemDefinition;
import airbreather.mods.airbreathercore.item.ItemRegistry;

// Implements RecipeRegistrar using the FML GameRegistry.
public final class FmlRecipeRegistrar implements RecipeRegistrar
{
    // register the given recipes with the underlying system.
    public void RegisterRecipes(RecipeConfiguration recipeConfiguration, ItemRegistry itemRegistry)
    {
        for (Recipe recipe : recipeConfiguration.GetRecipes())
        {
            switch (recipe.GetRecipeType())
            {
                case Smelting:
                    RegisterSmeltingRecipe(recipe, itemRegistry);
                    break;

                case ShapedCrafting:
                    RegisterShapedCraftingRecipe(recipe, itemRegistry);
                    break;
            }
        }
    }

    private static void RegisterSmeltingRecipe(Recipe recipe, ItemRegistry itemRegistry)
    {
        SmeltingRecipe smeltingRecipe = (SmeltingRecipe)recipe;

        ItemDefinition inputDefinition = smeltingRecipe.GetInput();
        Item input = itemRegistry.FetchItem(inputDefinition);
        int inputID = input.itemID;

        RecipeResult result = smeltingRecipe.GetResult();
        ItemStack resultItemStack = GetResultItemStack(result, itemRegistry);

        float experience = smeltingRecipe.GetExperience();

        GameRegistry.addSmelting(inputID, resultItemStack, experience);
    }

    private static void RegisterShapedCraftingRecipe(Recipe recipe, ItemRegistry itemRegistry)
    {
        ShapedCraftingRecipe shapedCraftingRecipe = (ShapedCraftingRecipe)recipe;

        // Gotta convert ItemDefinition to their Item.
        Object[] weakInputs = shapedCraftingRecipe.GetInputs();
        ArrayList<Object> strongInputs = new ArrayList<Object>(weakInputs.length);
        for (Object weakInput : weakInputs)
        {
            if (weakInput instanceof ItemDefinition)
            {
                ItemDefinition definition = (ItemDefinition)weakInput;
                Item strongInput = itemRegistry.FetchItem(definition);
                strongInputs.add(strongInput);
{'fraction_non_alphanumeric': 0.0696432386242256, 'fraction_numerical': 0.000640888698995941, 'mean_word_length': 2.9081803005008346, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5045291', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1232, 'n_words': 255}