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


C# Level.SetBlock方法代码示例

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


在下文中一共展示了Level.SetBlock方法的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: 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
            {
                Block skull = new Block(144);
                skull.Coordinates = coor;
                skull.Metadata = 1; // Skull on floor, rotation in block entity
                world.SetBlock(skull);
            }
            else if (face == BlockFace.Down) // At the bottom of block
            {
                // Doesn't work, ignore if that happen.
                return;
            }
            else
            {
                Block skull = new Block(144);
                skull.Coordinates = coor;
                skull.Metadata = (byte) face; // Skull on floor, rotation in block entity
                world.SetBlock(skull);
            }

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

            var skullBlockEntity = new SkullBlockEntity
            {
                Coordinates = coor,
                Rotation = (byte)((int)(Math.Floor(((player.KnownPosition.Yaw)) * 16 / 360) + 0.5) & 0x0f),
                SkullType = (byte) Metadata
            };

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

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

示例4: BreakBlock

        public override void BreakBlock(Level level)
        {
            BlockCoordinates direction = new BlockCoordinates();
            switch (Metadata & 0x07)
            {
                case 0:
                    direction = Level.East;
                    break; // West
                case 1:
                    direction = Level.North;
                    break; // North
                case 2:
                    direction = Level.West;
                    break; // East
                case 3:
                    direction = Level.South;
                    break; // South
            }

            // Remove bed
            if ((Metadata & 0x08) != 0x08)
            {
                direction = direction*-1;
            }

            level.SetBlock(new Air {Coordinates = Coordinates + direction});
            level.SetBlock(new Air {Coordinates = Coordinates});
        }
开发者ID:WilliamGao1,项目名称:MiNET,代码行数:28,代码来源:Bed.cs

示例5: BreakBlock

        public override void BreakBlock(Level level)
        {
            // Remove door
            if ((Metadata & 0x08) == 0x08) // Is Upper?
            {
                level.SetBlock(new Air {Coordinates = Coordinates + Level.Down});
            }
            else
            {
                level.SetBlock(new Air {Coordinates = Coordinates + Level.Up});
            }

            level.SetBlock(new Air {Coordinates = Coordinates});
        }
开发者ID:WilliamGao1,项目名称:MiNET,代码行数:14,代码来源:WoodenDoor.cs

示例6: UseItem

        public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
        {
            byte direction = player.GetDirection();

            var coordinates = GetNewCoordinatesFromFace(blockCoordinates, face);

            // Base block, meta sets orientation
            Block block = new WoodenDoor();
            block.Coordinates = coordinates;
            block.Metadata = direction;

            int x = blockCoordinates.X;
            int y = blockCoordinates.Y;
            int z = blockCoordinates.Z;

            int xd = 0;
            int zd = 0;

            if (direction == 0) zd = 1;
            if (direction == 1) xd = -1;
            if (direction == 2) zd = -1;
            if (direction == 3) xd = 1;

            int i1 = (world.GetBlock(x - xd, y, z - zd).IsSolid ? 1 : 0) + (world.GetBlock(x - xd, y + 1, z - zd).IsSolid ? 1 : 0);
            int j1 = (world.GetBlock(x + xd, y, z + zd).IsSolid ? 1 : 0) + (world.GetBlock(x + xd, y + 1, z + zd).IsSolid ? 1 : 0);
            bool flag = world.GetBlock(x - xd, y, z - zd).Id == block.Id || world.GetBlock(x - xd, y + 1, z - zd).Id == block.Id;
            bool flag1 = world.GetBlock(x + xd, y, z + zd).Id == block.Id || world.GetBlock(x + xd, y + 1, z + zd).Id == block.Id;
            bool flag2 = false;

            if (flag && !flag1)
            {
                flag2 = true;
            }
            else if (j1 > i1)
            {
                flag2 = true;
            }

            if (!block.CanPlace(world, face)) return;

            // The upper doore block, meta marks upper and
            // sets orientation based on ajecent blocks
            Block blockUpper = new WoodenDoor();
            blockUpper.Coordinates = coordinates + Level.Up;
            blockUpper.Metadata = (byte) (0x08 | (flag2 ? 1 : 0));

            world.SetBlock(block);
            world.SetBlock(blockUpper);
        }
