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


C# BlockFace类代码示例

本文整理汇总了C#中BlockFace的典型用法代码示例。如果您正苦于以下问题:C# BlockFace类的具体用法?C# BlockFace怎么用?C# BlockFace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: UseItem

        public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
        {
            Log.Warn("Player " + player.Username + " should be banned for hacking!");

            var block = world.GetBlock(blockCoordinates);
            if (block is Tnt)
            {
                world.SetBlock(new Air() {Coordinates = block.Coordinates});
                new PrimedTnt(world)
                {
                    KnownPosition = new PlayerLocation(blockCoordinates.X, blockCoordinates.Y, blockCoordinates.Z),
                    Fuse = (byte) (new Random().Next(0, 20) + 10)
                }.SpawnEntity();
            }
            else if (block.IsSolid)
            {
                var affectedBlock = world.GetBlock(GetNewCoordinatesFromFace(blockCoordinates, BlockFace.Up));
                if (affectedBlock.Id == 0)
                {
                    var fire = new Fire
                    {
                        Coordinates = affectedBlock.Coordinates
                    };
                    world.SetBlock(fire);
                }
            }
        }
开发者ID:newchild,项目名称:MiNET,代码行数:27,代码来源:ItemFlintAndSteel.cs

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

示例3: Place

        public override void Place(EntityBase entity, StructBlock block, StructBlock targetBlock, BlockFace targetSide)
        {
            Player player = entity as Player;
            if (player == null)
                return;

            // TODO: Bugged - should depend on the player's Yaw/Pitch
            switch (player.Client.FacingDirection(4))
            {
                case "N":
                    block.MetaData = (byte)MetaData.Stairs.South;
                    break;
                case "E":
                    block.MetaData = (byte)MetaData.Stairs.West;
                    break;
                case "S":
                    block.MetaData = (byte)MetaData.Stairs.North;
                    break;
                case "W":
                    block.MetaData = (byte)MetaData.Stairs.East;
                    break;
                default:
                    return;
            }
            base.Place(entity, block, targetBlock, targetSide);
        }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:26,代码来源:BlockCobblestoneStairs.cs

示例4: UseItem

        public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
        {
            var coor = GetNewCoordinatesFromFace(blockCoordinates, face);
            if (face == BlockFace.Up) // On top of block
            {
                // Standing Sign
                var sign = new StandingSign();
                sign.Coordinates = coor;
                // metadata for sign is a value 0-15 that signify the orientation of the sign. Same as PC metadata.
                sign.Metadata = (byte) ((int) (Math.Floor((player.KnownPosition.Yaw + 180)*16/360) + 0.5) & 0x0f);
                world.SetBlock(sign);
            }
            else if (face == BlockFace.North) // At the bottom of block
            {
                // Doesn't work, ignore if that happen.
                return;
            }
            else
            {
                // Wall sign
                var sign = new WallSign();
                sign.Coordinates = coor;
                sign.Metadata = (byte) face;
                world.SetBlock(sign);
            }

            // Then we create and set the sign block entity that has all the intersting data

            var signBlockEntity = new Sign
            {
                Coordinates = coor
            };

            world.SetBlockEntity(signBlockEntity);
        }
开发者ID:GoldishKirby,项目名称:MiNET,代码行数:35,代码来源:ItemSign.cs

示例5: PlaceBlock

		public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
		{
			if (face == BlockFace.Down) return true;

			switch (face)
			{
				case BlockFace.Up:
					Metadata = 5;
					break;
				case BlockFace.East:
					Metadata = 4;
					break;
				case BlockFace.West:
					Metadata = 3;
					break;
				case BlockFace.North:
					Metadata = 2;
					break;
				case BlockFace.South:
					Metadata = 1;
					break;
			}

			world.SetBlock(this);
			return true;
		}
开发者ID:PocketRealms,项目名称:MiNET,代码行数:26,代码来源:Torch.cs

