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


C# IWorld.SetBlockID方法代码示例

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


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

示例1: ItemUsedOnBlock

 public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
 {
     var bottom = coordinates + MathHelper.BlockFaceToCoordinates(face);
     var top = bottom + Coordinates3D.Up;
     if (world.GetBlockID(top) != 0 || world.GetBlockID(bottom) != 0)
         return;
     DoorFlags direction;
     switch (MathHelper.DirectionByRotationFlat(user.Entity.Yaw))
     {
         case Direction.North:
             direction = DoorFlags.Northwest;
             break;
         case Direction.South:
             direction = DoorFlags.Southeast;
             break;
         case Direction.East:
             direction = DoorFlags.Northeast;
             break;
         default: // Direction.West:
             direction = DoorFlags.Southwest;
             break;
     }
     user.Server.BlockUpdatesEnabled = false;
     world.SetBlockID(bottom, BlockID);
     world.SetMetadata(bottom, (byte)direction);
     world.SetBlockID(top, BlockID);
     world.SetMetadata(top, (byte)(direction | DoorFlags.Upper));
     user.Server.BlockUpdatesEnabled = true;
     item.Count--;
     user.Inventory[user.SelectedSlot] = item;
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:31,代码来源:DoorItem.cs

示例2: BlockUpdate

 public override void BlockUpdate(BlockDescriptor descriptor, BlockDescriptor source, IMultiplayerServer server, IWorld world)
 {
     bool upper = ((DoorItem.DoorFlags)descriptor.Metadata & DoorItem.DoorFlags.Upper) == DoorItem.DoorFlags.Upper;
     var other = upper ? Coordinates3D.Down : Coordinates3D.Up;
     if (world.GetBlockID(descriptor.Coordinates + other) != ID)
         world.SetBlockID(descriptor.Coordinates, 0);
 }
开发者ID:Gbear605,项目名称:TrueCraft,代码行数:7,代码来源:DoorBlock.cs

示例3: ItemUsedOnBlock

 public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
 {
     coordinates += MathHelper.BlockFaceToCoordinates(face);
     if (world.GetBlockID(coordinates) == AirBlock.BlockID)
     {
         world.SetBlockID(coordinates, FireBlock.BlockID);
     }
 }
开发者ID:KayleeSmall,项目名称:TrueCraft,代码行数:8,代码来源:FlintAndSteelItem.cs

示例4: BlockUpdate

 public override void BlockUpdate(BlockDescriptor descriptor, BlockDescriptor source, IMultiplayerServer server, IWorld world)
 {
     if (world.GetBlockID(descriptor.Coordinates + Coordinates3D.Down) != FarmlandBlock.BlockID)
     {
         GenerateDropEntity(descriptor, world, server);
         world.SetBlockID(descriptor.Coordinates, 0);
     }
 }
开发者ID:Luigifan,项目名称:TrueCraft,代码行数:8,代码来源:CropsBlock.cs

示例5: BlockRightClicked

 public override bool BlockRightClicked(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
 {
     if (descriptor.Metadata == 5)
         world.SetBlockID(descriptor.Coordinates, AirBlock.BlockID);
     else
         world.SetMetadata(descriptor.Coordinates, (byte)(descriptor.Metadata + 1));
     return false;
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:8,代码来源:CakeBlock.cs

示例6: BlockUpdate

 public override void BlockUpdate(BlockDescriptor descriptor, BlockDescriptor source, IMultiplayerServer server, IWorld world)
 {
     if (world.GetBlockID(descriptor.Coordinates + Coordinates3D.Down) == AirBlock.BlockID)
     {
         world.SetBlockID(descriptor.Coordinates, AirBlock.BlockID);
         server.GetEntityManagerForWorld(world).SpawnEntity(new FallingGravelEntity(descriptor.Coordinates));
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:8,代码来源:GravelBlock.cs

示例7: ItemUsedOnBlock

 public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
 {
     if (world.GetBlockID(coordinates) == FarmlandBlock.BlockID)
     {
         world.SetBlockID(coordinates + MathHelper.BlockFaceToCoordinates(face), CropsBlock.BlockID);
         world.BlockRepository.GetBlockProvider(CropsBlock.BlockID).BlockPlaced(
             new BlockDescriptor { Coordinates = coordinates }, face, world, user);
     }
 }
开发者ID:Luigifan,项目名称:TrueCraft,代码行数:9,代码来源:SeedsItem.cs

示例8: ItemUsedOnBlock

 public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
 {
     coordinates += MathHelper.BlockFaceToCoordinates(face);
     if (item.ID == ItemID) // Empty bucket
     {
         var block = world.GetBlockID(coordinates);
         if (block == WaterBlock.BlockID || block == StationaryWaterBlock.BlockID)
         {
             var meta = world.GetMetadata(coordinates);
             if (meta == 0) // Is source block?
             {
                 user.Inventory[user.SelectedSlot] = new ItemStack(WaterBucketItem.ItemID);
                 world.SetBlockID(coordinates, 0);
             }
         }
         else if (block == LavaBlock.BlockID || block == StationaryLavaBlock.BlockID)
         {
             var meta = world.GetMetadata(coordinates);
             if (meta == 0) // Is source block?
             {
                 user.Inventory[user.SelectedSlot] = new ItemStack(LavaBucketItem.ItemID);
                 world.SetBlockID(coordinates, 0);
             }
         }
     }
     else
     {
         var provider = user.Server.BlockRepository.GetBlockProvider(world.GetBlockID(coordinates));
         if (!provider.Opaque)
         {
             if (RelevantBlockType != null)
             {
                 var blockType = RelevantBlockType.Value;
                 user.Server.BlockUpdatesEnabled = false;
                 world.SetBlockID(coordinates, blockType);
                 world.SetMetadata(coordinates, 0); // Source block
                 user.Server.BlockUpdatesEnabled = true;
                 var liquidProvider = world.BlockRepository.GetBlockProvider(blockType);
                 liquidProvider.BlockPlaced(new BlockDescriptor { Coordinates = coordinates }, face, world, user);
             }
             user.Inventory[user.SelectedSlot] = new ItemStack(BucketItem.ItemID);
         }
     }
 }
开发者ID:Luigifan,项目名称:TrueCraft,代码行数:44,代码来源:BucketItem.cs

示例9: ItemUsedOnBlock

 public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
 {
     var id = world.GetBlockID(coordinates);
     if (id == DirtBlock.BlockID || id == GrassBlock.BlockID)
     {
         world.SetBlockID(coordinates, FarmlandBlock.BlockID);
         user.Server.BlockRepository.GetBlockProvider(FarmlandBlock.BlockID).BlockPlaced(
             new BlockDescriptor { Coordinates = coordinates }, face, world, user);
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:10,代码来源:HoeItem.cs

示例10: ScheduledUpdate

 private void ScheduledUpdate(IWorld world, Coordinates3D coords)
 {
     if (world.IsValidPosition(coords + Coordinates3D.Up))
     {
         var id = world.GetBlockID(coords + Coordinates3D.Up);
         var provider = world.BlockRepository.GetBlockProvider(id);
         if (provider.Opaque)
             world.SetBlockID(coords, DirtBlock.BlockID);
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:10,代码来源:GrassBlock.cs

示例11: ItemUsedOnBlock

 public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
 {
     coordinates += MathHelper.BlockFaceToCoordinates(face);
     var old = world.BlockRepository.GetBlockProvider(world.GetBlockID(coordinates));
     if (old.Hardness == 0)
     {
         world.SetBlockID(coordinates, CakeBlock.BlockID);
         item.Count--;
         user.Inventory[user.SelectedSlot] = item;
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:11,代码来源:CakeItem.cs

示例12: ItemUsedOnBlock

        public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
        {
            coordinates += MathHelper.BlockFaceToCoordinates(face);
            IBlockProvider supportingBlock = world.BlockRepository.GetBlockProvider(world.GetBlockID(coordinates + Coordinates3D.Down));

            if (supportingBlock.Opaque)
            {
                world.SetBlockID(coordinates, RedstoneDustBlock.BlockID);
                item.Count--;
                user.Inventory[user.SelectedSlot] = item;
            }
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:12,代码来源:RedstoneItem.cs

示例13: ItemUsedOnBlock

 public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
 {
     coordinates += MathHelper.BlockFaceToCoordinates(face);
     if (SugarcaneBlock.ValidPlacement(new BlockDescriptor { Coordinates = coordinates }, world))
     {
         world.SetBlockID(coordinates, SugarcaneBlock.BlockID);
         item.Count--;
         user.Inventory[user.SelectedSlot] = item;
         user.Server.BlockRepository.GetBlockProvider(SugarcaneBlock.BlockID).BlockPlaced(
             new BlockDescriptor { Coordinates = coordinates }, face, world, user);
     }
 }
开发者ID:Luigifan,项目名称:TrueCraft,代码行数:12,代码来源:SugarCanesItem.cs

示例14: BlockPlaced

        public override void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
        {
            if (ValidCactusPosition(descriptor, user.Server.BlockRepository, world))
                base.BlockPlaced(descriptor, face, world, user);
            else
            {
                world.SetBlockID(descriptor.Coordinates, AirBlock.BlockID);

                var manager = user.Server.GetEntityManagerForWorld(world);
                manager.SpawnEntity(
                    new ItemEntity(descriptor.Coordinates + Coordinates3D.Up,
                        new ItemStack(CactusBlock.BlockID, (sbyte)1)));
                // user.Inventory.PickUpStack() wasn't working?
            }
        }
开发者ID:Luigifan,项目名称:TrueCraft,代码行数:15,代码来源:CactusBlock.cs

示例15: ItemUsedOnBlock

        public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
        {
            coordinates += MathHelper.BlockFaceToCoordinates(face);
            if (world.GetBlockID(coordinates) == AirBlock.BlockID)
            {
                world.SetBlockID(coordinates, FireBlock.BlockID);
                world.BlockRepository.GetBlockProvider(FireBlock.BlockID)
                    .BlockPlaced(world.GetBlockData(coordinates), face, world, user);

                var slot = user.SelectedItem;
                slot.Metadata += 1;
                if (slot.Metadata >= Uses)
                    slot.Count = 0; // Destroy item
                user.Inventory[user.SelectedSlot] = slot;
            }
        }
开发者ID:ComputeLinux,项目名称:TrueCraft,代码行数:16,代码来源:FlintAndSteelItem.cs


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