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


C# IWorld.GetBlockData方法代码示例

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


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

示例1: ItemUsedOnBlock

 public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
 {
     coordinates += MathHelper.BlockFaceToCoordinates(face);
     var descriptor = world.GetBlockData(coordinates);
     LadderDirection direction;
     switch (MathHelper.DirectionByRotationFlat(user.Entity.Yaw))
     {
         case Direction.North:
             direction = LadderDirection.North;
             break;
         case Direction.South:
             direction = LadderDirection.South;
             break;
         case Direction.East:
             direction = LadderDirection.East;
             break;
         default:
             direction = LadderDirection.West;
             break;
     }
     descriptor.Metadata = (byte)direction;
     if (IsSupported(descriptor, user.Server, world))
     {
         world.SetBlockID(descriptor.Coordinates, BlockID);
         world.SetMetadata(descriptor.Coordinates, (byte)direction);
         item.Count--;
         user.Inventory[user.SelectedSlot] = item;
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:29,代码来源:LadderBlock.cs

示例2: 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

示例3: FlowOutward

 private void FlowOutward(IWorld world, LiquidFlow target, IMultiplayerServer server)
 {
     // For each block we can flow into, generate an item entity if appropriate
     var provider = world.BlockRepository.GetBlockProvider(world.GetBlockID(target.TargetBlock));
     provider.GenerateDropEntity(new BlockDescriptor { Coordinates = target.TargetBlock, ID = provider.ID }, world, server, ItemStack.EmptyStack);
     // And overwrite the block with a new fluid block.
     world.SetBlockID(target.TargetBlock, FlowingID);
     world.SetMetadata(target.TargetBlock, target.Level);
     var chunk = world.FindChunk(target.TargetBlock);
     server.Scheduler.ScheduleEvent("fluid", chunk,
         TimeSpan.FromSeconds(SecondsBetweenUpdates),
         s => AutomataUpdate(s, world, target.TargetBlock));
     if (FlowingID == LavaBlock.BlockID)
     {
         (BlockRepository.GetBlockProvider(FireBlock.BlockID) as FireBlock).ScheduleUpdate(
             server, world, world.GetBlockData(target.TargetBlock));
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:18,代码来源:FluidBlock.cs

示例4: ItemUsedOnBlock

        public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
        {
            coordinates += MathHelper.BlockFaceToCoordinates(face);
            var old = world.GetBlockData(coordinates);
            byte[] overwritable =
            {
                AirBlock.BlockID,
                WaterBlock.BlockID,
                StationaryWaterBlock.BlockID,
                LavaBlock.BlockID,
                StationaryLavaBlock.BlockID
            };
            if (overwritable.Any(b => b == old.ID))
            {
                var data = world.GetBlockData(coordinates);
                data.ID = ID;
                data.Metadata = (byte)item.Metadata;

                BlockPlaced(data, face, world, user);

                if (!IsSupported(world.GetBlockData(coordinates), user.Server, world))
                    world.SetBlockData(coordinates, old);
                else
                {
                    item.Count--;
                    user.Inventory[user.SelectedSlot] = item;
                }
            }
        }
开发者ID:Luigifan,项目名称:TrueCraft,代码行数:29,代码来源:TorchBlock.cs

示例5: ItemUsedOnBlock

        public virtual void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
        {
            coordinates += MathHelper.BlockFaceToCoordinates(face);
            var old = world.GetBlockData(coordinates);
            byte[] overwritable =
                {
                    AirBlock.BlockID,
                    WaterBlock.BlockID,
                    StationaryWaterBlock.BlockID,
                    LavaBlock.BlockID,
                    StationaryLavaBlock.BlockID
                };
            if (overwritable.Any(b => b == old.ID))
            {
                // Test for entities
                var em = user.Server.GetEntityManagerForWorld(world);
                var entities = em.EntitiesInRange(coordinates, 2);
                var box = new BoundingBox(coordinates, coordinates + Vector3.One);
                foreach (var entity in entities)
                {
                    var aabb = entity as IAABBEntity;
                    if (aabb != null && !(entity is ItemEntity))
                    {
                        if (aabb.BoundingBox.Intersects(box) && false) // TODO: Figure out
                            return;
                    }
                    var player = entity as PlayerEntity; // Players do not implement IAABBEntity
                    if (player != null)
                    {
                        if (new BoundingBox(player.Position, player.Position + player.Size)
                            .Intersects(box) && false)
                            return;
                    }
                }

                // Place block
                world.SetBlockID(coordinates, ID);
                world.SetMetadata(coordinates, (byte)item.Metadata);

                BlockPlaced(world.GetBlockData(coordinates), face, world, user);

                if (!IsSupported(world.GetBlockData(coordinates), user.Server, world))
                    world.SetBlockData(coordinates, old);
                else
                {
                    item.Count--;
                    user.Inventory[user.SelectedSlot] = item;
                }
            }
        }
开发者ID:zevipa,项目名称:TrueCraft,代码行数:50,代码来源:BlockProvider.cs

示例6: ItemUsedOnBlock

        public virtual void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
        {
            var old = world.GetBlockData(coordinates);
            if (!Overwritable.Any(b => b == old.ID))
            {
                coordinates += MathHelper.BlockFaceToCoordinates(face);
                old = world.GetBlockData(coordinates);
                if (!Overwritable.Any(b => b == old.ID))
                    return;
            }

            // Test for entities
            if (BoundingBox.HasValue)
            {
                var em = user.Server.GetEntityManagerForWorld(world);
                var entities = em.EntitiesInRange(coordinates, 3);
                var box = new BoundingBox(BoundingBox.Value.Min + (Vector3)coordinates,
                    BoundingBox.Value.Max + (Vector3)coordinates);
                foreach (var entity in entities)
                {
                    var aabb = entity as IAABBEntity;
                    if (aabb != null && !(entity is ItemEntity))
                    {
                        if (aabb.BoundingBox.Intersects(box))
                            return;
                    }
                    var player = entity as PlayerEntity; // Players do not implement IAABBEntity
                    if (player != null)
                    {
                        if (new BoundingBox(player.Position, player.Position + player.Size)
                            .Intersects(box))
                            return;
                    }
                }
            }

            // Place block
            world.SetBlockID(coordinates, ID);
            world.SetMetadata(coordinates, (byte)item.Metadata);

            BlockPlaced(world.GetBlockData(coordinates), face, world, user);

            if (!IsSupported(world.GetBlockData(coordinates), user.Server, world))
                world.SetBlockData(coordinates, old);
            else
            {
                item.Count--;
                user.Inventory[user.SelectedSlot] = item;
            }
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:50,代码来源:BlockProvider.cs

示例7: DoSpread

        public void DoSpread(IMultiplayerServer server, IWorld world, BlockDescriptor descriptor)
        {
            foreach (var coord in SpreadableBlocks)
            {
                var check = descriptor.Coordinates + coord;
                if (world.GetBlockID(check) == AirBlock.BlockID)
                {
                    // Check if this is adjacent to a flammable block
                    foreach (var adj in AdjacentBlocks)
                    {
                        var provider = BlockRepository.GetBlockProvider(
                           world.GetBlockID(check + adj));
                        if (provider.Flammable)
                        {
                            if (provider.Hardness == 0)
                                check = check + adj;

                            // Spread to this block
                            world.SetBlockID(check, FireBlock.BlockID);
                            ScheduleUpdate(server, world, world.GetBlockData(check));
                            break;
                        }
                    }
                }
            }
        }
开发者ID:ComputeLinux,项目名称:TrueCraft,代码行数:26,代码来源:FireBlock.cs


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