Exemplo n.º 1
0
        public override net.minecraft.src.ItemStack OnItemRightClick(net.minecraft.src.ItemStack
                                                                     itemstack, net.minecraft.src.World world, net.minecraft.src.EntityPlayer entityplayer
                                                                     )
        {
            float f  = 1.0F;
            float f1 = entityplayer.prevRotationPitch + (entityplayer.rotationPitch - entityplayer
                                                         .prevRotationPitch) * f;
            float f2 = entityplayer.prevRotationYaw + (entityplayer.rotationYaw - entityplayer
                                                       .prevRotationYaw) * f;
            double d = entityplayer.prevPosX + (entityplayer.posX - entityplayer.prevPosX) *
                       (double)f;
            double d1 = (entityplayer.prevPosY + (entityplayer.posY - entityplayer.prevPosY)
                         * (double)f + 1.6200000000000001D) - (double)entityplayer.yOffset;
            double d2 = entityplayer.prevPosZ + (entityplayer.posZ - entityplayer.prevPosZ) *
                        (double)f;

            net.minecraft.src.Vec3D vec3d = net.minecraft.src.Vec3D.CreateVector(d, d1, d2);
            float  f3 = net.minecraft.src.MathHelper.Cos(-f2 * 0.01745329F - 3.141593F);
            float  f4 = net.minecraft.src.MathHelper.Sin(-f2 * 0.01745329F - 3.141593F);
            float  f5 = -net.minecraft.src.MathHelper.Cos(-f1 * 0.01745329F);
            float  f6 = net.minecraft.src.MathHelper.Sin(-f1 * 0.01745329F);
            float  f7 = f4 * f5;
            float  f8 = f6;
            float  f9 = f3 * f5;
            double d3 = 5D;

            net.minecraft.src.Vec3D vec3d1 = vec3d.AddVector((double)f7 * d3, (double)f8 * d3
                                                             , (double)f9 * d3);
            net.minecraft.src.MovingObjectPosition movingobjectposition = world.RayTraceBlocks_do
                                                                              (vec3d, vec3d1, true);
            if (movingobjectposition == null)
            {
                return(itemstack);
            }
            if (movingobjectposition.typeOfHit == net.minecraft.src.EnumMovingObjectType.TILE)
            {
                int i = movingobjectposition.blockX;
                int j = movingobjectposition.blockY;
                int k = movingobjectposition.blockZ;
                if (!world.singleplayerWorld)
                {
                    if (world.GetBlockId(i, j, k) == net.minecraft.src.Block.SNOW.ID)
                    {
                        j--;
                    }
                    world.AddEntity(new net.minecraft.src.EntityBoat(world, (float)i + 0.5F,
                                                                     (float)j + 1.0F, (float)k + 0.5F));
                }
                itemstack.stackSize--;
            }
            return(itemstack);
        }
Exemplo n.º 2
0
        public virtual net.minecraft.src.MovingObjectPosition CollisionRayTrace(net.minecraft.src.World
                                                                                world, int i, int j, int k, net.minecraft.src.Vec3D vec3d, net.minecraft.src.Vec3D
                                                                                vec3d1)
        {
            SetBlockBoundsBasedOnState(world, i, j, k);
            vec3d  = vec3d.AddVector(-i, -j, -k);
            vec3d1 = vec3d1.AddVector(-i, -j, -k);
            net.minecraft.src.Vec3D vec3d2 = vec3d.GetIntermediateWithXValue(vec3d1, minX);
            net.minecraft.src.Vec3D vec3d3 = vec3d.GetIntermediateWithXValue(vec3d1, maxX);
            net.minecraft.src.Vec3D vec3d4 = vec3d.GetIntermediateWithYValue(vec3d1, minY);
            net.minecraft.src.Vec3D vec3d5 = vec3d.GetIntermediateWithYValue(vec3d1, maxY);
            net.minecraft.src.Vec3D vec3d6 = vec3d.GetIntermediateWithZValue(vec3d1, minZ);
            net.minecraft.src.Vec3D vec3d7 = vec3d.GetIntermediateWithZValue(vec3d1, maxZ);
            if (!IsVecInsideYZBounds(vec3d2))
            {
                vec3d2 = null;
            }
            if (!IsVecInsideYZBounds(vec3d3))
            {
                vec3d3 = null;
            }
            if (!IsVecInsideXZBounds(vec3d4))
            {
                vec3d4 = null;
            }
            if (!IsVecInsideXZBounds(vec3d5))
            {
                vec3d5 = null;
            }
            if (!IsVecInsideXYBounds(vec3d6))
            {
                vec3d6 = null;
            }
            if (!IsVecInsideXYBounds(vec3d7))
            {
                vec3d7 = null;
            }
            net.minecraft.src.Vec3D vec3d8 = null;
            if (vec3d2 != null && (vec3d8 == null || vec3d.DistanceTo(vec3d2) < vec3d.DistanceTo
                                       (vec3d8)))
            {
                vec3d8 = vec3d2;
            }
            if (vec3d3 != null && (vec3d8 == null || vec3d.DistanceTo(vec3d3) < vec3d.DistanceTo
                                       (vec3d8)))
            {
                vec3d8 = vec3d3;
            }
            if (vec3d4 != null && (vec3d8 == null || vec3d.DistanceTo(vec3d4) < vec3d.DistanceTo
                                       (vec3d8)))
            {
                vec3d8 = vec3d4;
            }
            if (vec3d5 != null && (vec3d8 == null || vec3d.DistanceTo(vec3d5) < vec3d.DistanceTo
                                       (vec3d8)))
            {
                vec3d8 = vec3d5;
            }
            if (vec3d6 != null && (vec3d8 == null || vec3d.DistanceTo(vec3d6) < vec3d.DistanceTo
                                       (vec3d8)))
            {
                vec3d8 = vec3d6;
            }
            if (vec3d7 != null && (vec3d8 == null || vec3d.DistanceTo(vec3d7) < vec3d.DistanceTo
                                       (vec3d8)))
            {
                vec3d8 = vec3d7;
            }
            if (vec3d8 == null)
            {
                return(null);
            }
            byte byte0 = unchecked ((byte)(-1));

            if (vec3d8 == vec3d2)
            {
                byte0 = 4;
            }
            if (vec3d8 == vec3d3)
            {
                byte0 = 5;
            }
            if (vec3d8 == vec3d4)
            {
                byte0 = 0;
            }
            if (vec3d8 == vec3d5)
            {
                byte0 = 1;
            }
            if (vec3d8 == vec3d6)
            {
                byte0 = 2;
            }
            if (vec3d8 == vec3d7)
            {
                byte0 = 3;
            }
            return(new net.minecraft.src.MovingObjectPosition(i, j, k, byte0, vec3d8.AddVector
                                                                  (i, j, k)));
        }