示例6: Interact

        public override bool Interact(Level currentLevel, Player player, BlockCoordinates blockCoordinates, BlockFace face)
        {
            Sign signEntity = currentLevel.GetBlockEntity(blockCoordinates) as Sign;
            if (signEntity == null) return false;

            string world = signEntity.Text1;

            if (player.Level.LevelId.Equals(world)) return true;

            if (!Worlds.ContainsKey(player.Level.LevelId))
            {
                Worlds.Add(player.Level.LevelId, player.Level);
            }

            if (!Worlds.ContainsKey(world))
            {
                var mobHuntLevel = new MobHuntLevel(world, new FlatlandWorldProvider());
                mobHuntLevel.Initialize();
                Worlds.Add(world, mobHuntLevel);
            }

            Level level = Worlds[world];
            player.SpawnLevel(level);
            level.BroadcastTextMessage(string.Format("{0} teleported to world <{1}>.", player.Username, level.LevelId));

            return true;
        }
开发者ID:WilliamGao1,项目名称:MiNET,代码行数:27,代码来源:CustomStandingSign.cs

示例7: Place

        public override void Place(IEntityBase entity, IStructBlock iBlock, IStructBlock targetIBlock, BlockFace face)
        {
            var block = (StructBlock)iBlock;
            var living = entity as LivingEntity;
            if (living == null)
                return;

            // TODO: Bugged - should depend on the player's Yaw/Pitch
            switch (living.FacingDirection(4))
            {
                case "N":
                    block.MetaData = (byte)MetaData.Stairs.South;
                    break;
                case "E":
                    block.MetaData = (byte)MetaData.Stairs.West;
                    break;
                case "S":
                    block.MetaData = (byte)MetaData.Stairs.North;
                    break;
                case "W":
                    block.MetaData = (byte)MetaData.Stairs.East;
                    break;
                default:
                    return;
            }
            base.Place(entity, block, targetIBlock, face);
        }
开发者ID:TheaP,项目名称:c-raft,代码行数:27,代码来源:BlockWoodenStairs.cs

示例8: PlaceBlock

        public override bool PlaceBlock(Level world, Player player, Vector3 blockCoordinates, BlockFace face, Vector3 mouseLocation)
        {
            var rawbits = new BitArray(new byte[] { 0x00 });

            byte direction = player.GetDirection();
            if (face == BlockFace.PositiveY)
            {
                switch (direction)
                {
                    case 0:
                        //South
                        rawbits[1] = true;
                        rawbits[2] = true;
                        break;
                    case 1:
                        //West
                        rawbits[0] = true;
                        rawbits[2] = true;
                        break;
                    case 2:
                        //North
                        rawbits[1] = true;
                        rawbits[2] = true;
                        break;
                    case 3:
                        //East
                        rawbits[0] = true;
                        rawbits[2] = true;
                        break;
                }
            }
            else if (face == BlockFace.NegativeY)
            {
                rawbits[0] = true;
                rawbits[1] = true;
                rawbits[2] = true;
            }
            else if (face == BlockFace.PositiveZ)
            {
                rawbits[0] = true;
                rawbits[1] = true;
            }
            else if (face == BlockFace.NegativeZ)
            {
                rawbits[2] = true;
            }
            else if (face == BlockFace.PositiveX)
            {
                rawbits[0] = true;
            }
            else if (face == BlockFace.NegativeX)
            {
                rawbits[1] = true;
            }

            Metadata = ConvertToByte(rawbits);

            world.SetBlock(this);
            return true;
        }
开发者ID:LiveMC,项目名称:SharpMC,代码行数:60,代码来源:BlockLever.cs

示例9: PlaceBlock

        // 000 001 010 011 100
        public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
        {
            byte direction = player.GetDirection();

            byte upper = (byte) ((faceCoords.Y > 0.5 && face != BlockFace.Up) || face == BlockFace.Down ? 0x04 : 0x00);

            switch (direction)
            {
                case 0:
                    Metadata = (byte) (0 | upper);
                    break;
                case 1:
                    Metadata = (byte) (2 | upper);
                    break;
                case 2:
                    Metadata = (byte) (1 | upper);
                    break;
                case 3:
                    Metadata = (byte) (3 | upper);
                    break;
            }

            world.SetBlock(this);
            return true;
        }
开发者ID:CRBairdUSA,项目名称:MiNET,代码行数:26,代码来源:BlockStairs.cs

