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


C# World.GetBlock方法代码示例

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


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

示例1: generate

        public override bool generate(World world, java.util.Random random, int i, int j, int k)
        {
            if (BlockData.BlockMaterial(world.GetBlock(i, j, k)) != Material.Water)
            {
                return false;
            }
            int l = random.nextInt(numberOfBlocks - 2) + 2;
            int i1 = 1;
            for (int j1 = i - l; j1 <= i + l; j1++)
            {
                for (int k1 = k - l; k1 <= k + l; k1++)
                {
                    int l1 = j1 - i;
                    int i2 = k1 - k;
                    if (l1 * l1 + i2 * i2 > l * l)
                    {
                        continue;
                    }
                    for (int j2 = j - i1; j2 <= j + i1; j2++)
                    {
                        int k2 = world.GetBlock(j1, j2, k1);
                        if (k2 == (byte)Blocks.Dirt || k2 == (byte)Blocks.ClayBlock)
                        {
                            world.SetBlock(j1, j2, k1, (byte)clayBlockId);
                        }
                    }

                }

            }

            return true;
        }
开发者ID:Nerketur,项目名称:ForgeCraft,代码行数:33,代码来源:WorldGenClay.cs

示例2: OnBlockPlaced

 public override bool OnBlockPlaced(World world, Vector3 position, Vector3 clickedBlock, Vector3 clickedSide, Vector3 cursorPosition, Entities.Entity usedBy)
 {
     var bottom = world.GetBlock(position + Vector3.Down);
     if (bottom is SugarCaneBlock)
     {
         ScheduleUpdate(world, position,
             DateTime.Now.AddSeconds(MathHelper.Random.Next(MinimumGrowthSeconds, MaximumGrowthSeconds)));
         return true;
     }
     if (!(bottom is DirtBlock || bottom is GrassBlock || bottom is SandBlock))
         return false;
     // Look for water
     bool found = false;
     for (int x = -1; x <= 1; x++)
         for (int z = -1; z <= 1; z++)
         {
             var block = world.GetBlock(position + new Vector3(x, -1, z));
             if (block is WaterFlowingBlock || block is WaterStillBlock)
             {
                 found = true;
                 break;
             }
         }
     if (found)
     {
         ScheduleGrowth(world, position);
         return true;
     }
     return false;
 }
开发者ID:cpancake,项目名称:Craft.Net,代码行数:30,代码来源:SugarCaneBlock.cs

示例3: generate

        public override bool generate(World world, java.util.Random random, int i, int j, int k)
        {
            if (BlockData.BlockMaterial(world.GetBlock(i, j, k)) != Material.Water)
            {
                return false;
            }
            int l = random.nextInt(field_35290_b - 2) + 2;
            byte byte0 = 2;
            for (int i1 = i - l; i1 <= i + l; i1++)
            {
                for (int j1 = k - l; j1 <= k + l; j1++)
                {
                    int k1 = i1 - i;
                    int l1 = j1 - k;
                    if (k1 * k1 + l1 * l1 > l * l)
                    {
                        continue;
                    }
                    for (int i2 = j - byte0; i2 <= j + byte0; i2++)
                    {
                        int j2 = world.GetBlock(i1, i2, j1);
                        if (j2 == (byte)Blocks.Dirt || j2 == (byte)Blocks.Grass)
                        {
                            world.SetBlock(i1, i2, j1, (byte)field_35291_a);
                        }
                    }

                }

            }

            return true;
        }
开发者ID:Nerketur,项目名称:ForgeCraft,代码行数:33,代码来源:WorldGenSand.cs

示例4: BlockUpdate

 public override void BlockUpdate(World world, Vector3 updatedBlock, Vector3 modifiedBlock)
 {
     if (!(world.GetBlock(updatedBlock + Vector3.Down) is FarmlandBlock))
     {
         var entity = new ItemEntity(updatedBlock + new Vector3(0.5), new ItemStack(new PumpkinSeedsItem()));
         entity.ApplyRandomVelocity();
         world.SetBlock(updatedBlock, new AirBlock());
         world.OnSpawnEntity(entity);
         return;
     }
     if (!world.UpdatePending(updatedBlock))
     {
         var possibleLocations = new List<Vector3>(new[]
         {
             updatedBlock + Vector3.Left, updatedBlock + Vector3.Right,
             updatedBlock + Vector3.Forwards, updatedBlock + Vector3.Backwards
         });
         bool found = false;
         for (int i = 0; i < possibleLocations.Count; i++)
         {
             if (world.GetBlock(possibleLocations[i]) is PumpkinBlock)
                 found = true;
         }
         if (!found)
             ScheduleGrowth(world, updatedBlock);
     }
     base.BlockUpdate(world, updatedBlock, modifiedBlock);
 }
