content: package zmaster587.advancedRocketry.item;
  
  import net.minecraft.block.Block;
  import net.minecraft.client.util.ITooltipFlag;
  import net.minecraft.entity.Entity;
  import net.minecraft.entity.player.EntityPlayer;
  import net.minecraft.init.Blocks;
  import net.minecraft.item.Item;
  import net.minecraft.item.ItemStack;
  import net.minecraft.stats.StatList;
  import net.minecraft.util.ActionResult;
  import net.minecraft.util.EnumActionResult;
  import net.minecraft.util.EnumHand;
  import net.minecraft.util.math.AxisAlignedBB;
  import net.minecraft.util.math.MathHelper;
  import net.minecraft.util.math.RayTraceResult;
  import net.minecraft.util.math.Vec3d;
  import net.minecraft.world.World;
  import zmaster587.advancedRocketry.entity.EntityHoverCraft;
  import zmaster587.libVulpes.LibVulpes;
  
  import javax.annotation.Nonnull;
  import javax.annotation.ParametersAreNonnullByDefault;
  import java.util.List;
  
  public class ItemHovercraft extends Item {
      
  	public ItemHovercraft() {
          super();
          this.maxStackSize = 1;
  	}
  
      /**
       * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
       */
      @ParametersAreNonnullByDefault
      @Nonnull
      public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
      {
          ItemStack itemstack = playerIn.getHeldItem(handIn);
          float f = 1.0F;
          float f1 = playerIn.prevRotationPitch + (playerIn.rotationPitch - playerIn.prevRotationPitch);
          float f2 = playerIn.prevRotationYaw + (playerIn.rotationYaw - playerIn.prevRotationYaw);
          double d0 = playerIn.prevPosX + (playerIn.posX - playerIn.prevPosX);
          double d1 = playerIn.prevPosY + (playerIn.posY - playerIn.prevPosY) + (double)playerIn.getEyeHeight();
          double d2 = playerIn.prevPosZ + (playerIn.posZ - playerIn.prevPosZ);
          Vec3d vec3d = new Vec3d(d0, d1, d2);
          float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI);
          float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI);
          float f5 = -MathHelper.cos(-f1 * 0.017453292F);
          float f6 = MathHelper.sin(-f1 * 0.017453292F);
          float f7 = f4 * f5;
          float f8 = f3 * f5;
          double d3 = 5.0D;
          Vec3d vec3d1 = vec3d.addVector((double)f7 * 5.0D, (double)f6 * 5.0D, (double)f8 * 5.0D);
          RayTraceResult raytraceresult = worldIn.rayTraceBlocks(vec3d, vec3d1, true);
  
          if (raytraceresult == null)
          {
              return new ActionResult<>(EnumActionResult.PASS, itemstack);
          }
          else
          {
              Vec3d vec3d2 = playerIn.getLook(1.0F);
              boolean flag = false;
              List<Entity> list = worldIn.getEntitiesWithinAABBExcludingEntity(playerIn, playerIn.getEntityBoundingBox().expand(vec3d2.x * 5.0D, vec3d2.y * 5.0D, vec3d2.z * 5.0D).grow(1.0D));
  
              for (Entity entity : list) {
                  if (entity.canBeCollidedWith()) {
                      AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox().grow(entity.getCollisionBorderSize());
  
                      if (axisalignedbb.contains(vec3d)) {
                          flag = true;
                      }
                  }
              }
  
              if (flag)
              {
                  return new ActionResult<>(EnumActionResult.PASS, itemstack);
              }
              else if (raytraceresult.typeOfHit != RayTraceResult.Type.BLOCK)
              {
                  return new ActionResult<>(EnumActionResult.PASS, itemstack);
              }
              else
              {
                  Block block = worldIn.getBlockState(raytraceresult.getBlockPos()).getBlock();
                  boolean flag1 = block == Blocks.WATER || block == Blocks.FLOWING_WATER;
                  EntityHoverCraft entityboat = new EntityHoverCraft(worldIn, raytraceresult.hitVec.x, flag1 ? raytraceresult.hitVec.y - 0.12D : raytraceresult.hitVec.y, raytraceresult.hitVec.z);
                  entityboat.rotationYaw = playerIn.rotationYaw;
  
                  if (!worldIn.getCollisionBoxes(entityboat, entityboat.getEntityBoundingBox().grow(-0.1D)).isEmpty())
                  {
                      return new ActionResult<>(EnumActionResult.FAIL, itemstack);
                  }
                  else
                  {
                      if (!worldIn.isRemote)
                      {
                          worldIn.spawnEntity(entityboat);
                      }
  
                      if (!playerIn.capabilities.isCreativeMode)
                      {
                          itemstack.shrink(1);
                      }
  
                      playerIn.addStat(StatList.getObjectUseStats(this));
                      return new ActionResult<>(EnumActionResult.SUCCESS, itemstack);
                  }
              }
          }
      }
      
      @Override
      public void addInformation(@Nonnull ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
      	tooltip.add(LibVulpes.proxy.getLocalizedString("item.hovercraft.tooltip"));
      }
  }
  