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