示例#1
0
        private Vec3D func_298_c(IBlockAccess iblockaccess, int i, int j, int k)
        {
            Vec3D vec3d = 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);
        }
示例#2
0
        public override ItemStack onItemRightClick(ItemStack itemstack, World world, 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) * f;
            double d1 = (entityplayer.prevPosY + (entityplayer.posY - entityplayer.prevPosY) * f +
                         1.6200000000000001D) - entityplayer.yOffset;
            double d2     = entityplayer.prevPosZ + (entityplayer.posZ - entityplayer.prevPosZ) * f;
            Vec3D  vec3d  = Vec3D.createVector(d, d1, d2);
            float  f3     = MathHelper.cos(-f2 * 0.01745329F - 3.141593F);
            float  f4     = MathHelper.sin(-f2 * 0.01745329F - 3.141593F);
            float  f5     = -MathHelper.cos(-f1 * 0.01745329F);
            float  f6     = MathHelper.sin(-f1 * 0.01745329F);
            float  f7     = f4 * f5;
            float  f8     = f6;
            float  f9     = f3 * f5;
            double d3     = 5D;
            Vec3D  vec3d1 = vec3d.addVector(f7 * d3, f8 * d3, f9 * d3);
            MovingObjectPosition movingobjectposition = world.rayTraceBlocks_do(vec3d, vec3d1, isFull == 0);

            if (movingobjectposition == null)
            {
                return(itemstack);
            }
            if (movingobjectposition.typeOfHit == 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) == Material.water && world.getBlockMetadata(i, j, k) == 0)
                    {
                        world.setBlockWithNotify(i, j, k, 0);
                        return(new ItemStack(bucketWater));
                    }
                    if (world.getBlockMaterial(i, j, k) == Material.lava && world.getBlockMetadata(i, j, k) == 0)
                    {
                        world.setBlockWithNotify(i, j, k, 0);
                        return(new ItemStack(bucketLava));
                    }
                }
                else
                {
                    if (isFull < 0)
                    {
                        return(new ItemStack(bucketEmpty));
                    }
                    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 == Block.waterStill.blockID)
                        {
                            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", i + Math.random(), j + Math.random(),
                                                    k + Math.random(), 0.0D, 0.0D, 0.0D);
                            }
                        }
                        else
                        {
                            world.setBlockAndMetadataWithNotify(i, j, k, isFull, 0);
                        }
                        return(new ItemStack(bucketEmpty));
                    }
                }
            }
            else if (isFull == 0 && (movingobjectposition.entityHit is EntityCow))
            {
                return(new ItemStack(bucketMilk));
            }
            return(itemstack);
        }
示例#3
0
        public virtual MovingObjectPosition collisionRayTrace(World world, int i, int j, int k, Vec3D vec3d,
                                                              Vec3D vec3d1)
        {
            setBlockBoundsBasedOnState(world, i, j, k);
            vec3d  = vec3d.addVector(-i, -j, -k);
            vec3d1 = vec3d1.addVector(-i, -j, -k);
            Vec3D vec3d2 = vec3d.getIntermediateWithXValue(vec3d1, minX);
            Vec3D vec3d3 = vec3d.getIntermediateWithXValue(vec3d1, maxX);
            Vec3D vec3d4 = vec3d.getIntermediateWithYValue(vec3d1, minY);
            Vec3D vec3d5 = vec3d.getIntermediateWithYValue(vec3d1, maxY);
            Vec3D vec3d6 = vec3d.getIntermediateWithZValue(vec3d1, minZ);
            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;
            }
            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);
            }
            sbyte byte0 = -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 MovingObjectPosition(i, j, k, byte0, vec3d8.addVector(i, j, k)));
        }