开发者ID:cpancake,项目名称:Craft.Net,代码行数:28,代码来源:PumpkinStemBlock.cs

示例5: TestBuckets

        public void TestBuckets()
        {
            World world = new World(new Level(), new FlatlandGenerator());
            world.WorldGenerator.Initialize(new Level());
            PlayerEntity player = new PlayerEntity(Difficulty.Normal)
            {
                GameMode = GameMode.Creative
            };
            Vector3 targetBlock = new Vector3(0, 2, 0);
            Vector3 alteredBlock = targetBlock + Vector3.Up;
            world.SetBlock(alteredBlock, new AirBlock());

            BucketItem bucket = new BucketItem();
            LavaBucketItem lavaBucket = new LavaBucketItem();
            WaterBucketItem waterBucket = new WaterBucketItem();

            // TODO: Survival tests
            waterBucket.OnItemUsedOnBlock(world, targetBlock, Vector3.Up, Vector3.Zero, player);
            Assert.AreEqual(new WaterFlowingBlock(), world.GetBlock(alteredBlock));

            bucket.OnItemUsedOnBlock(world, targetBlock, Vector3.Up, Vector3.Zero, player);
            Assert.AreEqual(new AirBlock(), world.GetBlock(alteredBlock));

            lavaBucket.OnItemUsedOnBlock(world, targetBlock, Vector3.Up, Vector3.Zero, player);
            Assert.AreEqual(new LavaFlowingBlock(), world.GetBlock(alteredBlock));

            bucket.OnItemUsedOnBlock(world, targetBlock, Vector3.Up, Vector3.Zero, player);
            Assert.AreEqual(new AirBlock(), world.GetBlock(alteredBlock));

            world.SetBlock(alteredBlock, new BedrockBlock());

            bucket.OnItemUsedOnBlock(world, targetBlock, Vector3.Up, Vector3.Zero, player);
            Assert.AreEqual(new BedrockBlock(), world.GetBlock(alteredBlock));
        }
开发者ID:Imperceptus,项目名称:Craft.Net,代码行数:34,代码来源:ItemTest.cs

示例6: OnItemUsedOnBlock

 public override void OnItemUsedOnBlock(World world, Vector3 clickedBlock, Vector3 clickedSide, Vector3 cursorPosition, Entities.Entity usedBy)
 {
     if (world.GetBlock(clickedBlock) is SoulSandBlock && world.GetBlock(clickedBlock + clickedSide) == 0)
     {
         var seeds = new NetherWartBlock();
         world.SetBlock(clickedBlock + clickedSide, seeds);
         seeds.OnBlockPlaced(world, clickedBlock + clickedSide, clickedBlock, clickedSide, cursorPosition, usedBy);
     }
 }
开发者ID:cpancake,项目名称:Craft.Net,代码行数:9,代码来源:NetherWartItem.cs

示例7: IsWalkable

    public static bool IsWalkable(World world, BlockPos pos)
    {
        if(!world.GetBlock(pos).controller.IsSolid(Direction.up))
            return false;

        for(int y = 1; y< characterHeight+1; y++){
            if (world.GetBlock(pos.Add(0,y,0)).GetType() != typeof(BlockAir))
                return false;
        }

        return true;
    }
开发者ID:holmstrom,项目名称:Voxelmetric,代码行数:12,代码来源:PathFinder.cs

示例8: OnItemUsedOnBlock

 public override void OnItemUsedOnBlock(World world, Vector3 clickedBlock, Vector3 clickedSide, Vector3 cursorPosition, Entities.Entity usedBy)
 {
     var entity = (PlayerEntity)usedBy;
     // TODO: Check for source block
     // TODO: Survival
     if (world.GetBlock(clickedBlock + clickedSide) is WaterFlowingBlock || world.GetBlock(clickedBlock + clickedSide) is WaterStillBlock)
     {
         world.SetBlock(clickedBlock + clickedSide, new AirBlock());
     }
     if (world.GetBlock(clickedBlock + clickedSide) is LavaFlowingBlock || world.GetBlock(clickedBlock + clickedSide) is LavaStillBlock)
     {
         world.SetBlock(clickedBlock + clickedSide, new AirBlock());
     }
 }
