    001    package net.minecraft.src;
    002
    003    import java.util.Iterator;
    004    import java.util.List;
    005
    006    public class ItemBoat extends Item
    007    {
    008        public ItemBoat(int par1)
    009        {
    010            super(par1);
    011            this.maxStackSize = 1;
    012            this.setCreativeTab(CreativeTabs.tabTransport);
    013        }
    014
    015        /**
    016         * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
    017         */
    018        public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    019        {
    020            float var4 = 1.0F;
    021            float var5 = par3EntityPlayer.prevRotationPitch + (par3EntityPlayer.rotationPitch - par3EntityPlayer.prevRotationPitch) * var4;
    022            float var6 = par3EntityPlayer.prevRotationYaw + (par3EntityPlayer.rotationYaw - par3EntityPlayer.prevRotationYaw) * var4;
    023            double var7 = par3EntityPlayer.prevPosX + (par3EntityPlayer.posX - par3EntityPlayer.prevPosX) * (double)var4;
    024            double var9 = par3EntityPlayer.prevPosY + (par3EntityPlayer.posY - par3EntityPlayer.prevPosY) * (double)var4 + 1.62D - (double)par3EntityPlayer.yOffset;
    025            double var11 = par3EntityPlayer.prevPosZ + (par3EntityPlayer.posZ - par3EntityPlayer.prevPosZ) * (double)var4;
    026            Vec3 var13 = par2World.getWorldVec3Pool().getVecFromPool(var7, var9, var11);
    027            float var14 = MathHelper.cos(-var6 * 0.017453292F - (float)Math.PI);
    028            float var15 = MathHelper.sin(-var6 * 0.017453292F - (float)Math.PI);
    029            float var16 = -MathHelper.cos(-var5 * 0.017453292F);
    030            float var17 = MathHelper.sin(-var5 * 0.017453292F);
    031            float var18 = var15 * var16;
    032            float var20 = var14 * var16;
    033            double var21 = 5.0D;
    034            Vec3 var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21);
    035            MovingObjectPosition var24 = par2World.rayTraceBlocks_do(var13, var23, true);
    036
    037            if (var24 == null)
    038            {
    039                return par1ItemStack;
    040            }
    041            else
    042            {
    043                Vec3 var25 = par3EntityPlayer.getLook(var4);
    044                boolean var26 = false;
    045                float var27 = 1.0F;
    046                List var28 = par2World.getEntitiesWithinAABBExcludingEntity(par3EntityPlayer, par3EntityPlayer.boundingBox.addCoord(var25.xCoord * var21, var25.yCoord * var21, var25.zCoord * var21).expand((double)var27, (double)var27, (double)var27));
    047                Iterator var29 = var28.iterator();
    048
    049                while (var29.hasNext())
    050                {
    051                    Entity var30 = (Entity)var29.next();
    052
    053                    if (var30.canBeCollidedWith())
    054                    {
    055                        float var31 = var30.getCollisionBorderSize();
    056                        AxisAlignedBB var32 = var30.boundingBox.expand((double)var31, (double)var31, (double)var31);
    057
    058                        if (var32.isVecInside(var13))
    059                        {
    060                            var26 = true;
    061                        }
    062                    }
    063                }
    064
    065                if (var26)
    066                {
    067                    return par1ItemStack;
    068                }
    069                else
    070                {
    071                    if (var24.typeOfHit == EnumMovingObjectType.TILE)
    072                    {
    073                        int var35 = var24.blockX;
    074                        int var33 = var24.blockY;
    075                        int var34 = var24.blockZ;
    076
    077                        if (par2World.getBlockId(var35, var33, var34) == Block.snow.blockID)
    078                        {
    079                            --var33;
    080                        }
    081
    082                        EntityBoat var36 = new EntityBoat(par2World, (double)((float)var35 + 0.5F), (double)((float)var33 + 1.0F), (double)((float)var34 + 0.5F));
    083
    084                        if (!par2World.getCollidingBoundingBoxes(var36, var36.boundingBox.expand(-0.1D, -0.1D, -0.1D)).isEmpty())
    085                        {
    086                            return par1ItemStack;
    087                        }
    088
    089                        if (!par2World.isRemote)
    090                        {
    091                            par2World.spawnEntityInWorld(var36);
    092                        }
    093
    094                        if (!par3EntityPlayer.capabilities.isCreativeMode)
    095                        {
    096                            --par1ItemStack.stackSize;
    097                        }
    098                    }
    099
    100                    return par1ItemStack;
    101                }
    102            }
    103        }
    104    }