Exemplo n.º 3
0
        private net.minecraft.src.Vec3D Func_298_c(net.minecraft.src.IBlockAccess iblockaccess
                                                   , int i, int j, int k)
        {
            net.minecraft.src.Vec3D vec3d = net.minecraft.src.Vec3D.CreateVector(0.0D, 0.0D,
                                                                                 0.0D);
            int l = Func_303_b(iblockaccess, i, j, k);

            for (int i1 = 0; i1 < 4; i1++)
            {
                int j1 = i;
                int k1 = j;
                int l1 = k;
                if (i1 == 0)
                {
                    j1--;
                }
                if (i1 == 1)
                {
                    l1--;
                }
                if (i1 == 2)
                {
                    j1++;
                }
                if (i1 == 3)
                {
                    l1++;
                }
                int i2 = Func_303_b(iblockaccess, j1, k1, l1);
                if (i2 < 0)
                {
                    if (iblockaccess.GetBlockMaterial(j1, k1, l1).GetIsSolid())
                    {
                        continue;
                    }
                    i2 = Func_303_b(iblockaccess, j1, k1 - 1, l1);
                    if (i2 >= 0)
                    {
                        int j2 = i2 - (l - 8);
                        vec3d = vec3d.AddVector((j1 - i) * j2, (k1 - j) * j2, (l1 - k) * j2);
                    }
                    continue;
                }
                if (i2 >= 0)
                {
                    int k2 = i2 - l;
                    vec3d = vec3d.AddVector((j1 - i) * k2, (k1 - j) * k2, (l1 - k) * k2);
                }
            }
            if (iblockaccess.GetBlockMetadata(i, j, k) >= 8)
            {
                bool flag = false;
                if (flag || ShouldSideBeRendered(iblockaccess, i, j, k - 1, 2))
                {
                    flag = true;
                }
                if (flag || ShouldSideBeRendered(iblockaccess, i, j, k + 1, 3))
                {
                    flag = true;
                }
                if (flag || ShouldSideBeRendered(iblockaccess, i - 1, j, k, 4))
                {
                    flag = true;
                }
                if (flag || ShouldSideBeRendered(iblockaccess, i + 1, j, k, 5))
                {
                    flag = true;
                }
                if (flag || ShouldSideBeRendered(iblockaccess, i, j + 1, k - 1, 2))
                {
                    flag = true;
                }
                if (flag || ShouldSideBeRendered(iblockaccess, i, j + 1, k + 1, 3))
                {
                    flag = true;
                }
                if (flag || ShouldSideBeRendered(iblockaccess, i - 1, j + 1, k, 4))
                {
                    flag = true;
                }
                if (flag || ShouldSideBeRendered(iblockaccess, i + 1, j + 1, k, 5))
                {
                    flag = true;
                }
                if (flag)
                {
                    vec3d = vec3d.Normalize().AddVector(0.0D, -6D, 0.0D);
                }
            }
            vec3d = vec3d.Normalize();
            return(vec3d);
        }
