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


C# Level.GetBlock方法代码示例

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


在下文中一共展示了Level.GetBlock方法的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)
		{
			// 8 = 1000
			byte upperBit = 0x08;
			// 7 = 0111
			byte materialMask = 0x07;

			Block existingBlock = world.GetBlock(blockCoordinates);

			var coordinates = GetNewCoordinatesFromFace(blockCoordinates, face);
			Block newBlock = world.GetBlock(coordinates);

			if (face == BlockFace.Up && faceCoords.Y == 0.5 && existingBlock.Id == Id && (existingBlock.Metadata & materialMask) == Metadata)
			{
				// Replace with double block
				SetDoubleSlab(world, blockCoordinates);
				return;
			}

			if (face == BlockFace.Down && faceCoords.Y == 0.5 && (existingBlock.Metadata & materialMask) == Metadata)
			{
				// Replace with double block
				SetDoubleSlab(world, blockCoordinates);
				return;
			}

			if (newBlock.Id != Id || (newBlock.Metadata & materialMask) != Metadata)
			{
				Block slab = BlockFactory.GetBlockById((byte) (Id));
				slab.Coordinates = coordinates;
				slab.Metadata = (byte) Metadata;
				if (face != BlockFace.Up && faceCoords.Y > 0.5 || (face == BlockFace.Down && faceCoords.Y == 0.0))
				{
					slab.Metadata |= upperBit;
				}
				world.SetBlock(slab);
				return;
			}

			// Same material in existing block, make double slab

			{
				// Create double slab, replace existing
				SetDoubleSlab(world, coordinates);
			}
		}
开发者ID:TheDiamondYT2,项目名称:MiNET,代码行数:46,代码来源:ItemSlab.cs

示例3: DoPhysics

		public override void DoPhysics(Level level)
		{
			CheckForHarden(level, Coordinates.X, Coordinates.Y, Coordinates.Z);

			if (level.GetBlock(Coordinates).Id == Id)
			{
				SetToFlowing(level);
			}
		}
开发者ID:CRBairdUSA,项目名称:MiNET,代码行数:9,代码来源:Stationary.cs

示例4: UseItem

 public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
 {
     Block block = world.GetBlock(blockCoordinates);
     if (block is Grass)
     {
         GrassPath grassPath = new GrassPath
         {
             Coordinates = blockCoordinates,
         };
         world.SetBlock(grassPath);
     }
 }
开发者ID:andrewhutche,项目名称:MiNET,代码行数:12,代码来源:ItemShovel.cs

示例5: UseItem

		public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
		{
			Block block = world.GetBlock(blockCoordinates);
			if (block is Grass || block is Dirt || block is GrassPath)
			{
				Farmland farmland = new Farmland
				{
					Coordinates = blockCoordinates,
					Metadata = 0
				};
				world.SetBlock(farmland);
			}
		}
