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


C# Level.SetBlockEntity方法代码示例

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


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

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

示例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)
        {
            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();
                }
            }

            var coor = GetNewCoordinatesFromFace(blockCoordinates, face);
            Chest chest = new Chest
            {
                Coordinates = coor,
            };

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

            chest.PlaceBlock(world, player, coor, face, faceCoords);

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

            ChestBlockEntity chestBlockEntity = new ChestBlockEntity
            {
                Coordinates = coor
            };

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

示例4: UseItem

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

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

			var coor = GetNewCoordinatesFromFace(blockCoordinates, face);
			EnchantingTable table = new EnchantingTable
			{
				Coordinates = coor,
				Metadata = (byte) Metadata
			};

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

			table.PlaceBlock(world, player, coor, face, faceCoords);

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

			EnchantingTableBlockEntity tableBlockEntity = new EnchantingTableBlockEntity
			{
				Coordinates = coor
			};

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

示例5: Interact

        public override bool Interact(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
        {
            Item itemInHande = player.Inventory.GetItemInHand();

            ItemFrameBlockEntity blockEntity = world.GetBlockEntity(blockCoordinates) as ItemFrameBlockEntity;
            if (blockEntity != null)
            {
                blockEntity.SetItem(itemInHande);
                world.SetBlockEntity(blockEntity);
            }

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

示例6: UseItem

        public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
        {
            var coor = GetNewCoordinatesFromFace(blockCoordinates, face);
            Furnace furnace = new Furnace
            {
                Coordinates = coor,
            };

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

            furnace.PlaceBlock(world, player, coor, face, faceCoords);

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

            FurnaceBlockEntity furnaceBlockEntity = new FurnaceBlockEntity
            {
                Coordinates = coor
            };

            world.SetBlockEntity(furnaceBlockEntity);
        }
开发者ID:andrewhutche,项目名称:MiNET,代码行数:21,代码来源:ItemFurnace.cs

示例7: UseItem

        public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
        {
            var coor = GetNewCoordinatesFromFace(blockCoordinates, face);
            Chest chest = new Chest
            {
                Coordinates = coor,
                Metadata = (byte) Metadata
            };

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

            chest.PlaceBlock(world, player, coor, face, faceCoords);

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

            ChestBlockEntity chestBlockEntity = new ChestBlockEntity
            {
                Coordinates = coor
            };

            world.SetBlockEntity(chestBlockEntity);
        }
开发者ID:ruslan81,项目名称:MiNET,代码行数:22,代码来源:ItemChest.cs

示例8: UseItem

        public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
        {
            Log.Warn("Using custom item frame");

            var coor = GetNewCoordinatesFromFace(blockCoordinates, face);

            ItemFrameBlockEntity itemFrameBlockEntity = new ItemFrameBlockEntity
            {
                Coordinates = coor
            };

            CustomItemFrame itemFrame = new CustomItemFrame(_frames, itemFrameBlockEntity, world, _frameTicker)
            {
                Coordinates = coor,
            };

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

            itemFrame.PlaceBlock(world, player, coor, face, faceCoords);

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

            world.SetBlockEntity(itemFrameBlockEntity);
        }
开发者ID:CRBairdUSA,项目名称:MiNET,代码行数:24,代码来源:CustomItemFrame.cs


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