<commit_before>package joshie.harvest.npcs.item;

import joshie.harvest.core.HFTab;
import joshie.harvest.core.base.item.ItemHFEnum;
import joshie.harvest.core.helpers.SpawnItemHelper;
import joshie.harvest.core.helpers.TextHelper;
import joshie.harvest.mining.MiningHelper;
import joshie.harvest.npcs.item.ItemNPCTool.NPCTool;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.IStringSerializable;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import javax.annotation.Nonnull;
import java.util.List;
import java.util.Locale;

import static joshie.harvest.core.lib.LootStrings.MINING_GEMS;
import static joshie.harvest.npcs.item.ItemNPCTool.NPCTool.NPC_KILLER;
import static net.minecraft.util.text.TextFormatting.AQUA;
import static net.minecraft.util.text.TextFormatting.GOLD;

public class ItemNPCTool extends ItemHFEnum<ItemNPCTool, NPCTool> {
    public static final String SPECIAL = "Gift";
    public enum NPCTool implements IStringSerializable {
        BLUE_FEATHER, NPC_KILLER, GIFT, SPEECH, MAIL;

        public boolean isReal() {
            return this == NPC_KILLER;
        }

        @Override
        public String getName() {
            return name().toLowerCase(Locale.ENGLISH);
        }
    }

    public ItemNPCTool() {
        super(HFTab.TOWN, NPCTool.class);
    }

    @Override
    public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
        if (getEnumFromStack(stack) == NPC_KILLER) {
            entity.setDead();
            return true;
        }

        return false;
    }

    @Override
    public boolean shouldDisplayInCreative(NPCTool cheat) {
        return cheat.isReal();
    }

    @Override
    public int getSortValue(ItemStack stack) {
        return 1;
    }

    @Override
    @SuppressWarnings("ConstantConditions")
    public String getItemStackDisplayName(ItemStack stack) {
        if (stack.hasTagCompound() && stack.getTagCompound().hasKey(SPECIAL)) return GOLD + TextHelper.translate("npctool.gift.special");
        else if (getEnumFromStack(stack).isReal()) return AQUA + super.getItemStackDisplayName(stack);
        else return super.getItemStackDisplayName(stack);
    }

    @SideOnly(Side.CLIENT)
    @Override
    @SuppressWarnings("ConstantConditions")
    public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
        if (stack.hasTagCompound() && stack.getTagCompound().hasKey(SPECIAL)) {
            tooltip.add(TextHelper.translate("npctool.gift.special.tooltip"));
        }
    }

    @Override
    @Nonnull
    @SuppressWarnings("ConstantConditions")
    public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack held, World world, EntityPlayer player, EnumHand hand) {
        if (held.hasTagCompound() && held.getTagCompound().hasKey(SPECIAL)) {
            if (!world.isRemote) {
                for (ItemStack stack: MiningHelper.getLoot(MINING_GEMS, world, player, 3F)) {
                    SpawnItemHelper.spawnByEntity(player, stack);
                }
            }

            return new ActionResult<>(EnumActionResult.SUCCESS, held);
        } else return super.onItemRightClick(held, world, player, hand);
    }
}<commit_msg>Fix infinite gifts from cloe.<commit_after>package joshie.harvest.npcs.item;

import joshie.harvest.core.HFTab;
import joshie.harvest.core.base.item.ItemHFEnum;
import joshie.harvest.core.helpers.SpawnItemHelper;
import joshie.harvest.core.helpers.TextHelper;
import joshie.harvest.mining.MiningHelper;
import joshie.harvest.npcs.item.ItemNPCTool.NPCTool;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.IStringSerializable;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import javax.annotation.Nonnull;
import java.util.List;
import java.util.Locale;

import static joshie.harvest.core.lib.LootStrings.MINING_GEMS;
import static joshie.harvest.npcs.item.ItemNPCTool.NPCTool.NPC_KILLER;
import static net.minecraft.util.text.TextFormatting.AQUA;
import static net.minecraft.util.text.TextFormatting.GOLD;

public class ItemNPCTool extends ItemHFEnum<ItemNPCTool, NPCTool> {
    public static final String SPECIAL = "Gift";
    public enum NPCTool implements IStringSerializable {
        BLUE_FEATHER, NPC_KILLER, GIFT, SPEECH, MAIL;

        public boolean isReal() {
            return this == NPC_KILLER;
        }

        @Override
        public String getName() {
            return name().toLowerCase(Locale.ENGLISH);
        }
    }

    public ItemNPCTool() {
        super(HFTab.TOWN, NPCTool.class);
    }

    @Override
    public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
        if (getEnumFromStack(stack) == NPC_KILLER) {
            entity.setDead();
            return true;
        }

        return false;
    }

    @Override
    public boolean shouldDisplayInCreative(NPCTool cheat) {
        return cheat.isReal();
    }

    @Override
    public int getSortValue(ItemStack stack) {
        return 1;
    }

    @Override
    @SuppressWarnings("ConstantConditions")
    public String getItemStackDisplayName(ItemStack stack) {
        if (stack.hasTagCompound() && stack.getTagCompound().hasKey(SPECIAL)) return GOLD + TextHelper.translate("npctool.gift.special");
        else if (getEnumFromStack(stack).isReal()) return AQUA + super.getItemStackDisplayName(stack);
        else return super.getItemStackDisplayName(stack);
    }

    @SideOnly(Side.CLIENT)
    @Override
    @SuppressWarnings("ConstantConditions")
    public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
        if (stack.hasTagCompound() && stack.getTagCompound().hasKey(SPECIAL)) {
            tooltip.add(TextHelper.translate("npctool.gift.special.tooltip"));
        }
    }

    @Override
    @Nonnull
    @SuppressWarnings("ConstantConditions")
    public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack held, World world, EntityPlayer player, EnumHand hand) {
        if (held.hasTagCompound() && held.getTagCompound().hasKey(SPECIAL)) {
            if (!world.isRemote) {
                for (ItemStack stack: MiningHelper.getLoot(MINING_GEMS, world, player, 3F)) {
                    SpawnItemHelper.spawnByEntity(player, stack);
                }
            }

            held.splitStack(1);
            return new ActionResult<>(EnumActionResult.SUCCESS, held);
        } else return super.onItemRightClick(held, world, player, hand);
    }
}
{'fraction_non_alphanumeric': 0.1015249929398475, 'fraction_numerical': 0.0007060152499293985, 'mean_word_length': 3.471590909090909, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3518404', 'n_tokens_mistral': 2181, 'n_tokens_neox': 2177, 'n_words': 399}