开发者ID:ammaraskar,项目名称:Craft.Net,代码行数:14,代码来源:BucketItem.cs

示例9: OnItemUsedOnBlock

 public override void OnItemUsedOnBlock(World world, Vector3 clickedBlock, Vector3 clickedSide, Vector3 cursorPosition, Entities.Entity usedBy)
 {
     if (clickedSide != Vector3.Up)
         return;
     Vector3 away = DataUtility.FowardVector(usedBy);
     var near = world.GetBlock(clickedBlock + clickedSide);
     var far = world.GetBlock(clickedBlock + clickedSide + away);
     if (near is AirBlock && far is AirBlock)
     {
         // Place bed
         world.SetBlock(clickedBlock + clickedSide, new BedBlock(BedBlock.Vector3ToBedDirection(away), false));
         world.SetBlock(clickedBlock + clickedSide + away, new BedBlock(BedBlock.Vector3ToBedDirection(away), true));
     }
 }
开发者ID:Imperceptus,项目名称:Craft.Net,代码行数:14,代码来源:BedItem.cs

示例10: generate

 public override bool generate(World world, java.util.Random random, int i, int j, int k)
 {
     if (world.GetBlock(i, j + 1, k) != (byte)Blocks.Netherrack)
     {
         return false;
     }
     if (world.GetBlock(i, j, k) != 0 && world.GetBlock(i, j, k) != (byte)Blocks.Netherrack)
     {
         return false;
     }
     int l = 0;
     if (world.GetBlock(i - 1, j, k) == (byte)Blocks.Netherrack)
     {
         l++;
     }
     if (world.GetBlock(i + 1, j, k) == (byte)Blocks.Netherrack)
     {
         l++;
     }
     if (world.GetBlock(i, j, k - 1) == (byte)Blocks.Netherrack)
     {
         l++;
     }
     if (world.GetBlock(i, j, k + 1) == (byte)Blocks.Netherrack)
     {
         l++;
     }
     if (world.GetBlock(i, j - 1, k) == (byte)Blocks.Netherrack)
     {
         l++;
     }
     int i1 = 0;
     if (world.IsAirBlock(i - 1, j, k))
     {
         i1++;
     }
     if (world.IsAirBlock(i + 1, j, k))
     {
         i1++;
     }
     if (world.IsAirBlock(i, j, k - 1))
     {
         i1++;
     }
     if (world.IsAirBlock(i, j, k + 1))
     {
         i1++;
     }
     if (world.IsAirBlock(i, j - 1, k))
     {
         i1++;
     }
     if (l == 4 && i1 == 1)
     {
         world.SetBlock(i, j, k, (byte)field_4250_a);
         world.physics.AddCheck(i, j, k);
         //Block.blocksList[field_4250_a].updateTick(world, i, j, k, random);
     }
     return true;
 }
开发者ID:Nerketur,项目名称:ForgeCraft,代码行数:60,代码来源:WorldGenHellLava.cs

示例11: generate

 public override bool generate(World world, java.util.Random random, int i, int j, int k)
 {
     if (world.GetBlock(i, j + 1, k) != (byte)Blocks.Stone)
     {
         return false;
     }
     if (world.GetBlock(i, j - 1, k) != (byte)Blocks.Stone)
     {
         return false;
     }
     if (world.GetBlock(i, j, k) != 0 && world.GetBlock(i, j, k) != (byte)Blocks.Stone)
     {
         return false;
     }
     int l = 0;
     if (world.GetBlock(i - 1, j, k) == (byte)Blocks.Stone)
     {
         l++;
     }
     if (world.GetBlock(i + 1, j, k) == (byte)Blocks.Stone)
     {
         l++;
     }
     if (world.GetBlock(i, j, k - 1) == (byte)Blocks.Stone)
     {
         l++;
     }
     if (world.GetBlock(i, j, k + 1) == (byte)Blocks.Stone)
     {
         l++;
     }
     int i1 = 0;
     if (world.IsAirBlock(i - 1, j, k))
     {
         i1++;
     }
     if (world.IsAirBlock(i + 1, j, k))
     {
         i1++;
     }
     if (world.IsAirBlock(i, j, k - 1))
     {
         i1++;
     }
     if (world.IsAirBlock(i, j, k + 1))
     {
         i1++;
     }
     if (l == 3 && i1 == 1)
     {
         world.SetBlock(i, j, k, (byte)liquidBlockId);
         world.physics.AddCheck(i, j, k, true);
         //world.scheduledUpdatesAreImmediate = true;
         //Block.blocksList[liquidBlockId].updateTick(world, i, j, k, random);
         //world.scheduledUpdatesAreImmediate = false;
     }
     return true;
 }
