当前位置: 首页>>代码示例>>C#>>正文


C# World.setBlock方法代码示例

本文整理汇总了C#中CraftyServer.Core.World.setBlock方法的典型用法代码示例。如果您正苦于以下问题:C# World.setBlock方法的具体用法?C# World.setBlock怎么用?C# World.setBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CraftyServer.Core.World的用法示例。


在下文中一共展示了World.setBlock方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: func_21027_b

 public void func_21027_b(World world, int i, int j, int k, Random random)
 {
     world.setBlock(i, j, k, 0);
     object obj = new WorldGenTrees();
     if (random.nextInt(10) == 0)
     {
         obj = new WorldGenBigTree();
     }
     if (!((WorldGenerator) (obj)).generate(world, random, i, j, k))
     {
         world.setBlock(i, j, k, blockID);
     }
 }
开发者ID:riverar,项目名称:Crafty,代码行数:13,代码来源:BlockSapling.cs

示例2: generate

        public override bool generate(World world, Random random, int i, int j, int k)
        {
            for (int l = 0; l < 20; l++)
            {
                int i1 = (i + random.nextInt(4)) - random.nextInt(4);
                int j1 = j;
                int k1 = (k + random.nextInt(4)) - random.nextInt(4);
                if (!world.isAirBlock(i1, j1, k1) ||
                    world.getBlockMaterial(i1 - 1, j1 - 1, k1) != Material.water &&
                    world.getBlockMaterial(i1 + 1, j1 - 1, k1) != Material.water &&
                    world.getBlockMaterial(i1, j1 - 1, k1 - 1) != Material.water &&
                    world.getBlockMaterial(i1, j1 - 1, k1 + 1) != Material.water)
                {
                    continue;
                }
                int l1 = 2 + random.nextInt(random.nextInt(3) + 1);
                for (int i2 = 0; i2 < l1; i2++)
                {
                    if (Block.reed.canBlockStay(world, i1, j1 + i2, k1))
                    {
                        world.setBlock(i1, j1 + i2, k1, Block.reed.blockID);
                    }
                }
            }

            return true;
        }
开发者ID:riverar,项目名称:Crafty,代码行数:27,代码来源:WorldGenReed.cs

示例3: generate

        public override bool generate(World world, Random random, int i, int j, int k)
        {
            for (int l = 0; l < 64; l++)
            {
                int i1 = (i + random.nextInt(8)) - random.nextInt(8);
                int j1 = (j + random.nextInt(4)) - random.nextInt(4);
                int k1 = (k + random.nextInt(8)) - random.nextInt(8);
                if (world.isAirBlock(i1, j1, k1) &&
                    (Block.blocksList[plantBlockId]).canBlockStay(world, i1, j1, k1))
                {
                    world.setBlock(i1, j1, k1, plantBlockId);
                }
            }

            return true;
        }
开发者ID:riverar,项目名称:Crafty,代码行数:16,代码来源:WorldGenFlowers.cs

示例4: generate

        public override bool generate(World world, Random random, int i, int j, int k)
        {
            if (world.getBlockMaterial(i, j, k) != Material.water)
            {
                return false;
            }
            float f = random.nextFloat()*3.141593F;
            double d = (i + 8) + (MathHelper.sin(f)*numberOfBlocks)/8F;
            double d1 = (i + 8) - (MathHelper.sin(f)*numberOfBlocks)/8F;
            double d2 = (k + 8) + (MathHelper.cos(f)*numberOfBlocks)/8F;
            double d3 = (k + 8) - (MathHelper.cos(f)*numberOfBlocks)/8F;
            double d4 = j + random.nextInt(3) + 2;
            double d5 = j + random.nextInt(3) + 2;
            for (int l = 0; l <= numberOfBlocks; l++)
            {
                double d6 = d + ((d1 - d)*l)/numberOfBlocks;
                double d7 = d4 + ((d5 - d4)*l)/numberOfBlocks;
                double d8 = d2 + ((d3 - d2)*l)/numberOfBlocks;
                double d9 = (random.nextDouble()*numberOfBlocks)/16D;
                double d10 = (MathHelper.sin((l*3.141593F)/numberOfBlocks) + 1.0F)*d9 + 1.0D;
                double d11 = (MathHelper.sin((l*3.141593F)/numberOfBlocks) + 1.0F)*d9 + 1.0D;
                for (var i1 = (int) (d6 - d10/2D); i1 <= (int) (d6 + d10/2D); i1++)
                {
                    for (var j1 = (int) (d7 - d11/2D); j1 <= (int) (d7 + d11/2D); j1++)
                    {
                        for (var k1 = (int) (d8 - d10/2D); k1 <= (int) (d8 + d10/2D); k1++)
                        {
                            double d12 = ((i1 + 0.5D) - d6)/(d10/2D);
                            double d13 = ((j1 + 0.5D) - d7)/(d11/2D);
                            double d14 = ((k1 + 0.5D) - d8)/(d10/2D);
                            if (d12*d12 + d13*d13 + d14*d14 >= 1.0D)
                            {
                                continue;
                            }
                            int l1 = world.getBlockId(i1, j1, k1);
                            if (l1 == Block.sand.blockID)
                            {
                                world.setBlock(i1, j1, k1, clayBlockId);
                            }
                        }
                    }
                }
            }

            return true;
        }
