<commit_before>package net.silentchaos512.gems.recipe;

import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.silentchaos512.gems.core.util.ToolHelper;
import net.silentchaos512.gems.item.ModItems;
import net.silentchaos512.gems.item.tool.GemAxe;
import net.silentchaos512.gems.item.tool.GemPickaxe;
import net.silentchaos512.gems.item.tool.GemShovel;
import net.silentchaos512.gems.lib.Strings;

public class TippedToolRecipe implements IRecipe {

  @Override
  public boolean matches(InventoryCrafting inv, World world) {

    return getCraftingResult(inv) != null;
  }

  @Override
  public ItemStack getCraftingResult(InventoryCrafting inv) {

    ItemStack tool = null;
    ItemStack upgrade = null;
    int upgradeValue = 0;
    ItemStack stack;
    Item item;
    int meta;

    // Find tool and upgrade
    for (int i = 0; i < inv.getSizeInventory(); ++i) {
      stack = inv.getStackInSlot(i);
      if (stack != null) {
        item = stack.getItem();
        meta = stack.getItemDamage();
        if (item instanceof GemPickaxe || item instanceof GemShovel || item instanceof GemAxe) {
          // Tool
          if (tool != null) {
            return null;
          }
          tool = stack.copy();
        } else if (item == ModItems.toolUpgrade && (meta == 0 || meta == 1)) {
          // Upgrade
          if (upgrade != null) {
            return null;
          }
          upgrade = stack;
          upgradeValue = meta + 1;
        } else {
          // Invalid
          return null;
        }
      }
    }

    if (tool != null && upgrade != null) {
      // Apply
      ItemStack result = tool.copy();
      if (result.stackTagCompound == null) {
        // Create NBT if needed.
        result.setTagCompound(new NBTTagCompound());
      } else if (ToolHelper.getToolHeadTip(result) > -1) {
        // Can't upgrade a tool that has already been upgraded.
        return null;
      }
      ToolHelper.setToolHeadTip(result, upgradeValue);
      return result;
    }

    return null;
  }

  @Override
  public int getRecipeSize() {

    return 2;
  }

  @Override
  public ItemStack getRecipeOutput() {

    // TODO Auto-generated method stub
    return null;
  }
}<commit_msg>Tipped tools can be upgraded from iron to diamond<commit_after>package net.silentchaos512.gems.recipe;

import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.silentchaos512.gems.core.util.LogHelper;
import net.silentchaos512.gems.core.util.ToolHelper;
import net.silentchaos512.gems.item.ModItems;
import net.silentchaos512.gems.item.tool.GemAxe;
import net.silentchaos512.gems.item.tool.GemPickaxe;
import net.silentchaos512.gems.item.tool.GemShovel;
import net.silentchaos512.gems.lib.Strings;

public class TippedToolRecipe implements IRecipe {

  @Override
  public boolean matches(InventoryCrafting inv, World world) {

    return getCraftingResult(inv) != null;
  }

  @Override
  public ItemStack getCraftingResult(InventoryCrafting inv) {

    ItemStack tool = null;
    ItemStack upgrade = null;
    int upgradeValue = 0;
    ItemStack stack;
    Item item;
    int meta;

    // Find tool and upgrade
    for (int i = 0; i < inv.getSizeInventory(); ++i) {
      stack = inv.getStackInSlot(i);
      if (stack != null) {
        item = stack.getItem();
        meta = stack.getItemDamage();
        if (item instanceof GemPickaxe || item instanceof GemShovel || item instanceof GemAxe) {
          // Tool
          if (tool != null) {
            return null;
          }
          tool = stack.copy();
        } else if (item == ModItems.toolUpgrade && (meta == 0 || meta == 1)) {
          // Upgrade
          if (upgrade != null) {
            return null;
          }
          upgrade = stack;
          upgradeValue = meta + 1;
        } else {
          // Invalid
          return null;
        }
      }
    }

    if (tool != null && upgrade != null) {
      // Apply
      ItemStack result = tool.copy();
      if (result.stackTagCompound == null) {
        // Create NBT if needed.
        result.setTagCompound(new NBTTagCompound());
      } else if (ToolHelper.getToolHeadTip(result) >= upgradeValue) {
        // Can't upgrade a tool that has already been upgraded.
        return null;
      }
      ToolHelper.setToolHeadTip(result, upgradeValue);
      return result;
    }

    return null;
  }

  @Override
  public int getRecipeSize() {

    return 2;
  }

  @Override
  public ItemStack getRecipeOutput() {

    // TODO Auto-generated method stub
    return null;
  }
}
{'fraction_non_alphanumeric': 0.10602701068332997, 'fraction_numerical': 0.01169119129207821, 'mean_word_length': 2.4869992972593113, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '675620', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1531, 'n_words': 368}