开发者ID:Nerketur,项目名称:ForgeCraft,代码行数:58,代码来源:WorldGenLiquids.cs

示例12: OnItemUsedOnBlock

 public override void OnItemUsedOnBlock(World world, Vector3 clickedBlock, Vector3 clickedSide, Vector3 cursorPosition, Entities.Entity usedBy)
 {
     if (clickedSide != Vector3.Up)
         return;
     Vector3 away = MathHelper.FowardVector(usedBy, true);
     var near = world.GetBlock(clickedBlock + clickedSide);
     var far = world.GetBlock(clickedBlock + clickedSide + Vector3.Up);
     if (near is AirBlock && far is AirBlock)
     {
         // Place door
         world.SetBlock(clickedBlock + clickedSide,
             new IronDoorBlock(DoorBlock.Vector3ToDoorDirection(away), false));
         world.SetBlock(clickedBlock + clickedSide + Vector3.Up,
             new IronDoorBlock(DoorBlock.Vector3ToDoorDirection(away), true));
     }
 }
开发者ID:ammaraskar,项目名称:Craft.Net,代码行数:16,代码来源:IronDoorItem.cs

示例13: BlockUpdate

 public override void BlockUpdate(World world, Vector3 updatedBlock, Vector3 modifiedBlock)
 {
     var block = world.GetBlock(updatedBlock + Vector3.Up);
     if (!(block is AirBlock) && !(block is IGrowableBlock))
         world.SetBlock(updatedBlock, new DirtBlock());
     base.BlockUpdate(world, updatedBlock, modifiedBlock);
 }
开发者ID:cpancake,项目名称:Craft.Net,代码行数:7,代码来源:FarmlandBlock.cs

示例14: OnScheduledUpdate

 public override void OnScheduledUpdate(World world, Vector3 position)
 {
     // Check for water
     int closest = int.MaxValue;
     for (int y = -1; y < 1; y++ )
         for (int x = -8; x < 8; x++)
             for (int z = -8; z < 8; z++)
             {
                 if (position.Y + y < 0)
                     continue;
                 var blockPosition = new Vector3(x, position.Y + y, z);
                 var block = world.GetBlock(blockPosition);
                 if (block is WaterFlowingBlock || block is WaterStillBlock)
                 {
                     var distance = position.DistanceTo(blockPosition);
                     if (distance < closest)
                         closest = (int)distance;
                 }
             }
     closest = -(closest - 4) + 4;
     Metadata = (byte)closest;
     if (closest >= 5 && MathHelper.Random.Next(5) == 0)
         world.SetBlock(position, new DirtBlock());
     else
     {
         world.SetBlock(position, this);
         ScheduleUpdate(world, position, DateTime.Now.AddSeconds(MathHelper.Random.Next(30, 120)));
     }
     base.OnScheduledUpdate(world, position);
 }
开发者ID:cpancake,项目名称:Craft.Net,代码行数:30,代码来源:FarmlandBlock.cs

示例15: BlockUpdate

 public override void BlockUpdate(World world, Vector3 updatedBlock, Vector3 modifiedBlock)
 {
     if (UpperHalf)
     {
         var block = world.GetBlock(updatedBlock + Vector3.Down);
         if (!(block is DoorBlock))
             world.SetBlock(updatedBlock, new AirBlock());
     }
     else
     {
         var block = world.GetBlock(updatedBlock + Vector3.Up);
         if (!(block is DoorBlock))
             world.SetBlock(updatedBlock, new AirBlock());
     }
     base.BlockUpdate(world, updatedBlock, modifiedBlock);
 }
开发者ID:cpancake,项目名称:Craft.Net,代码行数:16,代码来源:DoorBlock.cs


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