<commit_before>package romelo333.notenoughwands.varia;

import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.S29PacketSoundEffect;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;

public class Tools {
    public static void error(EntityPlayer player, String msg) {
        player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + msg));
    }

    public static void notify(EntityPlayer player, String msg) {
        player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GREEN + msg));
    }

    public static boolean consumeInventoryItem(Item item, int meta, InventoryPlayer inv) {
        int i = finditem(item, meta, inv);

        if (i < 0) {
            return false;
        } else {
            if (--inv.mainInventory[i].stackSize <= 0) {
                inv.mainInventory[i] = null;
            }

            return true;
        }
    }

    public static int finditem(Item item, int meta, InventoryPlayer inv) {
        for (int i = 0; i < inv.mainInventory.length; ++i) {
            if (inv.mainInventory[i] != null && inv.mainInventory[i].getItem() == item && meta == inv.mainInventory[i].getItemDamage()) {
                return i;
            }
        }

        return -1;
    }

    public static NBTTagCompound getTagCompound(ItemStack stack) {
        NBTTagCompound tagCompound = stack.getTagCompound();
        if (tagCompound == null){
            tagCompound = new NBTTagCompound();
            stack.setTagCompound(tagCompound);
        }<commit_msg>Helper to give items to the player<commit_after>package romelo333.notenoughwands.varia;

import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.S29PacketSoundEffect;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;

public class Tools {
    public static void error(EntityPlayer player, String msg) {
        player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + msg));
    }

    public static void notify(EntityPlayer player, String msg) {
        player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.GREEN + msg));
    }

    public static boolean consumeInventoryItem(Item item, int meta, InventoryPlayer inv) {
        int i = finditem(item, meta, inv);

        if (i < 0) {
            return false;
        } else {
            if (--inv.mainInventory[i].stackSize <= 0) {
                inv.mainInventory[i] = null;
            }

            return true;
        }
    }

    public static void giveItem(World world, EntityPlayer player, Block block, int meta, int cnt, int x, int y, int z) {
        ItemStack oldStack = new ItemStack(block, cnt, meta);
        if (!player.inventory.addItemStackToInventory(oldStack)) {
            // Not enough room. Spawn item in world.
            EntityItem entityItem = new EntityItem(world, x, y, z, oldStack);
            world.spawnEntityInWorld(entityItem);
        }
    }

    public static int finditem(Item item, int meta, InventoryPlayer inv) {
        for (int i = 0; i < inv.mainInventory.length; ++i) {
            if (inv.mainInventory[i] != null && inv.mainInventory[i].getItem() == item && meta == inv.mainInventory[i].getItemDamage()) {
                return i;
            }
        }

        return -1;
    }

    public static NBTTagCompound getTagCompound(ItemStack stack) {
        NBTTagCompound tagCompound = stack.getTagCompound();
        if (tagCompound == null){
            tagCompound = new NBTTagCompound();
            stack.setTagCompound(tagCompound);
        }
{'fraction_non_alphanumeric': 0.10064190738193489, 'fraction_numerical': 0.0041265474552957355, 'mean_word_length': 2.934174932371506, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, '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': '4888989', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1262, 'n_words': 287}