package crazypants.enderzoo.item;

import crazypants.enderzoo.EnderZoo;
import crazypants.enderzoo.EnderZooTab;
import crazypants.enderzoo.config.Config;
import crazypants.enderzoo.entity.EntityOwlEgg;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class ItemOwlEgg extends Item {

  public static final String NAME = "owlegg";

  public static ItemOwlEgg create() {
    
    EntityRegistry.registerModEntity(new ResourceLocation(EnderZoo.MODID,"EntityOwlEgg"),
        EntityOwlEgg.class, "EntityOwlEgg", Config.entityOwlEggId, EnderZoo.instance, 64, 10, true);
    
    ItemOwlEgg res = new ItemOwlEgg();
    res.init();
    return res;
  }

  private ItemOwlEgg() {
    setUnlocalizedName(NAME);
    setRegistryName(NAME);
    setCreativeTab(EnderZooTab.tabEnderZoo);
    setHasSubtypes(false);
  }

  private void init() {
    GameRegistry.register(this);
  }

  @Override
  public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
    ItemStack itemStackIn = playerIn.getHeldItem(hand);
    if (!playerIn.capabilities.isCreativeMode) {
      itemStackIn.shrink(1);
    }
    worldIn.playSound(playerIn, playerIn.getPosition(), SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.BLOCKS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
    if (!worldIn.isRemote) {         
      worldIn.spawnEntity(new EntityOwlEgg(worldIn, playerIn));
    }
    return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn);
  }

}
@@ -753,16 +753,174 @@
  Item %7B%0A
+  private static final float VELOCITY_DEFAULT = 1.5F;%0A  private static final float INACCURACY_DEFAULT = 1.0F;%0A  private static final float PITCHOFFSET = 0.0F;
 %0A  publi
@@ -1950,75 +1950,324 @@
     
+%0A 
      
-%0A      worldIn.spawnEntity(new EntityOwlEgg(worldIn, playerIn)
+EntityOwlEgg entityEgg = new EntityOwlEgg(worldIn, playerIn);%0A      //without setHeading the egg just falls to the players feet%0A      entityEgg.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, PITCHOFFSET, VELOCITY_DEFAULT, INACCURACY_DEFAULT);%0A      worldIn.spawnEntity(entityEgg
 );%0A 

fix owl egg not flying on throw