开发者ID:andrewhutche,项目名称:MiNET,代码行数:49,代码来源:ItemDoor.cs

示例7: CheckForHarden

		private void CheckForHarden(Level world, int x, int y, int z)
		{
			Block block = world.GetBlock(x, y, z);
			{
				bool harden = false;
				if (block is FlowingLava || block is StationaryLava)
				{
					if (IsWater(world, x, y, z))
					{
						harden = true;
					}

					if (harden || IsWater(world, x, y, z + 1))
					{
						harden = true;
					}

					if (harden || IsWater(world, x - 1, y, z))
					{
						harden = true;
					}

					if (harden || IsWater(world, x + 1, y, z))
					{
						harden = true;
					}

					if (harden || IsWater(world, x, y + 1, z))
					{
						harden = true;
					}

					if (harden)
					{
						int meta = block.Metadata;

						if (meta == 0)
						{
							world.SetBlock(new Obsidian {Coordinates = new BlockCoordinates(x, y, z)});
						}
						else if (meta <= 4)
						{
							world.SetBlock(new Cobblestone {Coordinates = new BlockCoordinates(x, y, z)});
						}
					}
				}
			}
		}
开发者ID:CRBairdUSA,项目名称:MiNET,代码行数:48,代码来源:Stationary.cs

示例8: UseItem

        public override void UseItem(Level world, Player player, BlockCoordinates targetCoordinates, BlockFace face, Vector3 faceCoords)
        {
            //if (player.GameMode != GameMode.Creative)
            //{
            //	Item itemStackInHand = player.Inventory.GetItemInHand();
            //	itemStackInHand.Count--;

            //	if (itemStackInHand.Count <= 0)
            //	{
            //		// set empty
            //		player.Inventory.Slots[player.Inventory.Slots.IndexOf(itemStackInHand)] = new ItemAir();
            //	}
            //}

            _block.Coordinates = GetNewCoordinatesFromFace(targetCoordinates, face);
            _block.Metadata = (byte) Metadata;

            if ((player.GetBoundingBox() - 0.01f).Intersects(_block.GetBoundingBox()))
            {
                Log.Debug("Can't build where you are standing: " + _block.GetBoundingBox());
                return;
            }
            if (!_block.CanPlace(world, face)) return;

            if (_block.PlaceBlock(world, player, targetCoordinates, face, faceCoords)) return; // Handled

            world.SetBlock(_block);
        }
开发者ID:CRBairdUSA,项目名称:MiNET,代码行数:28,代码来源:ItemBlock.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: 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

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

示例12: SetDoubleSlab

		private void SetDoubleSlab(Level world, BlockCoordinates coordinates)
		{
			Block slab = BlockFactory.GetBlockById((byte) (Id - 1));
			slab.Coordinates = coordinates;
			slab.Metadata = (byte) Metadata;
			world.SetBlock(slab);
		}
开发者ID:TheDiamondYT2,项目名称:MiNET,代码行数:7,代码来源:ItemSlab.cs

示例13: PlaceBlock

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

            switch (face)
            {
                case BlockFace.South: // ok
                    Metadata = 0;
                    break;
                case BlockFace.North:
                    Metadata = 1;
                    break;
                case BlockFace.West:
                    Metadata = 2;
                    break;
                case BlockFace.East: // ok
                    Metadata = 3;
                    break;
            }

            Log.Warn($"Direction={direction}, face={face}, metadata={Metadata}");

            world.SetBlock(this);

            return true;
        }
开发者ID:CRBairdUSA,项目名称:MiNET,代码行数:26,代码来源:CustomItemFrame.cs

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

示例15: SetToFlowing

		private void SetToFlowing(Level world)
		{
			Block flowingBlock = BlockFactory.GetBlockById((byte) (Id - 1));
			flowingBlock.Metadata = Metadata;
			flowingBlock.Coordinates = Coordinates;
			world.SetBlock(flowingBlock, applyPhysics: false);
			world.ScheduleBlockTick(flowingBlock, 5);
		}
开发者ID:CRBairdUSA,项目名称:MiNET,代码行数:8,代码来源:Stationary.cs


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