开发者ID:TheDiamondYT2,项目名称:MiNET,代码行数:13,代码来源:ItemHoe.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: Interact

        public override bool Interact(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face)
        {
            Block block = this;
            // Remove door
            if ((Metadata & 0x08) == 0x08) // Is Upper?
            {
                block = world.GetBlock(GetNewCoordinatesFromFace(blockCoordinates, BlockFace.Down));
            }

            block.Metadata ^= 0x04;
            world.SetBlock(block);

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

示例8: UseItem

        public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
        {
            if (NeedBlockRevert)
            {
                var coord = GetNewCoordinatesFromFace(blockCoordinates, face);

                Log.Info("Reset block");
                // Resend the block to removed the new one
                Block block = world.GetBlock(coord);
                world.SetBlock(block);
            }

            Action(this, world, player, blockCoordinates);
        }
开发者ID:CRBairdUSA,项目名称:MiNET,代码行数:14,代码来源:ItemCommand.cs

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

示例10: CanPlace

		protected override bool CanPlace(Level world, BlockCoordinates blockCoordinates, BlockFace face)
		{
			Block block = world.GetBlock(blockCoordinates);
			if (block is Farmland
			    || block is Ice
				/*|| block is Glowstone || block is Leaves  */
			    || block is Tnt
			    || block is BlockStairs
			    || block is StoneSlab
			    || block is WoodSlab) return true;

			//TODO: More checks here, but PE blocks it pretty good right now
			if (block is Glass && face == BlockFace.Up) return true;

			return !block.IsTransparent;
		}
开发者ID:PocketRealms,项目名称:MiNET,代码行数:16,代码来源:Torch.cs

示例11: BlocksFluid

		private bool BlocksFluid(Level world, int x, int y, int z)
		{
			Block block = world.GetBlock(x, y, z);

			return BlocksFluid(block);
		}
开发者ID:TheDiamondYT2,项目名称:MiNET,代码行数:6,代码来源:Flowing.cs

示例12: CanPlace

 protected override bool CanPlace(Level world, BlockCoordinates blockCoordinates)
 {
     return world.GetBlock(blockCoordinates).IsReplacible && world.GetBlock(blockCoordinates + Level.Up).IsReplacible;
 }
开发者ID:WilliamGao1,项目名称:MiNET,代码行数:4,代码来源:WoodenDoor.cs

示例13: CanPlace

		protected virtual bool CanPlace(Level world, BlockCoordinates blockCoordinates, BlockFace face)
		{
			return world.GetBlock(blockCoordinates).IsReplacible;
		}
开发者ID:TheDiamondYT2,项目名称:MiNET,代码行数:4,代码来源:Block.cs

示例14: OnTick

        public override void OnTick(Level level)
        {
            if (Inventory == null) return;

            Furnace furnace = level.GetBlock(Coordinates) as Furnace;
            if (furnace == null) return;

            if (!(furnace is LitFurnace))
            {
                Item fuel = GetFuel();
                Item ingredient = GetIngredient();
                Item smelt = ingredient.GetSmelt();
                // To light a furnace you need both fule and proper ingredient.
                if (fuel.Count > 0 && fuel.FuelEfficiency > 0 && smelt != null)
                {
                    LitFurnace litFurnace = new LitFurnace
                    {
                        Coordinates = furnace.Coordinates,
                        Metadata = furnace.Metadata
                    };

                    level.SetBlock(litFurnace);
                    furnace = litFurnace;

                    BurnTime = GetFuelEfficiency(fuel);
                    FuelEfficiency = BurnTime;
                    CookTime = 0;
                    Inventory.DecreaseSlot(1);
                }
            }

            if (furnace is LitFurnace)
            {
                if (BurnTime > 0)
                {
                    BurnTime--;
                    BurnTick = (short) Math.Ceiling((double) BurnTime/FuelEfficiency*200d);

                    Item ingredient = GetIngredient();
                    Item smelt = ingredient.GetSmelt();
                    if (smelt != null)
                    {
                        CookTime++;
                        if (CookTime >= 200)
                        {
                            Inventory.DecreaseSlot(0);
                            Inventory.IncreaseSlot(2, smelt.Id, smelt.Metadata);

                            CookTime = 0;
                        }
                    }
                    else
                    {
                        CookTime = 0;
                    }
                }

                if (BurnTime <= 0)
                {
                    var fuel = GetFuel();
                    Item ingredient = GetIngredient();
                    Item smelt = ingredient.GetSmelt();
                    if (fuel.Count > 0 && fuel.FuelEfficiency > 0 && smelt != null)
                    {
                        Inventory.DecreaseSlot(1);

                        CookTime = 0;
                        BurnTime = GetFuelEfficiency(fuel);
                        FuelEfficiency = BurnTime;
                        BurnTick = (short) Math.Ceiling((double) BurnTime/FuelEfficiency*200d);
                    }
                    else
                    {
                        // No more fule or nothin more to smelt.
                        Furnace unlitFurnace = new Furnace
                        {
                            Coordinates = furnace.Coordinates,
                            Metadata = furnace.Metadata
                        };

                        level.SetBlock(unlitFurnace);
                        FuelEfficiency = 0;
                        BurnTick = 0;
                        BurnTime = 0;
                        CookTime = 0;
                    }
                }
            }

            foreach (var observer in Inventory.Observers)
            {
                var cookTimeSetData = McpeContainerSetData.CreateObject();
                cookTimeSetData.windowId = Inventory.WindowsId;
                cookTimeSetData.property = 0;
                cookTimeSetData.value = CookTime;
                observer.SendPackage(cookTimeSetData);

                var burnTimeSetData = McpeContainerSetData.CreateObject();
                burnTimeSetData.windowId = Inventory.WindowsId;
                burnTimeSetData.property = 1;
//.........这里部分代码省略.........
开发者ID:CRBairdUSA,项目名称:MiNET,代码行数:101,代码来源:FurnaceBlockEntity.cs

示例15: OnTick

        public override void OnTick(Level level)
        {
            if (Inventory == null) return;

            Furnace furnace = level.GetBlock(Coordinates) as Furnace;
            if (furnace == null) return;

            if (!(furnace is LitFurnace))
            {
                if (GetFuel().Id != 0)
                {
                    LitFurnace litFurnace = new LitFurnace
                    {
                        Coordinates = furnace.Coordinates,
                        Metadata = furnace.Metadata
                    };

                    level.SetBlock(litFurnace);
                    furnace = litFurnace;

                    BurnTime = GetFuelEfficiency(GetFuel());
                    FuelEfficiency = BurnTime;
                    CookTime = 0;
                    Inventory.DecreaseSlot(1);
                }
            }

            if (!(furnace is LitFurnace)) return;

            if (BurnTime > 0)
            {
                BurnTime--;
                BurnTick = (short) Math.Ceiling((double) BurnTime/FuelEfficiency*200d);

                if (GetIngredient().Id != 0)
                {
                    CookTime++;
                    if (CookTime >= 200)
                    {
                        Item result = GetResult(GetIngredient());
                        if (result != null)
                        {
                            Inventory.DecreaseSlot(0);
                            Inventory.IncreaseSlot(2, result.Id, result.Metadata);
                        }

                        CookTime = 0;
                    }
                }
                else
                {
                    CookTime = 0;
                }
            }

            if (BurnTime <= 0)
            {
                if (!Inventory.DecreaseSlot(1))
                {
                    //CookTime = 0;
                    BurnTime = GetFuelEfficiency(GetFuel());
                    FuelEfficiency = BurnTime;
                    BurnTick = (short) Math.Ceiling((double) BurnTime/FuelEfficiency*200d);
                }
                else
                {
                    // No more fule
                    Furnace unlitFurnace = new Furnace
                    {
                        Coordinates = furnace.Coordinates,
                        Metadata = furnace.Metadata
                    };

                    level.SetBlock(unlitFurnace);
                    FuelEfficiency = 0;
                    BurnTick = 0;
                    BurnTime = 0;
                    CookTime = 0;
                }
            }

            level.RelayBroadcast(new McpeContainerSetData
            {
                windowId = Inventory.WindowsId,
                property = 0,
                value = CookTime
            });

            level.RelayBroadcast(new McpeContainerSetData
            {
                windowId = Inventory.WindowsId,
                property = 1,
                value = BurnTick
            });
        }
开发者ID:shishir333,项目名称:MiNET,代码行数:95,代码来源:FurnaceBlockEntity.cs


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