Exemplo n.º 4
0
        public override net.minecraft.src.ItemStack OnItemRightClick(net.minecraft.src.ItemStack
                                                                     itemstack, net.minecraft.src.World world, net.minecraft.src.EntityPlayer entityplayer
                                                                     )
        {
            float f  = 1.0F;
            float f1 = entityplayer.prevRotationPitch + (entityplayer.rotationPitch - entityplayer
                                                         .prevRotationPitch) * f;
            float f2 = entityplayer.prevRotationYaw + (entityplayer.rotationYaw - entityplayer
                                                       .prevRotationYaw) * f;
            double d = entityplayer.prevPosX + (entityplayer.posX - entityplayer.prevPosX) *
                       (double)f;
            double d1 = (entityplayer.prevPosY + (entityplayer.posY - entityplayer.prevPosY)
                         * (double)f + 1.6200000000000001D) - (double)entityplayer.yOffset;
            double d2 = entityplayer.prevPosZ + (entityplayer.posZ - entityplayer.prevPosZ) *
                        (double)f;

            net.minecraft.src.Vec3D vec3d = net.minecraft.src.Vec3D.CreateVector(d, d1, d2);
            float  f3 = net.minecraft.src.MathHelper.Cos(-f2 * 0.01745329F - 3.141593F);
            float  f4 = net.minecraft.src.MathHelper.Sin(-f2 * 0.01745329F - 3.141593F);
            float  f5 = -net.minecraft.src.MathHelper.Cos(-f1 * 0.01745329F);
            float  f6 = net.minecraft.src.MathHelper.Sin(-f1 * 0.01745329F);
            float  f7 = f4 * f5;
            float  f8 = f6;
            float  f9 = f3 * f5;
            double d3 = 5D;

            net.minecraft.src.Vec3D vec3d1 = vec3d.AddVector((double)f7 * d3, (double)f8 * d3
                                                             , (double)f9 * d3);
            net.minecraft.src.MovingObjectPosition movingobjectposition = world.RayTraceBlocks_do
                                                                              (vec3d, vec3d1, isFull == 0);
            if (movingobjectposition == null)
            {
                return(itemstack);
            }
            if (movingobjectposition.typeOfHit == net.minecraft.src.EnumMovingObjectType.TILE)
            {
                int i = movingobjectposition.blockX;
                int j = movingobjectposition.blockY;
                int k = movingobjectposition.blockZ;
                if (!world.CanMineBlock(entityplayer, i, j, k))
                {
                    return(itemstack);
                }
                if (isFull == 0)
                {
                    if (world.GetBlockMaterial(i, j, k) == net.minecraft.src.Material.water && world.
                        GetBlockMetadata(i, j, k) == 0)
                    {
                        world.SetBlockWithNotify(i, j, k, 0);
                        return(new net.minecraft.src.ItemStack(net.minecraft.src.Item.WATER_BUCKET));
                    }
                    if (world.GetBlockMaterial(i, j, k) == net.minecraft.src.Material.lava && world.GetBlockMetadata
                            (i, j, k) == 0)
                    {
                        world.SetBlockWithNotify(i, j, k, 0);
                        return(new net.minecraft.src.ItemStack(net.minecraft.src.Item.LAVA_BUCKET));
                    }
                }
                else
                {
                    if (isFull < 0)
                    {
                        return(new net.minecraft.src.ItemStack(net.minecraft.src.Item.BUCKET));
                    }
                    if (movingobjectposition.sideHit == 0)
                    {
                        j--;
                    }
                    if (movingobjectposition.sideHit == 1)
                    {
                        j++;
                    }
                    if (movingobjectposition.sideHit == 2)
                    {
                        k--;
                    }
                    if (movingobjectposition.sideHit == 3)
                    {
                        k++;
                    }
                    if (movingobjectposition.sideHit == 4)
                    {
                        i--;
                    }
                    if (movingobjectposition.sideHit == 5)
                    {
                        i++;
                    }
                    if (world.IsAirBlock(i, j, k) || !world.GetBlockMaterial(i, j, k).IsSolid())
                    {
                        if (world.worldProvider.isHellWorld && isFull == net.minecraft.src.Block.WATER
                            .ID)
                        {
                            world.PlaySoundEffect(d + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F, 2.6F +
                                                  (world.rand.NextFloat() - world.rand.NextFloat()) * 0.8F);
                            for (int l = 0; l < 8; l++)
                            {
                                world.SpawnParticle("largesmoke", (double)i + SharpRandom.NextDouble(), (double)j + SharpRandom.NextDouble(), (double)k + SharpRandom.NextDouble(), 0.0D, 0.0D, 0.0D);
                            }
                        }
                        else
                        {
                            world.SetBlockAndMetadataWithNotify(i, j, k, isFull, 0);
                        }
                        return(new net.minecraft.src.ItemStack(net.minecraft.src.Item.BUCKET));
                    }
                }
            }
            else
            {
                if (isFull == 0 && (movingobjectposition.entityHit is net.minecraft.src.EntityCow
                                    ))
                {
                    return(new net.minecraft.src.ItemStack(net.minecraft.src.Item.MILK_BUCKET));
                }
            }
            return(itemstack);
        }