<commit_before>package net.mcft.copy.betterstorage.misc.handlers;

import net.mcft.copy.betterstorage.BetterStorage;
import net.mcft.copy.betterstorage.item.ItemKey;
import net.mcft.copy.betterstorage.item.ItemLock;
import net.mcft.copy.betterstorage.utils.InventoryUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.ICraftingHandler;

/** Handles key and lock crafting. */
public class CraftingHandler implements ICraftingHandler {
	
	@Override
	public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix) {
		// If item crafted is a key ...
		if (item.getItem() instanceof ItemKey) {
			
			// Get the key used in the crafting recipe, if there was one.
			int keyIndex = InventoryUtils.findItemSlot(craftMatrix, BetterStorage.key);
			ItemStack key = ((keyIndex >= 0) ? craftMatrix.getStackInSlot(keyIndex) : null);
			
			// See if a key was modified by checking if no gold was used in the recipe.
			boolean modifyKey = !InventoryUtils.hasItem(craftMatrix, Item.ingotGold);
			
			// If a key is being modified, remove it from the crafting matrix.
			if (modifyKey) craftMatrix.setInventorySlotContents(keyIndex, null);
			// Otherwise, if a new key is crafted (not duplicated),
			// set the the damege of the key to a random value.
			else if (key == null) item.setItemDamage(-32000 + BetterStorage.random.nextInt(64000));
			
		}
		// If item crafted is a lock, copy the damage value from the key.
		if (item.getItem() instanceof ItemLock)
			item.setItemDamage(craftMatrix.getStackInSlot(4).getItemDamage());
	}
	@Override
	public void onSmelting(EntityPlayer player, ItemStack item) {  }
	
}<commit_msg>Change random key ID range to only positive<commit_after>package net.mcft.copy.betterstorage.misc.handlers;

import net.mcft.copy.betterstorage.BetterStorage;
import net.mcft.copy.betterstorage.item.ItemKey;
import net.mcft.copy.betterstorage.item.ItemLock;
import net.mcft.copy.betterstorage.utils.InventoryUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.ICraftingHandler;

/** Handles key and lock crafting. */
public class CraftingHandler implements ICraftingHandler {
	
	@Override
	public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix) {
		// If item crafted is a key ...
		if (item.getItem() instanceof ItemKey) {
			
			// Get the key used in the crafting recipe, if there was one.
			int keyIndex = InventoryUtils.findItemSlot(craftMatrix, BetterStorage.key);
			ItemStack key = ((keyIndex >= 0) ? craftMatrix.getStackInSlot(keyIndex) : null);
			
			// See if a key was modified by checking if no gold was used in the recipe.
			boolean modifyKey = !InventoryUtils.hasItem(craftMatrix, Item.ingotGold);
			
			// If a key is being modified, remove it from the crafting matrix.
			if (modifyKey)
				craftMatrix.setInventorySlotContents(keyIndex, null);
			// Otherwise, if a new key is crafted (not duplicated),
			// set the the damege of the key to a random value.
			else if (key == null)
				item.setItemDamage(BetterStorage.random.nextInt(32000));
			
		}
		// If item crafted is a lock, copy the damage value from the key.
		if (item.getItem() instanceof ItemLock)
			item.setItemDamage(craftMatrix.getStackInSlot(4).getItemDamage());
	}
	
	@Override
	public void onSmelting(EntityPlayer player, ItemStack item) {  }
	
}
{'fraction_non_alphanumeric': 0.09690893901420217, 'fraction_numerical': 0.005291005291005291, 'mean_word_length': 4.2437956204379566, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1694136', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1081, 'n_words': 322}