<commit_before>package io.github.sihenzhang.cursedlasso.item;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFence;
import net.minecraft.block.BlockWall;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Facing;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;

import java.util.List;

public class ItemCursedLasso extends Item {
    public ItemCursedLasso() {
        setCreativeTab(CreativeTabs.tabTools);
        setUnlocalizedName("cursedlasso.cursed_lasso");
        setTextureName("cursedlasso:cursed_lasso");
        setMaxStackSize(1);
    }

    @Override
    @SideOnly(Side.CLIENT)
    public boolean hasEffect(ItemStack item, int pass) {
        return item.hasTagCompound();
    }

    @Override
    public boolean itemInteractionForEntity(ItemStack item, EntityPlayer player, EntityLivingBase entity) {
        if (entity.worldObj.isRemote) {
            return false;
        }
        if (entity instanceof IMob) {
            if (item.hasTagCompound())
                return false;
            item.setTagCompound(new NBTTagCompound());
            NBTTagCompound mainTag = new NBTTagCompound();
            NBTTagCompound entityTag = new NBTTagCompound();
            entity.writeToNBT(entityTag);
            mainTag.setTag("data", entityTag);
            mainTag.setString("id", EntityList.getEntityString(entity));
            item.getTagCompound().setTag("entity", mainTag);
            player.setCurrentItemOrArmor(0, item);
            entity.setDead();
            return true;
        }
        return super.itemInteractionForEntity(item, player, entity);
    }

    @Override
    public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int facing, float hitX, float hitY, float hitZ) {
        if (world.isRemote) {
            return true;
        }
        if (!item.hasTagCompound()) {
            return false;
        }
        if(player == null) {
            return false;
        }

        String entityId = item.getTagCompound().getCompoundTag("entity").getString("id");
        Entity entityToSpawn = EntityList.createEntityByName(entityId, world);

        Block blk = world.getBlock(x,y,z);
        double spawnX = x + Facing.offsetsXForSide[facing] + 0.5;
        double spawnY = y + Facing.offsetsYForSide[facing];
        double spawnZ = z + Facing.offsetsZForSide[facing] + 0.5;
        if(facing == ForgeDirection.UP.ordinal() && (blk instanceof BlockFence || blk instanceof BlockWall)) {
            spawnY += 0.5;
        }
        entityToSpawn.setLocationAndAngles(spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0);

        world.spawnEntityInWorld(entityToSpawn);
        if(entityToSpawn instanceof EntityLiving) {
            ((EntityLiving)entityToSpawn).playLivingSound();
        }

        Entity riddenByEntity = entityToSpawn.riddenByEntity;
        while(riddenByEntity != null) {
            riddenByEntity.setLocationAndAngles(spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0.0F);
            world.spawnEntityInWorld(riddenByEntity);
            if(riddenByEntity instanceof EntityLiving) {
                ((EntityLiving)riddenByEntity).playLivingSound();
            }
            riddenByEntity = riddenByEntity.riddenByEntity;
        }
        item.setTagCompound(null);
        player.setCurrentItemOrArmor(0, item);
        return true;
    }

    public String getMobTypeFromStack(ItemStack item) {
        if(!item.hasTagCompound()) {
            return null;
        }
        if(item.stackTagCompound == null || !item.stackTagCompound.hasKey("id")) {
            return null;
        }
        return item.stackTagCompound.getString("id");
    }

    public static String getDisplayNameForEntity(String mobName) {
        return StatCollector.translateToLocal("entity." + mobName + ".name");
    }

    @Override
    @SideOnly(Side.CLIENT)<commit_msg>A Successful Commit<commit_after>package io.github.sihenzhang.cursedlasso.item;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFence;
import net.minecraft.block.BlockWall;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Facing;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;

import java.util.List;

public class ItemCursedLasso extends Item {
    public ItemCursedLasso() {
        setCreativeTab(CreativeTabs.tabTools);
        setUnlocalizedName("cursedlasso.cursed_lasso");
        setTextureName("cursedlasso:cursed_lasso");
        setMaxStackSize(1);
    }

    @Override
    @SideOnly(Side.CLIENT)
    public boolean hasEffect(ItemStack item, int pass) {
        return item.hasTagCompound();
    }

    @Override
    public boolean itemInteractionForEntity(ItemStack item, EntityPlayer player, EntityLivingBase entity) {
        if (entity.worldObj.isRemote) {
            return false;
        }
        if (entity instanceof IMob) {
            if (item.hasTagCompound())
                return false;
            item.setTagCompound(new NBTTagCompound());
            NBTTagCompound mainTag = new NBTTagCompound();
            NBTTagCompound entityTag = new NBTTagCompound();
            entity.writeToNBT(entityTag);
            mainTag.setTag("data", entityTag);
            mainTag.setString("id", EntityList.getEntityString(entity));
            item.getTagCompound().setTag("entity", mainTag);
            player.setCurrentItemOrArmor(0, item);
            entity.setDead();
            return true;
        }
        return super.itemInteractionForEntity(item, player, entity);
    }

    @Override
    public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int facing, float hitX, float hitY, float hitZ) {
        if (world.isRemote) {
            return true;
        }
        if (!item.hasTagCompound()) {
            return false;
        }
        if(player == null) {
            return false;
        }

        String entityId = item.getTagCompound().getCompoundTag("entity").getString("id");
        Entity entityToSpawn = EntityList.createEntityByName(entityId, world);

        Block blk = world.getBlock(x,y,z);
        double spawnX = x + Facing.offsetsXForSide[facing] + 0.5;
        double spawnY = y + Facing.offsetsYForSide[facing];
        double spawnZ = z + Facing.offsetsZForSide[facing] + 0.5;
        if(facing == ForgeDirection.UP.ordinal() && (blk instanceof BlockFence || blk instanceof BlockWall)) {
            spawnY += 0.5;
        }
        entityToSpawn.setLocationAndAngles(spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0);

        world.spawnEntityInWorld(entityToSpawn);
        if(entityToSpawn instanceof EntityLiving) {
            ((EntityLiving)entityToSpawn).playLivingSound();
        }

        Entity riddenByEntity = entityToSpawn.riddenByEntity;
        while(riddenByEntity != null) {
            riddenByEntity.setLocationAndAngles(spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0.0F);
            world.spawnEntityInWorld(riddenByEntity);
            if(riddenByEntity instanceof EntityLiving) {
                ((EntityLiving)riddenByEntity).playLivingSound();
            }
            riddenByEntity = riddenByEntity.riddenByEntity;
        }
        item.setTagCompound(null);
        player.setCurrentItemOrArmor(0, item);
        return true;
    }

    public String getMobTypeFromStack(ItemStack item) {
        if(!item.hasTagCompound()) {
            return null;
        }
        if(item.stackTagCompound == null) {
            return null;
        }
        return item.stackTagCompound.getCompoundTag("entity").getString("id");

    }

    public static String getDisplayNameForEntity(String mobName) {
        return StatCollector.translateToLocal("entity." + mobName + ".name");
    }

    @Override
    @SideOnly(Side.CLIENT)
{'fraction_non_alphanumeric': 0.10342889263631254, 'fraction_numerical': 0.004496908375491849, 'mean_word_length': 2.8627876682587927, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4628833', 'n_tokens_mistral': 2693, 'n_tokens_neox': 2662, 'n_words': 476}