开发者ID:riverar,项目名称:Crafty,代码行数:46,代码来源:WorldGenClay.cs

示例5: generate

        public override bool generate(World world, Random random, int i, int j, int k)
        {
            for (int l = 0; l < 10; l++)
            {
                int i1 = (i + random.nextInt(8)) - random.nextInt(8);
                int j1 = (j + random.nextInt(4)) - random.nextInt(4);
                int k1 = (k + random.nextInt(8)) - random.nextInt(8);
                if (!world.isAirBlock(i1, j1, k1))
                {
                    continue;
                }
                int l1 = 1 + random.nextInt(random.nextInt(3) + 1);
                for (int i2 = 0; i2 < l1; i2++)
                {
                    if (Block.cactus.canBlockStay(world, i1, j1 + i2, k1))
                    {
                        world.setBlock(i1, j1 + i2, k1, Block.cactus.blockID);
                    }
                }
            }

            return true;
        }
开发者ID:riverar,项目名称:Crafty,代码行数:23,代码来源:WorldGenCactus.cs

示例6: generate

        public override bool generate(World world, Random random, int i, int j, int k)
        {
            int l = random.nextInt(5) + 7;
            int i1 = l - random.nextInt(2) - 3;
            int j1 = l - i1;
            int k1 = 1 + random.nextInt(j1 + 1);
            bool flag = true;
            if (j < 1 || j + l + 1 > 128)
            {
                return false;
            }
            for (int l1 = j; l1 <= j + 1 + l && flag; l1++)
            {
                int j2 = 1;
                if (l1 - j < i1)
                {
                    j2 = 0;
                }
                else
                {
                    j2 = k1;
                }
                for (int l2 = i - j2; l2 <= i + j2 && flag; l2++)
                {
                    for (int k3 = k - j2; k3 <= k + j2 && flag; k3++)
                    {
                        if (l1 >= 0 && l1 < 128)
                        {
                            int j4 = world.getBlockId(l2, l1, k3);
                            if (j4 != 0 && j4 != Block.leaves.blockID)
                            {
                                flag = false;
                            }
                        }
                        else
                        {
                            flag = false;
                        }
                    }
                }
            }

            if (!flag)
            {
                return false;
            }
            int i2 = world.getBlockId(i, j - 1, k);
            if (i2 != Block.grass.blockID && i2 != Block.dirt.blockID || j >= 128 - l - 1)
            {
                return false;
            }
            world.setBlock(i, j - 1, k, Block.dirt.blockID);
            int k2 = 0;
            for (int i3 = j + l; i3 >= j + i1; i3--)
            {
                for (int l3 = i - k2; l3 <= i + k2; l3++)
                {
                    int k4 = l3 - i;
                    for (int l4 = k - k2; l4 <= k + k2; l4++)
                    {
                        int i5 = l4 - k;
                        if ((Math.abs(k4) != k2 || Math.abs(i5) != k2 || k2 <= 0) &&
                            !Block.opaqueCubeLookup[world.getBlockId(l3, i3, l4)])
                        {
                            world.setBlockAndMetadata(l3, i3, l4, Block.leaves.blockID, 1);
                        }
                    }
                }

                if (k2 >= 1 && i3 == j + i1 + 1)
                {
                    k2--;
                    continue;
                }
                if (k2 < k1)
                {
                    k2++;
                }
            }

            for (int j3 = 0; j3 < l - 1; j3++)
            {
                int i4 = world.getBlockId(i, j + j3, k);
                if (i4 == 0 || i4 == Block.leaves.blockID)
                {
                    world.setBlockAndMetadata(i, j + j3, k, Block.wood.blockID, 1);
                }
            }

            return true;
        }
开发者ID:riverar,项目名称:Crafty,代码行数:91,代码来源:WorldGenTaiga1.cs