示例10: Place

 public override void Place(IEntityBase entity, IStructBlock iBlock, IStructBlock targetIBlock, BlockFace face)
 {
     StructBlock block = (StructBlock)iBlock;
     LivingEntity living = entity as LivingEntity;
     if (living == null)
         return;
     switch (living.FacingDirection(4))
     {
         case "N":
             block.MetaData = (byte)MetaData.Door.Northwest;
             break;
         case "W":
             block.MetaData = (byte)MetaData.Door.Southwest;
             break;
         case "S":
             block.MetaData = (byte)MetaData.Door.Southeast;
             break;
         case "E":
             block.MetaData = (byte)MetaData.Door.Northeast;
             break;
         default:
             return;
     }
     base.Place(entity, block, targetIBlock, face);
 }
开发者ID:TheaP,项目名称:c-raft,代码行数:25,代码来源:BlockBaseDoor.cs

示例11: Interact

		public override bool Interact(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face)
		{
			Metadata = (byte) (Metadata | (0x8));
			world.SetBlock(this);
			world.ScheduleBlockTick(this, TickRate);
			return true;
		}
开发者ID:TheDiamondYT2,项目名称:MiNET,代码行数:7,代码来源:Button.cs

示例12: PlaceBlock

		public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
		{
			Metadata = (byte) face;

			world.SetBlock(this);
			return true;
		}
开发者ID:TheDiamondYT2,项目名称:MiNET,代码行数:7,代码来源:Button.cs

示例13: Place

        public override void Place(EntityBase entity, StructBlock block, StructBlock targetBlock, BlockFace face)
        {
            // Load the blocks surrounding the position (NSEW) not diagonals
            BlockData.Blocks[] nsewBlocks = new BlockData.Blocks[4];
            UniversalCoords[] nsewBlockPositions = new UniversalCoords[4];
            int nsewCount = 0;
            block.Chunk.ForNSEW(block.Coords, (uc) =>
            {
                nsewBlocks[nsewCount] = (BlockData.Blocks)block.World.GetBlockId(uc);
                nsewBlockPositions[nsewCount] = uc;
                nsewCount++;
            });

            // Count chests in list
            if (nsewBlocks.Where((b) => b == BlockData.Blocks.Chest).Count() > 1)
            {
                // Cannot place next to two chests
                return;
            }

            for (int i = 0; i < 4; i++)
            {
                UniversalCoords p = nsewBlockPositions[i];
                if (nsewBlocks[i] == BlockData.Blocks.Chest && block.Chunk.IsNSEWTo(p, (byte)BlockData.Blocks.Chest))
                {
                    // Cannot place next to a double chest
                    return;
                }
            }
            base.Place(entity, block, targetBlock, face);
        }
开发者ID:Smjert,项目名称:c-raft,代码行数:31,代码来源:BlockChest.cs

示例14: PlaceBlock

 public override bool PlaceBlock(Level world, Player player, Vector3 blockCoordinates, BlockFace face, Vector3 mouseLocation)
 {
     var prevblock = world.GetBlock(Coordinates);
     if (prevblock.Id == Id && prevblock.Metadata == Metadata)
     {
         DoubleSlab ds = new DoubleSlab(Metadata) {Coordinates = Coordinates};
         world.SetBlock(ds);
     }
     else if (prevblock.Id == Id && prevblock.Metadata != Metadata)
     {
         if (player.Gamemode != Gamemode.Creative)
         {
             player.Inventory.AddItem((short)Id, Metadata, 1);
         }
         return true;
     }
     else
     {
         bool upper = ((mouseLocation.Y >= 8 && face != BlockFace.PositiveY) || face == BlockFace.NegativeY);
         BitArray b = new BitArray(new byte[] {Metadata});
         b[3] = upper;
         Metadata = ConvertToByte(b);
         world.SetBlock(this);
     }
     return true;
 }
开发者ID:LiveMC,项目名称:SharpMC,代码行数:26,代码来源:Slab.cs

示例15: UseItem

 public override void UseItem(Level world, Player player, Vector3 blockCoordinates, BlockFace face)
 {
     blockCoordinates = GetNewCoordinatesFromFace(blockCoordinates, face);
     var d = new BlockRedstoneDust {Coordinates = blockCoordinates};
     //d.SetPowerLevel(new Random().Next(0,15));
     world.SetBlock(d, true, true);
 }
开发者ID:LiveMC,项目名称:SharpMC,代码行数:7,代码来源:ItemRedstone.cs


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