示例7: generate

        public override bool generate(World world, Random random, int i, int j, int k)
        {
            i -= 8;
            for (k -= 8; j > 0 && world.isAirBlock(i, j, k); j--)
            {
            }
            j -= 4;
            var aflag = new bool[2048];
            int l = random.nextInt(4) + 4;
            for (int i1 = 0; i1 < l; i1++)
            {
                double d = random.nextDouble()*6D + 3D;
                double d1 = random.nextDouble()*4D + 2D;
                double d2 = random.nextDouble()*6D + 3D;
                double d3 = random.nextDouble()*(16D - d - 2D) + 1.0D + d/2D;
                double d4 = random.nextDouble()*(8D - d1 - 4D) + 2D + d1/2D;
                double d5 = random.nextDouble()*(16D - d2 - 2D) + 1.0D + d2/2D;
                for (int j4 = 1; j4 < 15; j4++)
                {
                    for (int k4 = 1; k4 < 15; k4++)
                    {
                        for (int l4 = 1; l4 < 7; l4++)
                        {
                            double d6 = (j4 - d3)/(d/2D);
                            double d7 = (l4 - d4)/(d1/2D);
                            double d8 = (k4 - d5)/(d2/2D);
                            double d9 = d6*d6 + d7*d7 + d8*d8;
                            if (d9 < 1.0D)
                            {
                                aflag[(j4*16 + k4)*8 + l4] = true;
                            }
                        }
                    }
                }
            }

            for (int j1 = 0; j1 < 16; j1++)
            {
                for (int j2 = 0; j2 < 16; j2++)
                {
                    for (int j3 = 0; j3 < 8; j3++)
                    {
                        bool flag = !aflag[(j1*16 + j2)*8 + j3] &&
                                    (j1 < 15 && aflag[((j1 + 1)*16 + j2)*8 + j3] ||
                                     j1 > 0 && aflag[((j1 - 1)*16 + j2)*8 + j3] ||
                                     j2 < 15 && aflag[(j1*16 + (j2 + 1))*8 + j3] ||
                                     j2 > 0 && aflag[(j1*16 + (j2 - 1))*8 + j3] ||
                                     j3 < 7 && aflag[(j1*16 + j2)*8 + (j3 + 1)] ||
                                     j3 > 0 && aflag[(j1*16 + j2)*8 + (j3 - 1)]);
                        if (!flag)
                        {
                            continue;
                        }
                        Material material = world.getBlockMaterial(i + j1, j + j3, k + j2);
                        if (j3 >= 4 && material.getIsLiquid())
                        {
                            return false;
                        }
                        if (j3 < 4 && !material.isSolid() && world.getBlockId(i + j1, j + j3, k + j2) != field_15005_a)
                        {
                            return false;
                        }
                    }
                }
            }

            for (int k1 = 0; k1 < 16; k1++)
            {
                for (int k2 = 0; k2 < 16; k2++)
                {
                    for (int k3 = 0; k3 < 8; k3++)
                    {
                        if (aflag[(k1*16 + k2)*8 + k3])
                        {
                            world.setBlock(i + k1, j + k3, k + k2, k3 < 4 ? field_15005_a : 0);
                        }
                    }
                }
            }

            for (int l1 = 0; l1 < 16; l1++)
            {
                for (int l2 = 0; l2 < 16; l2++)
                {
                    for (int l3 = 4; l3 < 8; l3++)
                    {
                        if (aflag[(l1*16 + l2)*8 + l3] &&
                            world.getBlockId(i + l1, (j + l3) - 1, k + l2) == Block.dirt.blockID &&
                            world.getSavedLightValue(EnumSkyBlock.Sky, i + l1, j + l3, k + l2) > 0)
                        {
                            world.setBlock(i + l1, (j + l3) - 1, k + l2, Block.grass.blockID);
                        }
                    }
                }
            }

            if (Block.blocksList[field_15005_a].blockMaterial == Material.lava)
            {
                for (int i2 = 0; i2 < 16; i2++)
                {
//.........这里部分代码省略.........
开发者ID:riverar,项目名称:Crafty,代码行数:101,代码来源:WorldGenLakes.cs

示例8: generate

        public override bool generate(World world, Random random, int i, int j, int k)
        {
            int l = random.nextInt(3) + 4;
            bool flag = true;
            if (j < 1 || j + l + 1 > 128)
            {
                return false;
            }
            for (int i1 = j; i1 <= j + 1 + l; i1++)
            {
                byte byte0 = 1;
                if (i1 == j)
                {
                    byte0 = 0;
                }
                if (i1 >= (j + 1 + l) - 2)
                {
                    byte0 = 2;
                }
                for (int i2 = i - byte0; i2 <= i + byte0 && flag; i2++)
                {
                    for (int l2 = k - byte0; l2 <= k + byte0 && flag; l2++)
                    {
                        if (i1 >= 0 && i1 < 128)
                        {
                            int j3 = world.getBlockId(i2, i1, l2);
                            if (j3 != 0 && j3 != Block.leaves.blockID)
                            {
                                flag = false;
                            }
                        }
                        else
                        {
                            flag = false;
                        }
                    }
                }
            }

            if (!flag)
            {
                return false;
            }
            int j1 = world.getBlockId(i, j - 1, k);
            if (j1 != Block.grass.blockID && j1 != Block.dirt.blockID || j >= 128 - l - 1)
            {
                return false;
            }
            world.setBlock(i, j - 1, k, Block.dirt.blockID);
            for (int k1 = (j - 3) + l; k1 <= j + l; k1++)
            {
                int j2 = k1 - (j + l);
                int i3 = 1 - j2/2;
                for (int k3 = i - i3; k3 <= i + i3; k3++)
                {
                    int l3 = k3 - i;
                    for (int i4 = k - i3; i4 <= k + i3; i4++)
                    {
                        int j4 = i4 - k;
                        if ((Math.abs(l3) != i3 || Math.abs(j4) != i3 || random.nextInt(2) != 0 && j2 != 0) &&
                            !Block.opaqueCubeLookup[world.getBlockId(k3, k1, i4)])
                        {
                            world.setBlock(k3, k1, i4, Block.leaves.blockID);
                        }
                    }
                }
            }

            for (int l1 = 0; l1 < l; l1++)
            {
                int k2 = world.getBlockId(i, j + l1, k);
                if (k2 == 0 || k2 == Block.leaves.blockID)
                {
                    world.setBlock(i, j + l1, k, Block.wood.blockID);
                }
            }

            return true;
        }
开发者ID:riverar,项目名称:Crafty,代码行数:79,代码来源:WorldGenTrees.cs

示例9: generate

        public override bool generate(World world, Random random, int i, int j, int k)
        {
            int l = random.nextInt(4) + 6;
            int i1 = 1 + random.nextInt(2);
            int j1 = l - i1;
            int k1 = 2 + random.nextInt(2);
            bool flag = true;
            if (j < 1 || j + l + 1 > 128)
            {
                return false;
            }
            for (int l1 = j; l1 <= j + 1 + l && flag; l1++)
            {
                int j2 = 1;
                if (l1 - j < i1)
                {
                    j2 = 0;
                }
                else
                {
                    j2 = k1;
                }
                for (int l2 = i - j2; l2 <= i + j2 && flag; l2++)
                {
                    for (int j3 = k - j2; j3 <= k + j2 && flag; j3++)
                    {
                        if (l1 >= 0 && l1 < 128)
                        {
                            int k3 = world.getBlockId(l2, l1, j3);
                            if (k3 != 0 && k3 != Block.leaves.blockID)
                            {
                                flag = false;
                            }
                        }
                        else
                        {
                            flag = false;
                        }
                    }
                }
            }

            if (!flag)
            {
                return false;
            }
            int i2 = world.getBlockId(i, j - 1, k);
            if (i2 != Block.grass.blockID && i2 != Block.dirt.blockID || j >= 128 - l - 1)
            {
                return false;
            }
            world.setBlock(i, j - 1, k, Block.dirt.blockID);
            int k2 = random.nextInt(2);
            int i3 = 1;
            bool flag1 = false;
            for (int l3 = 0; l3 <= j1; l3++)
            {
                int j4 = (j + l) - l3;
                for (int l4 = i - k2; l4 <= i + k2; l4++)
                {
                    int j5 = l4 - i;
                    for (int k5 = k - k2; k5 <= k + k2; k5++)
                    {
                        int l5 = k5 - k;
                        if ((Math.abs(j5) != k2 || Math.abs(l5) != k2 || k2 <= 0) &&
                            !Block.opaqueCubeLookup[world.getBlockId(l4, j4, k5)])
                        {
                            world.setBlockAndMetadata(l4, j4, k5, Block.leaves.blockID, 1);
                        }
                    }
                }

                if (k2 >= i3)
                {
                    k2 = ((flag1) ? 1 : 0);
                    flag1 = true;
                    if (++i3 > k1)
                    {
                        i3 = k1;
                    }
                }
                else
                {
                    k2++;
                }
            }

            int i4 = random.nextInt(3);
            for (int k4 = 0; k4 < l - i4; k4++)
            {
                int i5 = world.getBlockId(i, j + k4, k);
                if (i5 == 0 || i5 == Block.leaves.blockID)
                {
                    world.setBlockAndMetadata(i, j + k4, k, Block.wood.blockID, 1);
                }
            }

            return true;
        }
开发者ID:riverar,项目名称:Crafty,代码行数:99,代码来源:WorldGenTaiga2.cs


注:本文中的CraftyServer.Core.World.setBlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。